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 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 Loading... |
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 Loading... |
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 Loading... |
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 // Appends an ACTION_UPDATE for a sync tab entity onto |change_output| to |
| 251 // reflect the contents of |tab|, given the tab node id |sync_id|. |
| 252 void AppendChangeForExistingTab(int sync_id, |
| 253 const sessions::SessionTab& tab, |
| 254 syncer::SyncChangeList* change_output); |
| 255 |
249 // Stops and re-starts syncing to rebuild association mappings. Returns true | 256 // Stops and re-starts syncing to rebuild association mappings. Returns true |
250 // when re-starting succeeds. | 257 // when re-starting succeeds. |
251 // See |local_tab_pool_out_of_sync_|. | 258 // See |local_tab_pool_out_of_sync_|. |
252 bool RebuildAssociations(); | 259 bool RebuildAssociations(); |
253 | 260 |
254 // Validates the content of a SessionHeader protobuf. | 261 // Validates the content of a SessionHeader protobuf. |
255 // Returns false if validation fails. | 262 // Returns false if validation fails. |
256 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header); | 263 static bool IsValidSessionHeader(const sync_pb::SessionHeader& header); |
257 | 264 |
258 // Calculates the tag hash from a specifics object. Calculating the hash is | 265 // Calculates the tag hash from a specifics object. Calculating the hash is |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 325 |
319 // Callback to inform sync that a sync data refresh is requested. | 326 // Callback to inform sync that a sync data refresh is requested. |
320 base::Closure datatype_refresh_callback_; | 327 base::Closure datatype_refresh_callback_; |
321 | 328 |
322 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); | 329 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); |
323 }; | 330 }; |
324 | 331 |
325 } // namespace sync_sessions | 332 } // namespace sync_sessions |
326 | 333 |
327 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 334 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
OLD | NEW |