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

Side by Side Diff: chrome/browser/sync/sessions/sessions_sync_manager.h

Issue 1408643002: [Sync] Componentize synced_tab_delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN, self review Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ 5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
6 #define CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ 6 #define CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 class SyncedWindowDelegatesGetter; 53 class SyncedWindowDelegatesGetter;
54 54
55 // An interface defining the ways in which local open tab events can interact 55 // An interface defining the ways in which local open tab events can interact
56 // with session sync. All local tab events flow to sync via this interface. 56 // with session sync. All local tab events flow to sync via this interface.
57 // In that way it is analogous to sync changes flowing to the local model 57 // In that way it is analogous to sync changes flowing to the local model
58 // via ProcessSyncChanges, just with a more granular breakdown. 58 // via ProcessSyncChanges, just with a more granular breakdown.
59 class LocalSessionEventHandler { 59 class LocalSessionEventHandler {
60 public: 60 public:
61 // A local navigation event took place that affects the synced session 61 // A local navigation event took place that affects the synced session
62 // for this instance of Chrome. 62 // for this instance of Chrome.
63 virtual void OnLocalTabModified(SyncedTabDelegate* modified_tab) = 0; 63 // Returns true if the tab had syncable data, false otherwise.
64 virtual bool OnLocalTabModified(SyncedTabDelegate* modified_tab) = 0;
64 65
65 // A local navigation occurred that triggered updates to favicon data for 66 // A local navigation occurred that triggered updates to favicon data for
66 // each page URL in |page_urls| (e.g. http://www.google.com) and the icon URL 67 // each page URL in |page_urls| (e.g. http://www.google.com) and the icon URL
67 // |icon_url| (e.g. http://www.google.com/favicon.ico). This is routed through 68 // |icon_url| (e.g. http://www.google.com/favicon.ico). This is routed through
68 // Sessions Sync so that we can filter (exclude) favicon updates for pages 69 // Sessions Sync so that we can filter (exclude) favicon updates for pages
69 // that aren't currently part of the set of local open tabs, and pass relevant 70 // that aren't currently part of the set of local open tabs, and pass relevant
70 // updates on to FaviconCache for out-of-band favicon syncing. 71 // updates on to FaviconCache for out-of-band favicon syncing.
71 virtual void OnFaviconsChanged(const std::set<GURL>& page_urls, 72 virtual void OnFaviconsChanged(const std::set<GURL>& page_urls,
72 const GURL& icon_url) = 0; 73 const GURL& icon_url) = 0;
73 }; 74 };
74 75
75 // The LocalSessionEventRouter is responsible for hooking itself up to various 76 // The LocalSessionEventRouter is responsible for hooking itself up to various
76 // notification sources in the browser process and forwarding relevant 77 // notification sources in the browser process and forwarding relevant
77 // events to a handler as defined in the LocalSessionEventHandler contract. 78 // events to a handler as defined in the LocalSessionEventHandler contract.
78 class LocalSessionEventRouter { 79 class LocalSessionEventRouter {
79 public: 80 public:
80 virtual ~LocalSessionEventRouter(); 81 virtual ~LocalSessionEventRouter();
81 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0; 82 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0;
82 virtual void Stop() = 0; 83 virtual void Stop() = 0;
83 }; 84 };
84 85
85 // Contains all logic for associating the Chrome sessions model and 86 // Contains all logic for associating the Chrome sessions model and
86 // the sync sessions model. 87 // the sync sessions model.
87 class SessionsSyncManager : public syncer::SyncableService, 88 class SessionsSyncManager : public syncer::SyncableService,
88 public sync_driver::OpenTabsUIDelegate, 89 public sync_driver::OpenTabsUIDelegate,
89 public LocalSessionEventHandler { 90 public LocalSessionEventHandler {
90 public: 91 public:
91 SessionsSyncManager( 92 SessionsSyncManager(
93 sync_sessions::SyncSessionsClient* sessions_client,
92 Profile* profile, 94 Profile* profile,
93 sync_driver::LocalDeviceInfoProvider* local_device, 95 sync_driver::LocalDeviceInfoProvider* local_device,
94 scoped_ptr<LocalSessionEventRouter> router, 96 scoped_ptr<LocalSessionEventRouter> router,
95 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter); 97 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter);
96 ~SessionsSyncManager() override; 98 ~SessionsSyncManager() override;
97 99
98 // syncer::SyncableService implementation. 100 // syncer::SyncableService implementation.
99 syncer::SyncMergeResult MergeDataAndStartSyncing( 101 syncer::SyncMergeResult MergeDataAndStartSyncing(
100 syncer::ModelType type, 102 syncer::ModelType type,
101 const syncer::SyncDataList& initial_sync_data, 103 const syncer::SyncDataList& initial_sync_data,
(...skipping 18 matching lines...) Expand all
120 const SessionID::id_type tab_id, 122 const SessionID::id_type tab_id,
121 const sessions::SessionTab** tab) override; 123 const sessions::SessionTab** tab) override;
122 bool GetForeignSessionTabs( 124 bool GetForeignSessionTabs(
123 const std::string& tag, 125 const std::string& tag,
124 std::vector<const sessions::SessionTab*>* tabs) override; 126 std::vector<const sessions::SessionTab*>* tabs) override;
125 void DeleteForeignSession(const std::string& tag) override; 127 void DeleteForeignSession(const std::string& tag) override;
126 bool GetLocalSession( 128 bool GetLocalSession(
127 const sync_driver::SyncedSession** local_session) override; 129 const sync_driver::SyncedSession** local_session) override;
128 130
129 // LocalSessionEventHandler implementation. 131 // LocalSessionEventHandler implementation.
130 void OnLocalTabModified(SyncedTabDelegate* modified_tab) override; 132 bool OnLocalTabModified(SyncedTabDelegate* modified_tab) override;
131 void OnFaviconsChanged(const std::set<GURL>& page_urls, 133 void OnFaviconsChanged(const std::set<GURL>& page_urls,
132 const GURL& icon_url) override; 134 const GURL& icon_url) override;
133 135
134 // Returns the tag used to uniquely identify this machine's session in the 136 // Returns the tag used to uniquely identify this machine's session in the
135 // sync model. 137 // sync model.
136 const std::string& current_machine_tag() const { 138 const std::string& current_machine_tag() const {
137 DCHECK(!current_machine_tag_.empty()); 139 DCHECK(!current_machine_tag_.empty());
138 return current_machine_tag_; 140 return current_machine_tag_;
139 } 141 }
140 142
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 syncer::SyncChangeList* change_output); 338 syncer::SyncChangeList* change_output);
337 339
338 // Stops and re-starts syncing to rebuild association mappings. 340 // Stops and re-starts syncing to rebuild association mappings.
339 // See |local_tab_pool_out_of_sync_|. 341 // See |local_tab_pool_out_of_sync_|.
340 void RebuildAssociations(); 342 void RebuildAssociations();
341 343
342 // Validates the content of a SessionHeader protobuf. 344 // Validates the content of a SessionHeader protobuf.
343 // Returns false if validation fails. 345 // Returns false if validation fails.
344 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header); 346 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header);
345 347
348 // The client of this sync sessions datatype.
349 sync_sessions::SyncSessionsClient* const sessions_client_;
350
346 // Mapping of current open (local) tabs to their sync identifiers. 351 // Mapping of current open (local) tabs to their sync identifiers.
347 TabLinksMap local_tab_map_; 352 TabLinksMap local_tab_map_;
348 353
349 SyncedSessionTracker session_tracker_; 354 SyncedSessionTracker session_tracker_;
350 FaviconCache favicon_cache_; 355 FaviconCache favicon_cache_;
351 356
352 // Pool of used/available sync nodes associated with local tabs. 357 // Pool of used/available sync nodes associated with local tabs.
353 TabNodePool local_tab_pool_; 358 TabNodePool local_tab_pool_;
354 359
355 // Tracks whether our local representation of which sync nodes map to what 360 // Tracks whether our local representation of which sync nodes map to what
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 395
391 // Owns revisiting instrumentation logic for page visit events. 396 // Owns revisiting instrumentation logic for page visit events.
392 PageRevisitBroadcaster page_revisit_broadcaster_; 397 PageRevisitBroadcaster page_revisit_broadcaster_;
393 398
394 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); 399 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager);
395 }; 400 };
396 401
397 } // namespace browser_sync 402 } // namespace browser_sync
398 403
399 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ 404 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698