desktop/source/lib/init.cxx |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 8143148f6d7d3237ae1e438f3ed0a637a21549b8
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 26 13:56:09 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/+/150035
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d6a0904210a2..9dc5b6bf66f2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4598,13 +4598,18 @@ 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> const & pCallback)
+    DispatchResultListener(const char* pCommand,
+                           std::shared_ptr<CallbackFlushHandler> const& 
pCallback)
         : maCommand(pCommand)
         , mpCallback(pCallback)
+        , mSaveTime(std::chrono::steady_clock::now())
+        , mbWasModified(SfxObjectShell::Current()->IsModified())
     {
         assert(mpCallback);
     }
@@ -4621,6 +4626,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());
     }
 

Reply via email to