summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2023-03-11 10:11:07 -0500
committerMiklos Vajna <vmiklos@collabora.com>2023-04-12 14:03:55 +0200
commit81dc568ab3f504bca58810da0b0bd3c4c2737096 (patch)
tree59a791171bd450aa090073b061d98c13c8d32dee /desktop
parentca9df86986e5cc5d60e74b9325cf0268dbacbfd4 (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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149985 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0521af8b427a..49d4298c7a66 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4612,13 +4612,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);
}
@@ -4635,6 +4639,14 @@ public:
}
unoAnyToJson(aJson, "result", rEvent.Result);
+ aJson.put("wasModified", mbWasModified);
+ aJson.put("startUnixTimeMics",
+ std::chrono::time_point_cast<std::chrono::microseconds>(mSaveTime)
+ .time_since_epoch()
+ .count());
+ aJson.put("saveDurationMics", std::chrono::duration_cast<std::chrono::microseconds>(
+ std::chrono::steady_clock::now() - mSaveTime)
+ .count());
mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, aJson.finishAndGetAsOString());
}