| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, MergeDeletesBadHash); | 139 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, MergeDeletesBadHash); |
| 140 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, | 140 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, |
| 141 MergeLocalSessionExistingTabs); | 141 MergeLocalSessionExistingTabs); |
| 142 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, | 142 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, |
| 143 CheckPrerenderedWebContentsSwap); | 143 CheckPrerenderedWebContentsSwap); |
| 144 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, | 144 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, |
| 145 AssociateWindowsDontReloadTabs); | 145 AssociateWindowsDontReloadTabs); |
| 146 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, SwappedOutOnRestore); | 146 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, SwappedOutOnRestore); |
| 147 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, | 147 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, |
| 148 ProcessRemoteDeleteOfLocalSession); | 148 ProcessRemoteDeleteOfLocalSession); |
| 149 FRIEND_TEST_ALL_PREFIXES(SessionsSyncManagerTest, SetVariationIds); | |
| 150 | 149 |
| 151 void InitializeCurrentMachineTag(const std::string& cache_guid); | 150 void InitializeCurrentMachineTag(const std::string& cache_guid); |
| 152 | 151 |
| 153 // Load and add window or tab data from synced specifics to our internal | 152 // Load and add window or tab data from synced specifics to our internal |
| 154 // tracking. | 153 // tracking. |
| 155 void UpdateTrackerWithSpecifics(const sync_pb::SessionSpecifics& specifics, | 154 void UpdateTrackerWithSpecifics(const sync_pb::SessionSpecifics& specifics, |
| 156 const base::Time& modification_time); | 155 const base::Time& modification_time); |
| 157 | 156 |
| 158 // Returns true if |sync_data| contained a header node for the current | 157 // Returns true if |sync_data| contained a header node for the current |
| 159 // machine, false otherwise. |new_changes| is a link to the SyncChange | 158 // machine, false otherwise. |new_changes| is a link to the SyncChange |
| (...skipping 28 matching lines...) Expand all Loading... |
| 188 | 187 |
| 189 // Used to populate a session header from the session specifics header | 188 // Used to populate a session header from the session specifics header |
| 190 // provided. | 189 // provided. |
| 191 static void PopulateSessionHeaderFromSpecifics( | 190 static void PopulateSessionHeaderFromSpecifics( |
| 192 const sync_pb::SessionHeader& header_specifics, | 191 const sync_pb::SessionHeader& header_specifics, |
| 193 base::Time mtime, | 192 base::Time mtime, |
| 194 SyncedSession* session_header); | 193 SyncedSession* session_header); |
| 195 | 194 |
| 196 // Builds |session_window| from the session specifics window | 195 // Builds |session_window| from the session specifics window |
| 197 // provided and updates the SessionTracker with foreign session data created. | 196 // provided and updates the SessionTracker with foreign session data created. |
| 198 void BuildSyncedSessionFromSpecifics(const std::string& session_tag, | 197 void BuildSyncedSessionFromSpecifics( |
| 199 const sync_pb::SessionWindow& specifics, | 198 const std::string& session_tag, |
| 200 base::Time mtime, | 199 const sync_pb::SessionWindow& specifics, |
| 201 sessions::SessionWindow* session_window); | 200 base::Time mtime, |
| 201 SyncedSessionWindow* synced_session_window); |
| 202 | 202 |
| 203 // Resync local window information. Updates the local sessions header node | 203 // 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 | 204 // 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 | 205 // only be called for changes that affect a window, not a change within a |
| 206 // single tab. | 206 // single tab. |
| 207 // | 207 // |
| 208 // RELOAD_TABS will additionally cause a resync of all tabs (same as calling | 208 // RELOAD_TABS will additionally cause a resync of all tabs (same as calling |
| 209 // AssociateTabs with a vector of all tabs). | 209 // AssociateTabs with a vector of all tabs). |
| 210 // | 210 // |
| 211 // Returns: false if the local session's sync nodes were deleted and | 211 // Returns: false if the local session's sync nodes were deleted and |
| (...skipping 11 matching lines...) Expand all Loading... |
| 223 // that exists in the caller's context. This function will append necessary | 223 // that exists in the caller's context. This function will append necessary |
| 224 // changes for processing later. | 224 // changes for processing later. |
| 225 void AssociateTab(SyncedTabDelegate* const tab, | 225 void AssociateTab(SyncedTabDelegate* const tab, |
| 226 syncer::SyncChangeList* change_output); | 226 syncer::SyncChangeList* change_output); |
| 227 | 227 |
| 228 // Set |session_tab| from |tab_delegate| and |mtime|. | 228 // Set |session_tab| from |tab_delegate| and |mtime|. |
| 229 void SetSessionTabFromDelegate(const SyncedTabDelegate& tab_delegate, | 229 void SetSessionTabFromDelegate(const SyncedTabDelegate& tab_delegate, |
| 230 base::Time mtime, | 230 base::Time mtime, |
| 231 sessions::SessionTab* session_tab); | 231 sessions::SessionTab* session_tab); |
| 232 | 232 |
| 233 // Sets |variation_ids| field of |session_tab| with the ids of the currently | |
| 234 // assigned variations which should be sent to sync. | |
| 235 static void SetVariationIds(sessions::SessionTab* session_tab); | |
| 236 | |
| 237 // Populates |specifics| based on the data in |tab_delegate|. | 233 // Populates |specifics| based on the data in |tab_delegate|. |
| 238 void LocalTabDelegateToSpecifics(const SyncedTabDelegate& tab_delegate, | 234 void LocalTabDelegateToSpecifics(const SyncedTabDelegate& tab_delegate, |
| 239 sync_pb::SessionSpecifics* specifics); | 235 sync_pb::SessionSpecifics* specifics); |
| 240 | 236 |
| 241 // It's possible that when we associate windows, tabs aren't all loaded | 237 // It's possible that when we associate windows, tabs aren't all loaded |
| 242 // into memory yet (e.g on android) and we don't have a WebContents. In this | 238 // into memory yet (e.g on android) and we don't have a WebContents. In this |
| 243 // case we can't do a full association, but we still want to update tab IDs | 239 // case we can't do a full association, but we still want to update tab IDs |
| 244 // as they may have changed after a session was restored. This method | 240 // as they may have changed after a session was restored. This method |
| 245 // compares new_tab_id and new_window_id against the previously persisted tab | 241 // compares new_tab_id and new_window_id against the previously persisted tab |
| 246 // ID and window ID (from our TabNodePool) and updates them if either differs. | 242 // ID and window ID (from our TabNodePool) and updates them if either differs. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 318 |
| 323 // Callback to inform sync that a sync data refresh is requested. | 319 // Callback to inform sync that a sync data refresh is requested. |
| 324 base::Closure datatype_refresh_callback_; | 320 base::Closure datatype_refresh_callback_; |
| 325 | 321 |
| 326 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); | 322 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); |
| 327 }; | 323 }; |
| 328 | 324 |
| 329 } // namespace sync_sessions | 325 } // namespace sync_sessions |
| 330 | 326 |
| 331 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 327 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| OLD | NEW |