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

Unified Diff: components/sync_sessions/sessions_sync_manager.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_sessions/sessions_sync_manager.h
diff --git a/components/sync_sessions/sessions_sync_manager.h b/components/sync_sessions/sessions_sync_manager.h
index 975b673cdc62fcf59b0b0a73c956e0364483718a..8776a8964aeb2ff43f0da6b7c3f1217b2e4a212b 100644
--- a/components/sync_sessions/sessions_sync_manager.h
+++ b/components/sync_sessions/sessions_sync_manager.h
@@ -6,6 +6,7 @@
#define COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
#include <stddef.h>
+#include <stdint.h>
#include <map>
#include <memory>
@@ -23,6 +24,7 @@
#include "components/sync/base/sync_prefs.h"
#include "components/sync/device_info/device_info.h"
#include "components/sync/model/syncable_service.h"
+#include "components/sync/user_events/global_id_mapper.h"
#include "components/sync_sessions/favicon_cache.h"
#include "components/sync_sessions/local_session_event_router.h"
#include "components/sync_sessions/lost_navigations_recorder.h"
@@ -58,7 +60,8 @@ class SyncedWindowDelegatesGetter;
// the sync sessions model.
class SessionsSyncManager : public syncer::SyncableService,
public OpenTabsUIDelegate,
- public LocalSessionEventHandler {
+ public LocalSessionEventHandler,
+ public syncer::GlobalIdMapper {
public:
SessionsSyncManager(SyncSessionsClient* sessions_client,
syncer::SyncPrefs* sync_prefs,
@@ -117,6 +120,10 @@ class SessionsSyncManager : public syncer::SyncableService,
// sessions data downloaded (sync cycles complete).
void DoGarbageCollection();
+ // GlobalIdMapper implementation.
+ void AddGlobalIdChangeObserver(syncer::GlobalIdChange callback) override;
+ int64_t GetLatestGlobalId(int64_t global_id) override;
+
private:
friend class extensions::ExtensionSessionsTest;
friend class SessionsSyncManagerTest;
@@ -281,6 +288,10 @@ class SessionsSyncManager : public syncer::SyncableService,
SyncedWindowDelegatesGetter* synced_window_delegates_getter() const;
+ void TrackNavigationIds(const sessions::SerializedNavigationEntry& current);
+
+ void CleanupNavigationTracking();
+
// The client of this sync sessions datatype.
SyncSessionsClient* const sessions_client_;
@@ -337,6 +348,12 @@ class SessionsSyncManager : public syncer::SyncableService,
// changes of current session.
std::unique_ptr<TaskTracker> task_tracker_;
+ // Used to track global_ids that should be used when referencing various
+ // pieces of sessions data, and notify observer when things have changed.
+ std::map<int64_t, int> global_to_unique_;
+ std::map<int, int64_t> unique_to_current_global_;
+ std::vector<syncer::GlobalIdChange> global_id_change_observers_;
+
DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager);
};

Powered by Google App Engine
This is Rietveld 408576698