diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2023-03-11 10:11:07 -0500 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-04-17 11:49:17 +0200 |
commit | 5700349951fa4bba750836d6f4b0979b005e11c0 (patch) | |
tree | f78690fb022cba30f06cb41d52b596a6bad75c3a /desktop | |
parent | d65f88621351aaa7bc753edec611619fceac110b (diff) |
lok: capture and publish the modified status in save result
This is necessary to flag to the storage whether or not
the contents of the file being uploaded has any user
modifications or not. This is typically used to optimize
the versioning and storage utilization.
We also add the time when saving started and the duration
it took. The timestamp is to figure out if there has been
subsequent activity/commands that could have modified
the document. The duration is to help Online throttle
saving if too frequent.
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: Id6d8e629ef9b6e723d1d8b84d64fc7741b997bc5
(cherry picked from commit 26742677b53a33e1aaee191750f7af51e4b56844)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150380
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Ashod Nakashian <ash@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 20cc63231cbd..918a4fe04368 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4631,13 +4631,17 @@ namespace { */ class DispatchResultListener : public cppu::WeakImplHelper<css::frame::XDispatchResultListener> { - OString maCommand; ///< Command for which this is the result. - std::shared_ptr<CallbackFlushHandler> mpCallback; ///< Callback to call. + const OString maCommand; ///< Command for which this is the result. + const std::shared_ptr<CallbackFlushHandler> mpCallback; ///< Callback to call. + const std::chrono::steady_clock::time_point mSaveTime; //< The time we started saving. + const bool mbWasModified; //< Whether or not the document was modified before saving. public: DispatchResultListener(const char* pCommand, std::shared_ptr<CallbackFlushHandler> pCallback) : maCommand(pCommand) , mpCallback(std::move(pCallback)) + , mSaveTime(std::chrono::steady_clock::now()) + , mbWasModified(SfxObjectShell::Current()->IsModified()) { assert(mpCallback); } @@ -4654,6 +4658,16 @@ public: } unoAnyToJson(aJson, "result", rEvent.Result); + aJson.put("wasModified", mbWasModified); + + const auto saveTime = std::chrono::time_point_cast<std::chrono::microseconds>(mSaveTime); + aJson.put("startUnixTimeMics", + static_cast<sal_Int64>(saveTime.time_since_epoch().count())); + + const auto saveDuration = std::chrono::duration_cast<std::chrono::microseconds>( + std::chrono::steady_clock::now() - mSaveTime); + aJson.put("saveDurationMics", static_cast<sal_Int64>(saveDuration.count())); + mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, aJson.extractData()); } |