desktop/source/lib/init.cxx |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 81dc568ab3f504bca58810da0b0bd3c4c2737096
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Sat Mar 11 10:11:07 2023 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Apr 12 14:03:55 2023 +0200

    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.nakash...@collabora.co.uk>
    Change-Id: Id6d8e629ef9b6e723d1d8b84d64fc7741b997bc5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149985
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

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());
     }
 

Reply via email to