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

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

Issue 401433003: Revert of Sync: Refactoring of DEVICE_INFO syncable type - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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 25 matching lines...) Expand all
36 class SessionHeader; 36 class SessionHeader;
37 class SessionSpecifics; 37 class SessionSpecifics;
38 class SessionTab; 38 class SessionTab;
39 class SessionWindow; 39 class SessionWindow;
40 class TabNavigation; 40 class TabNavigation;
41 } // namespace sync_pb 41 } // namespace sync_pb
42 42
43 namespace browser_sync { 43 namespace browser_sync {
44 44
45 class DataTypeErrorHandler; 45 class DataTypeErrorHandler;
46 class LocalDeviceInfoProvider;
47 class SyncedTabDelegate; 46 class SyncedTabDelegate;
48 class SyncedWindowDelegate; 47 class SyncedWindowDelegate;
49 class SyncedWindowDelegatesGetter; 48 class SyncedWindowDelegatesGetter;
50 49
51 // An interface defining the ways in which local open tab events can interact 50 // An interface defining the ways in which local open tab events can interact
52 // with session sync. All local tab events flow to sync via this interface. 51 // with session sync. All local tab events flow to sync via this interface.
53 // In that way it is analogous to sync changes flowing to the local model 52 // In that way it is analogous to sync changes flowing to the local model
54 // via ProcessSyncChanges, just with a more granular breakdown. 53 // via ProcessSyncChanges, just with a more granular breakdown.
55 class LocalSessionEventHandler { 54 class LocalSessionEventHandler {
56 public: 55 public:
(...skipping 19 matching lines...) Expand all
76 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0; 75 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0;
77 virtual void Stop() = 0; 76 virtual void Stop() = 0;
78 }; 77 };
79 78
80 // Contains all logic for associating the Chrome sessions model and 79 // Contains all logic for associating the Chrome sessions model and
81 // the sync sessions model. 80 // the sync sessions model.
82 class SessionsSyncManager : public syncer::SyncableService, 81 class SessionsSyncManager : public syncer::SyncableService,
83 public OpenTabsUIDelegate, 82 public OpenTabsUIDelegate,
84 public LocalSessionEventHandler { 83 public LocalSessionEventHandler {
85 public: 84 public:
85 // Isolates SessionsSyncManager from having to depend on sync internals.
86 class SyncInternalApiDelegate {
87 public:
88 virtual ~SyncInternalApiDelegate() {}
89
90 // Returns sync's representation of the local device info.
91 // Return value is an empty scoped_ptr if the device info is unavailable.
92 virtual scoped_ptr<DeviceInfo> GetLocalDeviceInfo() const = 0;
93
94 // Used for creation of the machine tag for this local session.
95 virtual std::string GetLocalSyncCacheGUID() const = 0;
96 };
97
86 SessionsSyncManager(Profile* profile, 98 SessionsSyncManager(Profile* profile,
87 LocalDeviceInfoProvider* local_device, 99 SyncInternalApiDelegate* delegate,
88 scoped_ptr<LocalSessionEventRouter> router); 100 scoped_ptr<LocalSessionEventRouter> router);
89 virtual ~SessionsSyncManager(); 101 virtual ~SessionsSyncManager();
90 102
91 // syncer::SyncableService implementation. 103 // syncer::SyncableService implementation.
92 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( 104 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
93 syncer::ModelType type, 105 syncer::ModelType type,
94 const syncer::SyncDataList& initial_sync_data, 106 const syncer::SyncDataList& initial_sync_data,
95 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 107 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
96 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; 108 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
97 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; 109 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 141 }
130 142
131 // Return the virtual URL of the current tab, even if it's pending. 143 // Return the virtual URL of the current tab, even if it's pending.
132 static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate); 144 static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate);
133 145
134 // Return the favicon url of the current tab, even if it's pending. 146 // Return the favicon url of the current tab, even if it's pending.
135 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate); 147 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate);
136 148
137 FaviconCache* GetFaviconCache(); 149 FaviconCache* GetFaviconCache();
138 150
139 SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() const;
140
141 // Triggers garbage collection of stale sessions (as defined by 151 // Triggers garbage collection of stale sessions (as defined by
142 // |stale_session_threshold_days_|). This is called automatically every 152 // |stale_session_threshold_days_|). This is called automatically every
143 // time we start up (via AssociateModels) and when new sessions data is 153 // time we start up (via AssociateModels) and when new sessions data is
144 // downloaded (sync cycles complete). 154 // downloaded (sync cycles complete).
145 void DoGarbageCollection(); 155 void DoGarbageCollection();
146 156
147 private: 157 private:
148 // Keep all the links to local tab data in one place. A tab_node_id and tab 158 // Keep all the links to local tab data in one place. A tab_node_id and tab
149 // must be passed at creation. The tab_node_id is not mutable, although 159 // must be passed at creation. The tab_node_id is not mutable, although
150 // all other fields are. 160 // all other fields are.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // proves that we are still relevant. 347 // proves that we are still relevant.
338 bool local_tab_pool_out_of_sync_; 348 bool local_tab_pool_out_of_sync_;
339 349
340 sync_driver::SyncPrefs sync_prefs_; 350 sync_driver::SyncPrefs sync_prefs_;
341 351
342 const Profile* const profile_; 352 const Profile* const profile_;
343 353
344 scoped_ptr<syncer::SyncErrorFactory> error_handler_; 354 scoped_ptr<syncer::SyncErrorFactory> error_handler_;
345 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 355 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
346 356
347 // Local device info provider, owned by ProfileSyncService. 357 const SyncInternalApiDelegate* const delegate_;
348 const LocalDeviceInfoProvider* const local_device_;
349 358
350 // Unique client tag. 359 // Unique client tag.
351 std::string current_machine_tag_; 360 std::string current_machine_tag_;
352 361
353 // User-visible machine name. 362 // User-visible machine name.
354 std::string current_session_name_; 363 std::string current_session_name_;
355 364
356 // SyncID for the sync node containing all the window information for this 365 // SyncID for the sync node containing all the window information for this
357 // client. 366 // client.
358 int local_session_header_node_id_; 367 int local_session_header_node_id_;
359 368
360 // Number of days without activity after which we consider a session to be 369 // Number of days without activity after which we consider a session to be
361 // stale and a candidate for garbage collection. 370 // stale and a candidate for garbage collection.
362 size_t stale_session_threshold_days_; 371 size_t stale_session_threshold_days_;
363 372
364 scoped_ptr<LocalSessionEventRouter> local_event_router_; 373 scoped_ptr<LocalSessionEventRouter> local_event_router_;
365 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; 374 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_;
366 375
367 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); 376 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager);
368 }; 377 };
369 378
370 } // namespace browser_sync 379 } // namespace browser_sync
371 380
372 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ 381 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698