Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: components/sync/user_events/global_id_mapper.h

Issue 2958303002: [Sync] Maintain a global_id mapping to update UserEvents that references navigations (Closed)
Patch Set: Rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync/user_events/global_id_mapper.h
diff --git a/components/sync/user_events/global_id_mapper.h b/components/sync/user_events/global_id_mapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..eae649ee61a98b9fb9addfbb26deea01f349609c
--- /dev/null
+++ b/components/sync/user_events/global_id_mapper.h
@@ -0,0 +1,40 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SYNC_USER_EVENTS_GLOBAL_ID_MAPPER_H_
+#define COMPONENTS_SYNC_USER_EVENTS_GLOBAL_ID_MAPPER_H_
+
+#include <stdint.h>
+
+#include "base/callback.h"
+
+namespace syncer {
+
+using GlobalIdChange =
+ base::RepeatingCallback<void(int64_t old_global_id, int64_t new_global_id)>;
+
+// UserEventSpecifics references SESSIONS data through their |navigation_id|
+// which will match values seen in TabNavigation's |global_id|. This field is
+// really just the timestamp from the NavigationEntry, which can change when a
+// page is reloaded. This will cause the SESSIONS side to override the old data.
+// The impact to USER_EVENTS depends on if the previous timestamp made it to the
+// server as part of SESSIONS data or not. If it did not, then USER_EVENTS must
+// be updated. But knowing the answer that question is currently very tricky
+// with Sync's current architecture, so instead we always update for uncommitted
+// USER_EVENTS. The purpose of the GlobalIdMapper is the track changes in the
+// SESSIONS' |global_id| field and feed this information the USER_EVENTS side.
+class GlobalIdMapper {
+ public:
+ // Register for information about changing
+ virtual void AddGlobalIdChangeObserver(GlobalIdChange callback) = 0;
+
+ // Given a |global_id|, returns what the latest global_id is for the given
+ // navigation, to the best of our ability. If we do not have such a mapping,
+ // which is quite possible, the input |global_id| is returned.
+ virtual int64_t GetLatestGlobalId(int64_t global_id) = 0;
+};
+
+} // namespace syncer
+
+#endif // COMPONENTS_SYNC_USER_EVENTS_GLOBAL_ID_MAPPER_H_

Powered by Google App Engine
This is Rietveld 408576698