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

New commits:
commit 5700349951fa4bba750836d6f4b0979b005e11c0
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Sat Mar 11 10:11:07 2023 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Apr 17 11:49:17 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
    (cherry picked from commit 26742677b53a33e1aaee191750f7af51e4b56844)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150380
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Ashod Nakashian <a...@collabora.com>

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

Reply via email to