[Libreoffice-commits] online.git: wsd/Admin.cpp wsd/AdminModel.cpp wsd/AdminModel.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Dec 21 08:08:02 UTC 2018
wsd/Admin.cpp | 16 ++++++++--------
wsd/AdminModel.cpp | 2 +-
wsd/AdminModel.hpp | 27 ++++++++++++++++++---------
3 files changed, 27 insertions(+), 18 deletions(-)
New commits:
commit 5c443ca7d99b6a923a2c1fc8712661e8908b3557
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Dec 21 09:07:34 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Dec 21 09:07:40 2018 +0100
DocBasicInfo: make members private
Nicely shows that all these members are only set once in the constructor
and otherwise only read.
Change-Id: I4b48a9d0faa50efc4bec30ce94239b7438bbf889
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 414427027..7efc46331 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -610,22 +610,22 @@ void Admin::triggerMemoryCleanup(const size_t totalMem)
for (const auto& doc : docList)
{
- LOG_TRC("OOM Document: DocKey: [" << doc.DocKey << "], Idletime: [" << doc.IdleTime << "]," <<
- " Saved: [" << doc.Saved << "], Mem: [" << doc.Mem << "].");
- if (doc.Saved)
+ LOG_TRC("OOM Document: DocKey: [" << doc.getDocKey() << "], Idletime: [" << doc.getIdleTime() << "]," <<
+ " Saved: [" << doc.getSaved() << "], Mem: [" << doc.getMem() << "].");
+ if (doc.getSaved())
{
// Kill the saved documents first.
- LOG_DBG("OOM: Killing saved document with DocKey [" << doc.DocKey << "] with " << doc.Mem << " KB.");
- LOOLWSD::closeDocument(doc.DocKey, "oom");
- memToFreeKb -= doc.Mem;
+ LOG_DBG("OOM: Killing saved document with DocKey [" << doc.getDocKey() << "] with " << doc.getMem() << " KB.");
+ LOOLWSD::closeDocument(doc.getDocKey(), "oom");
+ memToFreeKb -= doc.getMem();
if (memToFreeKb <= 1024)
break;
}
else
{
// Save unsaved documents.
- LOG_TRC("Saving document: DocKey [" << doc.DocKey << "].");
- LOOLWSD::autoSave(doc.DocKey);
+ LOG_TRC("Saving document: DocKey [" << doc.getDocKey() << "].");
+ LOOLWSD::autoSave(doc.getDocKey());
}
}
}
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index e25c08bf5..df1529724 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -644,7 +644,7 @@ std::vector<DocBasicInfo> AdminModel::getDocumentsSortedByIdle() const
std::sort(std::begin(docs), std::end(docs),
[](const DocBasicInfo& a, const DocBasicInfo& b)
{
- return a.IdleTime >= b.IdleTime;
+ return a.getIdleTime() >= b.getIdleTime();
});
return docs;
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 69a9f4557..86c68df33 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -56,20 +56,29 @@ struct DocProcSettings
};
/// Containing basic information about document
-struct DocBasicInfo
+class DocBasicInfo
{
- std::string DocKey;
- std::time_t IdleTime;
- int Mem;
- bool Saved;
+ std::string _docKey;
+ std::time_t _idleTime;
+ int _mem;
+ bool _saved;
+public:
DocBasicInfo(const std::string& docKey, std::time_t idleTime, int mem, bool saved) :
- DocKey(docKey),
- IdleTime(idleTime),
- Mem(mem),
- Saved(saved)
+ _docKey(docKey),
+ _idleTime(idleTime),
+ _mem(mem),
+ _saved(saved)
{
}
+
+ const std::string& getDocKey() const { return _docKey; }
+
+ std::time_t getIdleTime() const { return _idleTime; }
+
+ int getMem() const { return _mem; }
+
+ bool getSaved() const { return _saved; }
};
/// A document in Admin controller.
More information about the Libreoffice-commits
mailing list