| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "components/sync_sessions/synced_session_tracker.h" | 5 #include "components/sync_sessions/synced_session_tracker.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 SyncedSessionTracker::SyncedSessionTracker(SyncSessionsClient* sessions_client) | 47 SyncedSessionTracker::SyncedSessionTracker(SyncSessionsClient* sessions_client) |
| 48 : sessions_client_(sessions_client) {} | 48 : sessions_client_(sessions_client) {} |
| 49 | 49 |
| 50 SyncedSessionTracker::~SyncedSessionTracker() { | 50 SyncedSessionTracker::~SyncedSessionTracker() { |
| 51 Clear(); | 51 Clear(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SyncedSessionTracker::SetLocalSessionTag( | 54 void SyncedSessionTracker::SetLocalSessionTag( |
| 55 const std::string& local_session_tag) { | 55 const std::string& local_session_tag) { |
| 56 DCHECK(local_session_tag_.empty()); |
| 57 DCHECK(!local_session_tag.empty()); |
| 56 local_session_tag_ = local_session_tag; | 58 local_session_tag_ = local_session_tag; |
| 57 } | 59 } |
| 58 | 60 |
| 59 bool SyncedSessionTracker::LookupAllForeignSessions( | 61 bool SyncedSessionTracker::LookupAllForeignSessions( |
| 60 std::vector<const SyncedSession*>* sessions, | 62 std::vector<const SyncedSession*>* sessions, |
| 61 SessionLookup lookup) const { | 63 SessionLookup lookup) const { |
| 62 DCHECK(sessions); | 64 DCHECK(sessions); |
| 63 sessions->clear(); | 65 sessions->clear(); |
| 64 for (const auto& session_pair : synced_session_map_) { | 66 for (const auto& session_pair : synced_session_map_) { |
| 65 SyncedSession* foreign_session = session_pair.second.get(); | 67 SyncedSession* foreign_session = session_pair.second.get(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 auto tab_iter = tab_map_iter->second.find(tab_id); | 102 auto tab_iter = tab_map_iter->second.find(tab_id); |
| 101 if (tab_iter == tab_map_iter->second.end()) { | 103 if (tab_iter == tab_map_iter->second.end()) { |
| 102 // We have no record of this tab. | 104 // We have no record of this tab. |
| 103 *tab = nullptr; | 105 *tab = nullptr; |
| 104 return false; | 106 return false; |
| 105 } | 107 } |
| 106 *tab = tab_iter->second; | 108 *tab = tab_iter->second; |
| 107 return true; | 109 return true; |
| 108 } | 110 } |
| 109 | 111 |
| 110 void SyncedSessionTracker::LookupTabNodeIds(const std::string& session_tag, | 112 void SyncedSessionTracker::LookupForeignTabNodeIds( |
| 111 std::set<int>* tab_node_ids) { | 113 const std::string& session_tag, |
| 114 std::set<int>* tab_node_ids) const { |
| 112 tab_node_ids->clear(); | 115 tab_node_ids->clear(); |
| 113 auto session_iter = synced_session_map_.find(session_tag); | 116 auto session_iter = synced_session_map_.find(session_tag); |
| 114 if (session_iter != synced_session_map_.end()) { | 117 if (session_iter != synced_session_map_.end()) { |
| 115 tab_node_ids->insert(session_iter->second->tab_node_ids.begin(), | 118 tab_node_ids->insert(session_iter->second->tab_node_ids.begin(), |
| 116 session_iter->second->tab_node_ids.end()); | 119 session_iter->second->tab_node_ids.end()); |
| 117 } | 120 } |
| 118 // In case an invalid node id was included, remove it. | 121 // In case an invalid node id was included, remove it. |
| 119 tab_node_ids->erase(TabNodePool::kInvalidTabNodeID); | 122 tab_node_ids->erase(TabNodePool::kInvalidTabNodeID); |
| 120 } | 123 } |
| 121 | 124 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 137 std::unique_ptr<SyncedSession> synced_session = | 140 std::unique_ptr<SyncedSession> synced_session = |
| 138 base::MakeUnique<SyncedSession>(); | 141 base::MakeUnique<SyncedSession>(); |
| 139 DVLOG(1) << "Creating new session with tag " << session_tag << " at " | 142 DVLOG(1) << "Creating new session with tag " << session_tag << " at " |
| 140 << synced_session.get(); | 143 << synced_session.get(); |
| 141 synced_session->session_tag = session_tag; | 144 synced_session->session_tag = session_tag; |
| 142 synced_session_map_[session_tag] = std::move(synced_session); | 145 synced_session_map_[session_tag] = std::move(synced_session); |
| 143 | 146 |
| 144 return synced_session_map_[session_tag].get(); | 147 return synced_session_map_[session_tag].get(); |
| 145 } | 148 } |
| 146 | 149 |
| 147 bool SyncedSessionTracker::DeleteSession(const std::string& session_tag) { | 150 bool SyncedSessionTracker::DeleteForeignSession( |
| 151 const std::string& session_tag) { |
| 152 DCHECK_NE(local_session_tag_, session_tag); |
| 148 unmapped_windows_.erase(session_tag); | 153 unmapped_windows_.erase(session_tag); |
| 149 unmapped_tabs_.erase(session_tag); | 154 unmapped_tabs_.erase(session_tag); |
| 150 | 155 |
| 151 bool header_existed = false; | 156 bool header_existed = false; |
| 152 auto iter = synced_session_map_.find(session_tag); | 157 auto iter = synced_session_map_.find(session_tag); |
| 153 if (iter != synced_session_map_.end()) { | 158 if (iter != synced_session_map_.end()) { |
| 154 // An implicitly created session that has children tabs but no header node | 159 // An implicitly created session that has children tabs but no header node |
| 155 // will have never had the device_type changed from unset. | 160 // will have never had the device_type changed from unset. |
| 156 header_existed = iter->second->device_type != SyncedSession::TYPE_UNSET; | 161 header_existed = iter->second->device_type != SyncedSession::TYPE_UNSET; |
| 157 // SyncedSession's destructor will trigger deletion of windows which will in | 162 // SyncedSession's destructor will trigger deletion of windows which will in |
| (...skipping 23 matching lines...) Expand all Loading... |
| 181 | 186 |
| 182 // Then unmap the window itself. | 187 // Then unmap the window itself. |
| 183 unmapped_windows_[session_tag][window_pair.first] = | 188 unmapped_windows_[session_tag][window_pair.first] = |
| 184 std::move(window_pair.second); | 189 std::move(window_pair.second); |
| 185 } | 190 } |
| 186 session->windows.clear(); | 191 session->windows.clear(); |
| 187 } | 192 } |
| 188 | 193 |
| 189 void SyncedSessionTracker::DeleteForeignTab(const std::string& session_tag, | 194 void SyncedSessionTracker::DeleteForeignTab(const std::string& session_tag, |
| 190 int tab_node_id) { | 195 int tab_node_id) { |
| 196 DCHECK_NE(local_session_tag_, session_tag); |
| 191 auto session_iter = synced_session_map_.find(session_tag); | 197 auto session_iter = synced_session_map_.find(session_tag); |
| 192 if (session_iter != synced_session_map_.end()) { | 198 if (session_iter != synced_session_map_.end()) { |
| 193 session_iter->second->tab_node_ids.erase(tab_node_id); | 199 session_iter->second->tab_node_ids.erase(tab_node_id); |
| 194 } | 200 } |
| 195 } | 201 } |
| 196 | 202 |
| 197 void SyncedSessionTracker::CleanupSession(const std::string& session_tag) { | 203 void SyncedSessionTracker::CleanupSessionImpl(const std::string& session_tag) { |
| 198 for (const auto& window_pair : unmapped_windows_[session_tag]) | 204 for (const auto& window_pair : unmapped_windows_[session_tag]) |
| 199 synced_window_map_[session_tag].erase(window_pair.first); | 205 synced_window_map_[session_tag].erase(window_pair.first); |
| 200 unmapped_windows_[session_tag].clear(); | 206 unmapped_windows_[session_tag].clear(); |
| 201 | 207 |
| 202 for (const auto& tab_pair : unmapped_tabs_[session_tag]) | 208 for (const auto& tab_pair : unmapped_tabs_[session_tag]) |
| 203 synced_tab_map_[session_tag].erase(tab_pair.first); | 209 synced_tab_map_[session_tag].erase(tab_pair.first); |
| 204 unmapped_tabs_[session_tag].clear(); | 210 unmapped_tabs_[session_tag].clear(); |
| 205 } | 211 } |
| 206 | 212 |
| 207 void SyncedSessionTracker::PutWindowInSession(const std::string& session_tag, | 213 void SyncedSessionTracker::PutWindowInSession(const std::string& session_tag, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 229 DCHECK(GetSession(session_tag)->windows.end() == | 235 DCHECK(GetSession(session_tag)->windows.end() == |
| 230 GetSession(session_tag)->windows.find(window_id)); | 236 GetSession(session_tag)->windows.find(window_id)); |
| 231 GetSession(session_tag)->windows[window_id] = std::move(window); | 237 GetSession(session_tag)->windows[window_id] = std::move(window); |
| 232 } | 238 } |
| 233 | 239 |
| 234 void SyncedSessionTracker::PutTabInWindow(const std::string& session_tag, | 240 void SyncedSessionTracker::PutTabInWindow(const std::string& session_tag, |
| 235 SessionID::id_type window_id, | 241 SessionID::id_type window_id, |
| 236 SessionID::id_type tab_id, | 242 SessionID::id_type tab_id, |
| 237 size_t tab_index) { | 243 size_t tab_index) { |
| 238 // We're called here for two reasons. 1) We've received an update to the | 244 // We're called here for two reasons. 1) We've received an update to the |
| 239 // SessionWindow information of a SessionHeader node for a foreign session, | 245 // SessionWindow information of a SessionHeader node for a session, |
| 240 // and 2) The SessionHeader node for our local session changed. In both cases | 246 // and 2) The SessionHeader node for our local session changed. In both cases |
| 241 // we need to update our tracking state to reflect the change. | 247 // we need to update our tracking state to reflect the change. |
| 242 // | 248 // |
| 243 // Because the SessionHeader nodes are separate from the individual tab nodes | 249 // Because the SessionHeader nodes are separate from the individual tab nodes |
| 244 // and we don't store tab_node_ids in the header / SessionWindow specifics, | 250 // and we don't store tab_node_ids in the header / SessionWindow specifics, |
| 245 // the tab_node_ids are not always available when processing headers. | 251 // the tab_node_ids are not always available when processing headers. |
| 246 // We know that we will eventually process (via GetTab) every single tab node | 252 // We know that we will eventually process (via GetTab) every single tab node |
| 247 // in the system, so we permit ourselves to use kInvalidTabNodeID here and | 253 // in the system, so we permit ourselves to use kInvalidTabNodeID here and |
| 248 // rely on the later update to build the mapping (or a restart). | 254 // rely on the later update to build the mapping (or a restart). |
| 249 GetTabImpl(session_tag, tab_id, TabNodePool::kInvalidTabNodeID); | 255 GetTab(session_tag, tab_id); |
| 250 | 256 |
| 251 // The tab should be unmapped. | 257 // The tab should be unmapped. |
| 252 std::unique_ptr<sessions::SessionTab> tab; | 258 std::unique_ptr<sessions::SessionTab> tab; |
| 253 auto it = unmapped_tabs_[session_tag].find(tab_id); | 259 auto it = unmapped_tabs_[session_tag].find(tab_id); |
| 254 if (it != unmapped_tabs_[session_tag].end()) { | 260 if (it != unmapped_tabs_[session_tag].end()) { |
| 255 tab = std::move(it->second); | 261 tab = std::move(it->second); |
| 256 unmapped_tabs_[session_tag].erase(it); | 262 unmapped_tabs_[session_tag].erase(it); |
| 257 } | 263 } |
| 258 DCHECK(tab); | 264 DCHECK(tab); |
| 259 | 265 |
| 260 tab->window_id.set_id(window_id); | 266 tab->window_id.set_id(window_id); |
| 261 DVLOG(1) << " - tab " << tab_id << " added to window " << window_id; | 267 DVLOG(1) << " - tab " << tab_id << " added to window " << window_id; |
| 262 DCHECK(GetSession(session_tag)->windows.find(window_id) != | 268 DCHECK(GetSession(session_tag)->windows.find(window_id) != |
| 263 GetSession(session_tag)->windows.end()); | 269 GetSession(session_tag)->windows.end()); |
| 264 auto& window_tabs = GetSession(session_tag)->windows[window_id]->tabs; | 270 auto& window_tabs = GetSession(session_tag)->windows[window_id]->tabs; |
| 265 if (window_tabs.size() <= tab_index) { | 271 if (window_tabs.size() <= tab_index) { |
| 266 window_tabs.resize(tab_index + 1); | 272 window_tabs.resize(tab_index + 1); |
| 267 } | 273 } |
| 268 DCHECK(!window_tabs[tab_index]); | 274 DCHECK(!window_tabs[tab_index]); |
| 269 window_tabs[tab_index] = std::move(tab); | 275 window_tabs[tab_index] = std::move(tab); |
| 270 } | 276 } |
| 271 | 277 |
| 278 void SyncedSessionTracker::OnTabNodeSeen(const std::string& session_tag, |
| 279 int tab_node_id) { |
| 280 GetSession(session_tag)->tab_node_ids.insert(tab_node_id); |
| 281 } |
| 282 |
| 272 sessions::SessionTab* SyncedSessionTracker::GetTab( | 283 sessions::SessionTab* SyncedSessionTracker::GetTab( |
| 273 const std::string& session_tag, | 284 const std::string& session_tag, |
| 274 SessionID::id_type tab_id, | 285 SessionID::id_type tab_id) { |
| 275 int tab_node_id) { | |
| 276 DCHECK_NE(TabNodePool::kInvalidTabNodeID, tab_node_id); | |
| 277 return GetTabImpl(session_tag, tab_id, tab_node_id); | |
| 278 } | |
| 279 | |
| 280 sessions::SessionTab* SyncedSessionTracker::GetTabImpl( | |
| 281 const std::string& session_tag, | |
| 282 SessionID::id_type tab_id, | |
| 283 int tab_node_id) { | |
| 284 sessions::SessionTab* tab_ptr = nullptr; | 286 sessions::SessionTab* tab_ptr = nullptr; |
| 285 auto iter = synced_tab_map_[session_tag].find(tab_id); | 287 auto iter = synced_tab_map_[session_tag].find(tab_id); |
| 286 if (iter != synced_tab_map_[session_tag].end()) { | 288 if (iter != synced_tab_map_[session_tag].end()) { |
| 287 tab_ptr = iter->second; | 289 tab_ptr = iter->second; |
| 288 if (tab_node_id != TabNodePool::kInvalidTabNodeID && | |
| 289 tab_id != TabNodePool::kInvalidTabID) { | |
| 290 // TabIDs are not stable across restarts of a client. Consider this | |
| 291 // example with two tabs: | |
| 292 // | |
| 293 // http://a.com TabID1 --> NodeIDA | |
| 294 // http://b.com TabID2 --> NodeIDB | |
| 295 // | |
| 296 // After restart, tab ids are reallocated. e.g, one possibility: | |
| 297 // http://a.com TabID2 --> NodeIDA | |
| 298 // http://b.com TabID1 --> NodeIDB | |
| 299 // | |
| 300 // If that happend on a remote client, here we will see an update to | |
| 301 // TabID1 with tab_node_id changing from NodeIDA to NodeIDB, and TabID2 | |
| 302 // with tab_node_id changing from NodeIDB to NodeIDA. | |
| 303 // | |
| 304 // We can also wind up here if we created this tab as an out-of-order | |
| 305 // update to the header node for this session before actually associating | |
| 306 // the tab itself, so the tab node id wasn't available at the time and | |
| 307 // is currently kInvalidTabNodeID. | |
| 308 // | |
| 309 // In both cases, we can safely throw it into the set of node ids. | |
| 310 GetSession(session_tag)->tab_node_ids.insert(tab_node_id); | |
| 311 } | |
| 312 | 290 |
| 313 if (VLOG_IS_ON(1)) { | 291 if (VLOG_IS_ON(1)) { |
| 314 std::string title; | 292 std::string title; |
| 315 if (tab_ptr->navigations.size() > 0) { | 293 if (tab_ptr->navigations.size() > 0) { |
| 316 title = | 294 title = |
| 317 " (" + base::UTF16ToUTF8(tab_ptr->navigations.back().title()) + ")"; | 295 " (" + base::UTF16ToUTF8(tab_ptr->navigations.back().title()) + ")"; |
| 318 } | 296 } |
| 319 DVLOG(1) << "Getting " | 297 DVLOG(1) << "Getting " |
| 320 << (session_tag == local_session_tag_ ? "local session" | 298 << (session_tag == local_session_tag_ ? "local session" |
| 321 : session_tag) | 299 : session_tag) |
| 322 << "'s seen tab " << tab_id << " at " << tab_ptr << " " << title; | 300 << "'s seen tab " << tab_id << " at " << tab_ptr << " " << title; |
| 323 } | 301 } |
| 324 } else { | 302 } else { |
| 325 std::unique_ptr<sessions::SessionTab> tab = | 303 std::unique_ptr<sessions::SessionTab> tab = |
| 326 base::MakeUnique<sessions::SessionTab>(); | 304 base::MakeUnique<sessions::SessionTab>(); |
| 327 tab_ptr = tab.get(); | 305 tab_ptr = tab.get(); |
| 328 tab->tab_id.set_id(tab_id); | 306 tab->tab_id.set_id(tab_id); |
| 329 synced_tab_map_[session_tag][tab_id] = tab_ptr; | 307 synced_tab_map_[session_tag][tab_id] = tab_ptr; |
| 330 unmapped_tabs_[session_tag][tab_id] = std::move(tab); | 308 unmapped_tabs_[session_tag][tab_id] = std::move(tab); |
| 331 GetSession(session_tag)->tab_node_ids.insert(tab_node_id); | |
| 332 DVLOG(1) << "Getting " | 309 DVLOG(1) << "Getting " |
| 333 << (session_tag == local_session_tag_ ? "local session" | 310 << (session_tag == local_session_tag_ ? "local session" |
| 334 : session_tag) | 311 : session_tag) |
| 335 << "'s new tab " << tab_id << " at " << tab_ptr; | 312 << "'s new tab " << tab_id << " at " << tab_ptr; |
| 336 } | 313 } |
| 337 DCHECK(tab_ptr); | 314 DCHECK(tab_ptr); |
| 338 DCHECK_EQ(tab_ptr->tab_id.id(), tab_id); | 315 DCHECK_EQ(tab_ptr->tab_id.id(), tab_id); |
| 339 return tab_ptr; | 316 return tab_ptr; |
| 340 } | 317 } |
| 341 | 318 |
| 319 void SyncedSessionTracker::CleanupForeignSession( |
| 320 const std::string& session_tag) { |
| 321 DCHECK_NE(local_session_tag_, session_tag); |
| 322 CleanupSessionImpl(session_tag); |
| 323 } |
| 324 |
| 325 void SyncedSessionTracker::CleanupLocalTabs(std::set<int>* deleted_node_ids) { |
| 326 DCHECK(!local_session_tag_.empty()); |
| 327 for (const auto& tab_pair : unmapped_tabs_[local_session_tag_]) |
| 328 local_tab_pool_.FreeTab(tab_pair.first); |
| 329 CleanupSessionImpl(local_session_tag_); |
| 330 local_tab_pool_.CleanupTabNodes(deleted_node_ids); |
| 331 for (int tab_node_id : *deleted_node_ids) { |
| 332 GetSession(local_session_tag_)->tab_node_ids.erase(tab_node_id); |
| 333 } |
| 334 } |
| 335 |
| 336 bool SyncedSessionTracker::GetTabNodeForLocalTab(int tab_id, int* tab_node_id) { |
| 337 DCHECK(!local_session_tag_.empty()); |
| 338 // Ensure a placeholder SessionTab is in place, if not already. |
| 339 // Although we don't need a SessionTab to fulfill this request, this forces |
| 340 // the |
| 341 // creation of one if it doesn't already exist. This helps to make sure we're |
| 342 // tracking this |tab_id| if |local_tab_pool_| is, and everyone's data |
| 343 // structures |
| 344 // are kept in sync and as consistent as possible. |
| 345 GetTab(local_session_tag_, tab_id); // Ignore result. |
| 346 |
| 347 bool reused_existing_tab = |
| 348 local_tab_pool_.GetTabNodeForTab(tab_id, tab_node_id); |
| 349 DCHECK_NE(TabNodePool::kInvalidTabNodeID, *tab_node_id); |
| 350 GetSession(local_session_tag_)->tab_node_ids.insert(*tab_node_id); |
| 351 return reused_existing_tab; |
| 352 } |
| 353 |
| 354 void SyncedSessionTracker::ReassociateLocalTab(int tab_node_id, |
| 355 SessionID::id_type new_tab_id) { |
| 356 DCHECK(!local_session_tag_.empty()); |
| 357 DCHECK_NE(TabNodePool::kInvalidTabNodeID, tab_node_id); |
| 358 DCHECK_NE(TabNodePool::kInvalidTabID, new_tab_id); |
| 359 |
| 360 SessionID::id_type old_tab_id = |
| 361 local_tab_pool_.GetTabIdFromTabNodeId(tab_node_id); |
| 362 local_tab_pool_.ReassociateTabNode(tab_node_id, new_tab_id); |
| 363 |
| 364 sessions::SessionTab* tab_ptr = nullptr; |
| 365 |
| 366 auto old_tab_iter = synced_tab_map_[local_session_tag_].find(old_tab_id); |
| 367 if (old_tab_iter != synced_tab_map_[local_session_tag_].end()) { |
| 368 tab_ptr = old_tab_iter->second; |
| 369 // Remove the tab from the synced tab map under the old id. |
| 370 synced_tab_map_[local_session_tag_].erase(old_tab_iter); |
| 371 } else { |
| 372 // It's possible a placeholder is already in place for the new tab. If so, |
| 373 // reuse it, otherwise create a new one (which will default to unmapped). |
| 374 tab_ptr = GetTab(local_session_tag_, new_tab_id); |
| 375 } |
| 376 |
| 377 // If the old tab is unmapped, update the tab id under which it is indexed. |
| 378 auto unmapped_tabs_iter = unmapped_tabs_[local_session_tag_].find(old_tab_id); |
| 379 if (old_tab_id != TabNodePool::kInvalidTabID && |
| 380 unmapped_tabs_iter != unmapped_tabs_[local_session_tag_].end()) { |
| 381 std::unique_ptr<sessions::SessionTab> tab = |
| 382 std::move(unmapped_tabs_iter->second); |
| 383 DCHECK_EQ(tab_ptr, tab.get()); |
| 384 unmapped_tabs_[local_session_tag_].erase(unmapped_tabs_iter); |
| 385 unmapped_tabs_[local_session_tag_][new_tab_id] = std::move(tab); |
| 386 } |
| 387 |
| 388 // Update the tab id. |
| 389 if (old_tab_id != TabNodePool::kInvalidTabID) { |
| 390 DVLOG(1) << "Remapped tab " << old_tab_id << " with node " << tab_node_id |
| 391 << " to tab " << new_tab_id; |
| 392 } else { |
| 393 DVLOG(1) << "Mapped new tab node " << tab_node_id << " to tab " |
| 394 << new_tab_id; |
| 395 } |
| 396 tab_ptr->tab_id.set_id(new_tab_id); |
| 397 |
| 398 // Add the tab back into the tab map with the new id. |
| 399 synced_tab_map_[local_session_tag_][new_tab_id] = tab_ptr; |
| 400 GetSession(local_session_tag_)->tab_node_ids.insert(tab_node_id); |
| 401 } |
| 402 |
| 342 void SyncedSessionTracker::Clear() { | 403 void SyncedSessionTracker::Clear() { |
| 343 // Cleanup unmapped tabs and windows. | 404 // Cleanup unmapped tabs and windows. |
| 344 unmapped_windows_.clear(); | 405 unmapped_windows_.clear(); |
| 345 unmapped_tabs_.clear(); | 406 unmapped_tabs_.clear(); |
| 346 | 407 |
| 347 // Delete SyncedSession objects (which also deletes all their windows/tabs). | 408 // Delete SyncedSession objects (which also deletes all their windows/tabs). |
| 348 synced_session_map_.clear(); | 409 synced_session_map_.clear(); |
| 349 | 410 |
| 350 // Get rid of our convenience maps (does not delete the actual Window/Tabs | 411 // Get rid of our convenience maps (does not delete the actual Window/Tabs |
| 351 // themselves; they should have all been deleted above). | 412 // themselves; they should have all been deleted above). |
| 352 synced_window_map_.clear(); | 413 synced_window_map_.clear(); |
| 353 synced_tab_map_.clear(); | 414 synced_tab_map_.clear(); |
| 354 | 415 |
| 416 local_tab_pool_.Clear(); |
| 355 local_session_tag_.clear(); | 417 local_session_tag_.clear(); |
| 356 } | 418 } |
| 357 | 419 |
| 358 } // namespace sync_sessions | 420 } // namespace sync_sessions |
| OLD | NEW |