| 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 "chrome/browser/sync/test/integration/sessions_helper.h" | 5 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 void ScopedWindowMap::Reset(SessionWindowMap* windows) { | 46 void ScopedWindowMap::Reset(SessionWindowMap* windows) { |
| 47 STLDeleteContainerPairSecondPointers(windows_.begin(), windows_.end()); | 47 STLDeleteContainerPairSecondPointers(windows_.begin(), windows_.end()); |
| 48 windows_.clear(); | 48 windows_.clear(); |
| 49 std::swap(*windows, windows_); | 49 std::swap(*windows, windows_); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool GetLocalSession(int index, const browser_sync::SyncedSession** session) { | 52 bool GetLocalSession(int index, const browser_sync::SyncedSession** session) { |
| 53 return ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 53 return ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 54 test()->GetProfile(index))->GetSessionModelAssociator()->GetLocalSession( | 54 test()->GetProfile(index))->GetSessionModelAssociatorDeprecated()-> |
| 55 session); | 55 GetLocalSession(session); |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url) { | 58 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url) { |
| 59 content::RunAllPendingInMessageLoop(); | 59 content::RunAllPendingInMessageLoop(); |
| 60 const browser_sync::SyncedSession* local_session; | 60 const browser_sync::SyncedSession* local_session; |
| 61 if (!GetLocalSession(index, &local_session)) { | 61 if (!GetLocalSession(index, &local_session)) { |
| 62 return false; | 62 return false; |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (local_session->windows.size() == 0) { | 65 if (local_session->windows.size() == 0) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 while (!found) { | 129 while (!found) { |
| 130 found = ModelAssociatorHasTabWithUrl(index, *it); | 130 found = ModelAssociatorHasTabWithUrl(index, *it); |
| 131 if (base::TimeTicks::Now() >= end_time) { | 131 if (base::TimeTicks::Now() >= end_time) { |
| 132 LOG(ERROR) << "Failed to find all tabs after " | 132 LOG(ERROR) << "Failed to find all tabs after " |
| 133 << TestTimeouts::action_max_timeout().InSecondsF() | 133 << TestTimeouts::action_max_timeout().InSecondsF() |
| 134 << " seconds."; | 134 << " seconds."; |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 if (!found) { | 137 if (!found) { |
| 138 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 138 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 139 test()->GetProfile(index))->GetSessionModelAssociator()-> | 139 test()->GetProfile(index))->GetSessionModelAssociatorDeprecated()-> |
| 140 BlockUntilLocalChangeForTest(TestTimeouts::action_max_timeout()); | 140 BlockUntilLocalChangeForTest(TestTimeouts::action_max_timeout()); |
| 141 content::RunMessageLoop(); | 141 content::RunMessageLoop(); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool GetLocalWindows(int index, SessionWindowMap* local_windows) { | 148 bool GetLocalWindows(int index, SessionWindowMap* local_windows) { |
| 149 // The local session provided by GetLocalSession is owned, and has lifetime | 149 // The local session provided by GetLocalSession is owned, and has lifetime |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 if (!GetLocalSession(index, &local_session)) { | 193 if (!GetLocalSession(index, &local_session)) { |
| 194 return 0; | 194 return 0; |
| 195 } | 195 } |
| 196 return local_session->windows.size(); | 196 return local_session->windows.size(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 int GetNumForeignSessions(int index) { | 199 int GetNumForeignSessions(int index) { |
| 200 SyncedSessionVector sessions; | 200 SyncedSessionVector sessions; |
| 201 if (!ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 201 if (!ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 202 test()->GetProfile(index))-> | 202 test()->GetProfile(index))-> |
| 203 GetSessionModelAssociator()->GetAllForeignSessions(&sessions)) | 203 GetSessionModelAssociatorDeprecated()->GetAllForeignSessions( |
| 204 &sessions)) { |
| 204 return 0; | 205 return 0; |
| 206 } |
| 205 return sessions.size(); | 207 return sessions.size(); |
| 206 } | 208 } |
| 207 | 209 |
| 208 bool GetSessionData(int index, SyncedSessionVector* sessions) { | 210 bool GetSessionData(int index, SyncedSessionVector* sessions) { |
| 209 if (!ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 211 if (!ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 210 test()->GetProfile(index))-> | 212 test()->GetProfile(index))-> |
| 211 GetSessionModelAssociator()->GetAllForeignSessions(sessions)) | 213 GetSessionModelAssociatorDeprecated()->GetAllForeignSessions( |
| 214 sessions)) { |
| 212 return false; | 215 return false; |
| 216 } |
| 213 SortSyncedSessions(sessions); | 217 SortSyncedSessions(sessions); |
| 214 return true; | 218 return true; |
| 215 } | 219 } |
| 216 | 220 |
| 217 bool CompareSyncedSessions(const browser_sync::SyncedSession* lhs, | 221 bool CompareSyncedSessions(const browser_sync::SyncedSession* lhs, |
| 218 const browser_sync::SyncedSession* rhs) { | 222 const browser_sync::SyncedSession* rhs) { |
| 219 if (!lhs || | 223 if (!lhs || |
| 220 !rhs || | 224 !rhs || |
| 221 lhs->windows.size() < 1 || | 225 lhs->windows.size() < 1 || |
| 222 rhs->windows.size() < 1) { | 226 rhs->windows.size() < 1) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 *(windows[window_index].Get()))) | 310 *(windows[window_index].Get()))) |
| 307 return false; | 311 return false; |
| 308 } | 312 } |
| 309 | 313 |
| 310 return true; | 314 return true; |
| 311 } | 315 } |
| 312 | 316 |
| 313 void DeleteForeignSession(int index, std::string session_tag) { | 317 void DeleteForeignSession(int index, std::string session_tag) { |
| 314 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 318 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 315 test()->GetProfile(index))-> | 319 test()->GetProfile(index))-> |
| 316 GetSessionModelAssociator()->DeleteForeignSession(session_tag); | 320 GetSessionModelAssociatorDeprecated()->DeleteForeignSession(session_tag); |
| 317 } | 321 } |
| 318 | 322 |
| 319 } // namespace sessions_helper | 323 } // namespace sessions_helper |
| OLD | NEW |