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

Side by Side Diff: components/sync_sessions/sessions_sync_manager.h

Issue 2791183003: [Sync] Restore previous session if no tabbed windows present (Closed)
Patch Set: Self review Created 3 years, 8 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 COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ 5 #ifndef COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
6 #define COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ 6 #define COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 FaviconCache* GetFaviconCache(); 112 FaviconCache* GetFaviconCache();
113 113
114 // Triggers garbage collection of stale sessions (as defined by 114 // Triggers garbage collection of stale sessions (as defined by
115 // |stale_session_threshold_days_|). This is called every time we see new 115 // |stale_session_threshold_days_|). This is called every time we see new
116 // sessions data downloaded (sync cycles complete). 116 // sessions data downloaded (sync cycles complete).
117 void DoGarbageCollection(); 117 void DoGarbageCollection();
118 118
119 private: 119 private:
120 friend class extensions::ExtensionSessionsTest; 120 friend class extensions::ExtensionSessionsTest;
121 friend class SessionsSyncManagerTest; 121 friend class SessionsSyncManagerTest;
122 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, PopulateSessionHeader); 122 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, PopulateSyncedSession);
123 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, PopulateSessionWindow); 123 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, PopulateSessionWindow);
124 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, ValidTabs); 124 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, ValidTabs);
125 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, SetSessionTabFromDelegate); 125 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, SetSessionTabFromDelegate);
126 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, 126 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest,
127 SetSessionTabFromDelegateNavigationIndex); 127 SetSessionTabFromDelegateNavigationIndex);
128 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, 128 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest,
129 SetSessionTabFromDelegateCurrentInvalid); 129 SetSessionTabFromDelegateCurrentInvalid);
130 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, BlockedNavigations); 130 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, BlockedNavigations);
131 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, DeleteForeignSession); 131 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, DeleteForeignSession);
132 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, 132 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 // Delete a foreign session and all its sync data. 181 // Delete a foreign session and all its sync data.
182 // |change_output| *must* be provided as a link to the SyncChange pipeline 182 // |change_output| *must* be provided as a link to the SyncChange pipeline
183 // that exists in the caller's context. This function will append necessary 183 // that exists in the caller's context. This function will append necessary
184 // changes for processing later. 184 // changes for processing later.
185 void DeleteForeignSessionInternal(const std::string& tag, 185 void DeleteForeignSessionInternal(const std::string& tag,
186 syncer::SyncChangeList* change_output); 186 syncer::SyncChangeList* change_output);
187 187
188 // Used to populate a session header from the session specifics header 188 // Used to populate a session header from the session specifics header
189 // provided. 189 // provided.
190 static void PopulateSessionHeaderFromSpecifics( 190 void PopulateSyncedSessionFromSpecifics(
191 const std::string& session_tag,
191 const sync_pb::SessionHeader& header_specifics, 192 const sync_pb::SessionHeader& header_specifics,
192 base::Time mtime, 193 base::Time mtime,
193 SyncedSession* session_header); 194 SyncedSession* synced_session);
194 195
195 // Builds |session_window| from the session specifics window 196 // Builds |synced_session_window| from the session specifics window
196 // provided and updates the SessionTracker with foreign session data created. 197 // provided and updates the SessionTracker with foreign session data created.
197 void BuildSyncedSessionFromSpecifics( 198 void PopulateSyncedSessionWindowFromSpecifics(
198 const std::string& session_tag, 199 const std::string& session_tag,
199 const sync_pb::SessionWindow& specifics, 200 const sync_pb::SessionWindow& specifics,
200 base::Time mtime, 201 base::Time mtime,
201 SyncedSessionWindow* synced_session_window); 202 SyncedSessionWindow* synced_session_window);
202 203
203 // Resync local window information. Updates the local sessions header node 204 // Resync local window information. Updates the local sessions header node
204 // with the status of open windows and the order of tabs they contain. Should 205 // with the status of open windows and the order of tabs they contain. Should
205 // only be called for changes that affect a window, not a change within a 206 // only be called for changes that affect a window, not a change within a
206 // single tab. 207 // single tab.
207 // 208 //
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // case we can't do a full association, but we still want to update tab IDs 240 // case we can't do a full association, but we still want to update tab IDs
240 // as they may have changed after a session was restored. This method 241 // as they may have changed after a session was restored. This method
241 // compares new_tab_id and new_window_id against the previously persisted tab 242 // compares new_tab_id and new_window_id against the previously persisted tab
242 // ID and window ID (from our TabNodePool) and updates them if either differs. 243 // ID and window ID (from our TabNodePool) and updates them if either differs.
243 void AssociateRestoredPlaceholderTab( 244 void AssociateRestoredPlaceholderTab(
244 const SyncedTabDelegate& tab_delegate, 245 const SyncedTabDelegate& tab_delegate,
245 SessionID::id_type new_tab_id, 246 SessionID::id_type new_tab_id,
246 SessionID::id_type new_window_id, 247 SessionID::id_type new_window_id,
247 syncer::SyncChangeList* change_output); 248 syncer::SyncChangeList* change_output);
248 249
250 // Updates a sync tab node based on local tab information.
skym 2017/04/17 20:37:02 I don't like the term update being used here. Yes,
Nicolas Zea 2017/04/17 21:24:54 Done.
251 void UpdateTabSpecifics(int sync_id,
252 const sessions::SessionTab& tab,
253 syncer::SyncChangeList* change_output);
254
249 // Stops and re-starts syncing to rebuild association mappings. Returns true 255 // Stops and re-starts syncing to rebuild association mappings. Returns true
250 // when re-starting succeeds. 256 // when re-starting succeeds.
251 // See |local_tab_pool_out_of_sync_|. 257 // See |local_tab_pool_out_of_sync_|.
252 bool RebuildAssociations(); 258 bool RebuildAssociations();
253 259
254 // Validates the content of a SessionHeader protobuf. 260 // Validates the content of a SessionHeader protobuf.
255 // Returns false if validation fails. 261 // Returns false if validation fails.
256 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header); 262 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header);
257 263
258 // Calculates the tag hash from a specifics object. Calculating the hash is 264 // Calculates the tag hash from a specifics object. Calculating the hash is
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 324
319 // Callback to inform sync that a sync data refresh is requested. 325 // Callback to inform sync that a sync data refresh is requested.
320 base::Closure datatype_refresh_callback_; 326 base::Closure datatype_refresh_callback_;
321 327
322 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); 328 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager);
323 }; 329 };
324 330
325 } // namespace sync_sessions 331 } // namespace sync_sessions
326 332
327 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ 333 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698