OLD | NEW |
---|---|
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 class SessionSpecifics; | 42 class SessionSpecifics; |
43 class SessionTab; | 43 class SessionTab; |
44 class SessionWindow; | 44 class SessionWindow; |
45 class TabNavigation; | 45 class TabNavigation; |
46 } // namespace sync_pb | 46 } // namespace sync_pb |
47 | 47 |
48 namespace browser_sync { | 48 namespace browser_sync { |
49 | 49 |
50 class DataTypeErrorHandler; | 50 class DataTypeErrorHandler; |
51 class SyncedTabDelegate; | 51 class SyncedTabDelegate; |
52 class SyncedWindowDelegate; | |
53 class SyncedWindowDelegatesGetter; | 52 class SyncedWindowDelegatesGetter; |
54 | 53 |
55 // An interface defining the ways in which local open tab events can interact | 54 // 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. | 55 // 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 | 56 // In that way it is analogous to sync changes flowing to the local model |
58 // via ProcessSyncChanges, just with a more granular breakdown. | 57 // via ProcessSyncChanges, just with a more granular breakdown. |
59 class LocalSessionEventHandler { | 58 class LocalSessionEventHandler { |
60 public: | 59 public: |
61 // A local navigation event took place that affects the synced session | 60 // A local navigation event took place that affects the synced session |
62 // for this instance of Chrome. | 61 // for this instance of Chrome. |
(...skipping 18 matching lines...) Expand all Loading... | |
81 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0; | 80 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0; |
82 virtual void Stop() = 0; | 81 virtual void Stop() = 0; |
83 }; | 82 }; |
84 | 83 |
85 // Contains all logic for associating the Chrome sessions model and | 84 // Contains all logic for associating the Chrome sessions model and |
86 // the sync sessions model. | 85 // the sync sessions model. |
87 class SessionsSyncManager : public syncer::SyncableService, | 86 class SessionsSyncManager : public syncer::SyncableService, |
88 public sync_driver::OpenTabsUIDelegate, | 87 public sync_driver::OpenTabsUIDelegate, |
89 public LocalSessionEventHandler { | 88 public LocalSessionEventHandler { |
90 public: | 89 public: |
91 SessionsSyncManager( | 90 SessionsSyncManager(sync_sessions::SyncSessionsClient* sessions_client, |
92 Profile* profile, | 91 Profile* profile, |
93 sync_driver::LocalDeviceInfoProvider* local_device, | 92 sync_driver::LocalDeviceInfoProvider* local_device, |
94 scoped_ptr<LocalSessionEventRouter> router, | 93 scoped_ptr<LocalSessionEventRouter> router); |
95 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter); | |
96 ~SessionsSyncManager() override; | 94 ~SessionsSyncManager() override; |
97 | 95 |
98 // syncer::SyncableService implementation. | 96 // syncer::SyncableService implementation. |
99 syncer::SyncMergeResult MergeDataAndStartSyncing( | 97 syncer::SyncMergeResult MergeDataAndStartSyncing( |
100 syncer::ModelType type, | 98 syncer::ModelType type, |
101 const syncer::SyncDataList& initial_sync_data, | 99 const syncer::SyncDataList& initial_sync_data, |
102 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 100 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
103 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; | 101 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; |
104 void StopSyncing(syncer::ModelType type) override; | 102 void StopSyncing(syncer::ModelType type) override; |
105 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; | 103 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
(...skipping 26 matching lines...) Expand all Loading... | |
132 const GURL& icon_url) override; | 130 const GURL& icon_url) override; |
133 | 131 |
134 // Returns the tag used to uniquely identify this machine's session in the | 132 // Returns the tag used to uniquely identify this machine's session in the |
135 // sync model. | 133 // sync model. |
136 const std::string& current_machine_tag() const { | 134 const std::string& current_machine_tag() const { |
137 DCHECK(!current_machine_tag_.empty()); | 135 DCHECK(!current_machine_tag_.empty()); |
138 return current_machine_tag_; | 136 return current_machine_tag_; |
139 } | 137 } |
140 | 138 |
141 // Return the virtual URL of the current tab, even if it's pending. | 139 // Return the virtual URL of the current tab, even if it's pending. |
142 static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate); | 140 static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate); |
sdefresne
2015/10/28 10:45:46
I think you forgot to remove this method declarati
| |
143 | 141 |
144 // Return the favicon url of the current tab, even if it's pending. | 142 // Return the favicon url of the current tab, even if it's pending. |
145 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate); | 143 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate); |
sdefresne
2015/10/28 10:45:46
Same here.
| |
146 | 144 |
147 FaviconCache* GetFaviconCache(); | 145 FaviconCache* GetFaviconCache(); |
148 | 146 |
149 SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() const; | 147 SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() const; |
150 | 148 |
151 // Triggers garbage collection of stale sessions (as defined by | 149 // Triggers garbage collection of stale sessions (as defined by |
152 // |stale_session_threshold_days_|). This is called automatically every | 150 // |stale_session_threshold_days_|). This is called automatically every |
153 // time we start up (via AssociateModels) and when new sessions data is | 151 // time we start up (via AssociateModels) and when new sessions data is |
154 // downloaded (sync cycles complete). | 152 // downloaded (sync cycles complete). |
155 void DoGarbageCollection(); | 153 void DoGarbageCollection(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 | 296 |
299 // Loads and reassociates the local tabs referenced in |tabs|. | 297 // Loads and reassociates the local tabs referenced in |tabs|. |
300 // |change_output| *must* be provided as a link to the SyncChange pipeline | 298 // |change_output| *must* be provided as a link to the SyncChange pipeline |
301 // that exists in the caller's context. This function will append necessary | 299 // that exists in the caller's context. This function will append necessary |
302 // changes for processing later. | 300 // changes for processing later. |
303 void AssociateTab(SyncedTabDelegate* const tab, | 301 void AssociateTab(SyncedTabDelegate* const tab, |
304 syncer::SyncChangeList* change_output); | 302 syncer::SyncChangeList* change_output); |
305 | 303 |
306 // Set |session_tab| from |tab_delegate| and |mtime|. | 304 // Set |session_tab| from |tab_delegate| and |mtime|. |
307 static void SetSessionTabFromDelegate( | 305 static void SetSessionTabFromDelegate( |
306 SyncedWindowDelegatesGetter* synced_window_getter, | |
308 const SyncedTabDelegate& tab_delegate, | 307 const SyncedTabDelegate& tab_delegate, |
309 base::Time mtime, | 308 base::Time mtime, |
310 sessions::SessionTab* session_tab); | 309 sessions::SessionTab* session_tab); |
311 | 310 |
312 // Sets |variation_ids| field of |session_tab| with the ids of the currently | 311 // Sets |variation_ids| field of |session_tab| with the ids of the currently |
313 // assigned variations which should be sent to sync. | 312 // assigned variations which should be sent to sync. |
314 static void SetVariationIds(sessions::SessionTab* session_tab); | 313 static void SetVariationIds(sessions::SessionTab* session_tab); |
315 | 314 |
316 // Populates |specifics| based on the data in |tab_delegate|. | 315 // Populates |specifics| based on the data in |tab_delegate|. |
317 void LocalTabDelegateToSpecifics(const SyncedTabDelegate& tab_delegate, | 316 void LocalTabDelegateToSpecifics(const SyncedTabDelegate& tab_delegate, |
(...skipping 18 matching lines...) Expand all Loading... | |
336 syncer::SyncChangeList* change_output); | 335 syncer::SyncChangeList* change_output); |
337 | 336 |
338 // Stops and re-starts syncing to rebuild association mappings. | 337 // Stops and re-starts syncing to rebuild association mappings. |
339 // See |local_tab_pool_out_of_sync_|. | 338 // See |local_tab_pool_out_of_sync_|. |
340 void RebuildAssociations(); | 339 void RebuildAssociations(); |
341 | 340 |
342 // Validates the content of a SessionHeader protobuf. | 341 // Validates the content of a SessionHeader protobuf. |
343 // Returns false if validation fails. | 342 // Returns false if validation fails. |
344 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header); | 343 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header); |
345 | 344 |
345 // The client of this sync sessions datatype. | |
346 sync_sessions::SyncSessionsClient* const sessions_client_; | |
347 | |
346 // Mapping of current open (local) tabs to their sync identifiers. | 348 // Mapping of current open (local) tabs to their sync identifiers. |
347 TabLinksMap local_tab_map_; | 349 TabLinksMap local_tab_map_; |
348 | 350 |
349 SyncedSessionTracker session_tracker_; | 351 SyncedSessionTracker session_tracker_; |
350 FaviconCache favicon_cache_; | 352 FaviconCache favicon_cache_; |
351 | 353 |
352 // Pool of used/available sync nodes associated with local tabs. | 354 // Pool of used/available sync nodes associated with local tabs. |
353 TabNodePool local_tab_pool_; | 355 TabNodePool local_tab_pool_; |
354 | 356 |
355 // Tracks whether our local representation of which sync nodes map to what | 357 // Tracks whether our local representation of which sync nodes map to what |
(...skipping 23 matching lines...) Expand all Loading... | |
379 | 381 |
380 // SyncID for the sync node containing all the window information for this | 382 // SyncID for the sync node containing all the window information for this |
381 // client. | 383 // client. |
382 int local_session_header_node_id_; | 384 int local_session_header_node_id_; |
383 | 385 |
384 // Number of days without activity after which we consider a session to be | 386 // Number of days without activity after which we consider a session to be |
385 // stale and a candidate for garbage collection. | 387 // stale and a candidate for garbage collection. |
386 size_t stale_session_threshold_days_; | 388 size_t stale_session_threshold_days_; |
387 | 389 |
388 scoped_ptr<LocalSessionEventRouter> local_event_router_; | 390 scoped_ptr<LocalSessionEventRouter> local_event_router_; |
389 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; | 391 SyncedWindowDelegatesGetter* synced_window_getter_; |
390 | 392 |
391 // Owns revisiting instrumentation logic for page visit events. | 393 // Owns revisiting instrumentation logic for page visit events. |
392 PageRevisitBroadcaster page_revisit_broadcaster_; | 394 PageRevisitBroadcaster page_revisit_broadcaster_; |
393 | 395 |
394 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); | 396 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); |
395 }; | 397 }; |
396 | 398 |
397 } // namespace browser_sync | 399 } // namespace browser_sync |
398 | 400 |
399 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 401 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
OLD | NEW |