OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/glue/foreign_session_tracker.h" | 5 #include "chrome/browser/sync/glue/foreign_session_tracker.h" |
6 #include "chrome/browser/sync/glue/session_model_associator.h" | 6 #include "chrome/browser/sync/glue/session_model_associator.h" |
7 | 7 |
8 namespace browser_sync { | 8 namespace browser_sync { |
9 | 9 |
10 | 10 |
11 ForeignSessionTracker::ForeignSessionTracker() { | 11 ForeignSessionTracker::ForeignSessionTracker() { |
12 } | 12 } |
13 | 13 |
14 ForeignSessionTracker::~ForeignSessionTracker() { | 14 ForeignSessionTracker::~ForeignSessionTracker() { |
15 clear(); | 15 clear(); |
16 } | 16 } |
17 | 17 |
18 bool ForeignSessionTracker::LookupAllForeignSessions( | 18 bool ForeignSessionTracker::LookupAllForeignSessions( |
19 std::vector<const ForeignSession*>* sessions) { | 19 std::vector<const ForeignSession*>* sessions) { |
20 DCHECK(sessions); | 20 DCHECK(sessions); |
21 // Fill vector of sessions from our foreign session map. | 21 // Fill vector of sessions from our foreign session map. |
22 for (ForeignSessionMap::const_iterator i = | 22 for (ForeignSessionMap::const_iterator i = |
23 foreign_session_map_.begin(); i != foreign_session_map_.end(); ++i) { | 23 foreign_session_map_.begin(); i != foreign_session_map_.end(); ++i) { |
24 // Only include sessions with open tabs. | 24 // Only include sessions with open tabs. |
25 ForeignSession* foreign_session = i->second; | 25 ForeignSession* foreign_session = i->second; |
26 if (foreign_session->windows.size() > 0 && | 26 if (!foreign_session->windows.empty() && |
27 !SessionModelAssociator::SessionWindowHasNoTabsToSync( | 27 !SessionModelAssociator::SessionWindowHasNoTabsToSync( |
28 *foreign_session->windows[0])) { | 28 *foreign_session->windows[0])) { |
29 sessions->push_back(foreign_session); | 29 sessions->push_back(foreign_session); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 if (sessions->size() > 0) | 33 return !sessions->empty(); |
34 return true; | |
35 else | |
36 return false; | |
37 } | 34 } |
38 | 35 |
39 bool ForeignSessionTracker::LookupSessionWindows( | 36 bool ForeignSessionTracker::LookupSessionWindows( |
40 const std::string& foreign_session_tag, | 37 const std::string& foreign_session_tag, |
41 std::vector<SessionWindow*>* windows) { | 38 std::vector<SessionWindow*>* windows) { |
42 DCHECK(windows); | 39 DCHECK(windows); |
43 ForeignSessionMap::iterator iter = foreign_session_map_.find( | 40 ForeignSessionMap::iterator iter = foreign_session_map_.find( |
44 foreign_session_tag); | 41 foreign_session_tag); |
45 if (iter == foreign_session_map_.end()) | 42 if (iter == foreign_session_map_.end()) |
46 return false; | 43 return false; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 foreign_tab_map_.end()); | 131 foreign_tab_map_.end()); |
135 foreign_tab_map_.clear(); | 132 foreign_tab_map_.clear(); |
136 | 133 |
137 // Go through and delete any tabs we had allocated but had not yet placed into | 134 // Go through and delete any tabs we had allocated but had not yet placed into |
138 // a ForeignSessionobject. | 135 // a ForeignSessionobject. |
139 STLDeleteContainerPointers(unmapped_tabs_.begin(), unmapped_tabs_.end()); | 136 STLDeleteContainerPointers(unmapped_tabs_.begin(), unmapped_tabs_.end()); |
140 unmapped_tabs_.clear(); | 137 unmapped_tabs_.clear(); |
141 } | 138 } |
142 | 139 |
143 } // namespace browser_sync | 140 } // namespace browser_sync |
OLD | NEW |