OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_sync_service_harness.h" | 5 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <sstream> | 10 #include <sstream> |
11 | 11 |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ptr_util.h" | |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
17 #include "chrome/browser/sync/profile_sync_service_factory.h" | 18 #include "chrome/browser/sync/profile_sync_service_factory.h" |
18 #include "chrome/browser/sync/test/integration/quiesce_status_change_checker.h" | 19 #include "chrome/browser/sync/test/integration/quiesce_status_change_checker.h" |
19 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" | 20 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 23 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 24 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 // Still waiting on sync setup. | 92 // Still waiting on sync setup. |
92 return false; | 93 return false; |
93 } | 94 } |
94 | 95 |
95 std::string GetDebugMessage() const override { return "Sync Setup"; } | 96 std::string GetDebugMessage() const override { return "Sync Setup"; } |
96 }; | 97 }; |
97 | 98 |
98 } // namespace | 99 } // namespace |
99 | 100 |
100 // static | 101 // static |
101 ProfileSyncServiceHarness* ProfileSyncServiceHarness::Create( | 102 std::unique_ptr<ProfileSyncServiceHarness> ProfileSyncServiceHarness::Create( |
102 Profile* profile, | 103 Profile* profile, |
103 const std::string& username, | 104 const std::string& username, |
104 const std::string& password, | 105 const std::string& password, |
105 SigninType signin_type) { | 106 SigninType signin_type) { |
106 return new ProfileSyncServiceHarness(profile, | 107 return base::WrapUnique( |
107 username, | 108 new ProfileSyncServiceHarness(profile, username, password, signin_type)); |
108 password, | |
109 signin_type); | |
110 } | 109 } |
111 | 110 |
112 ProfileSyncServiceHarness::ProfileSyncServiceHarness( | 111 ProfileSyncServiceHarness::ProfileSyncServiceHarness( |
113 Profile* profile, | 112 Profile* profile, |
114 const std::string& username, | 113 const std::string& username, |
115 const std::string& password, | 114 const std::string& password, |
116 SigninType signin_type) | 115 SigninType signin_type) |
117 : profile_(profile), | 116 : profile_(profile), |
118 service_(ProfileSyncServiceFactory::GetForProfile(profile)), | 117 service_(ProfileSyncServiceFactory::GetForProfile(profile)), |
119 username_(username), | 118 username_(username), |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 } | 282 } |
284 | 283 |
285 return true; | 284 return true; |
286 } | 285 } |
287 | 286 |
288 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( | 287 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( |
289 ProfileSyncServiceHarness* partner) { | 288 ProfileSyncServiceHarness* partner) { |
290 std::vector<ProfileSyncServiceHarness*> harnesses; | 289 std::vector<ProfileSyncServiceHarness*> harnesses; |
291 harnesses.push_back(this); | 290 harnesses.push_back(this); |
292 harnesses.push_back(partner); | 291 harnesses.push_back(partner); |
293 return AwaitQuiescence(harnesses); | 292 return AwaitQuiescence(std::move(harnesses)); |
294 } | 293 } |
295 | 294 |
296 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion( | 295 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion( |
297 const std::vector<ProfileSyncServiceHarness*>& partners) { | 296 std::vector<ProfileSyncServiceHarness*> partners) { |
298 return AwaitQuiescence(partners); | 297 return AwaitQuiescence(std::move(partners)); |
299 } | 298 } |
300 | 299 |
301 // static | 300 // static |
302 bool ProfileSyncServiceHarness::AwaitQuiescence( | 301 bool ProfileSyncServiceHarness::AwaitQuiescence( |
303 const std::vector<ProfileSyncServiceHarness*>& clients) { | 302 std::vector<ProfileSyncServiceHarness*> clients) { |
Lei Zhang
2017/03/23 02:59:26
Should this remain a const-ref?
leonhsl(Using Gerrit)
2017/03/23 15:03:17
This function is called by SyncTest::AwaitQuiescen
Nicolas Zea
2017/03/23 23:10:07
Isn't GetSyncClients good enough to access a vecto
leonhsl(Using Gerrit)
2017/03/24 02:23:12
Sorry if I'm misunderstanding the question, do you
Nicolas Zea
2017/03/24 16:48:03
Why do you need to keep a vector member in SyncTes
leonhsl(Using Gerrit)
2017/03/25 14:41:13
Ah,, I see, Thank you! Done.
| |
304 std::vector<ProfileSyncService*> services; | 303 std::vector<ProfileSyncService*> services; |
305 if (clients.empty()) { | 304 if (clients.empty()) { |
306 return true; | 305 return true; |
307 } | 306 } |
308 | 307 |
309 for (const ProfileSyncServiceHarness* harness : clients) { | 308 for (const ProfileSyncServiceHarness* harness : clients) { |
310 services.push_back(harness->service()); | 309 services.push_back(harness->service()); |
311 } | 310 } |
312 return QuiesceStatusChangeChecker(services).Wait(); | 311 return QuiesceStatusChangeChecker(services).Wait(); |
313 } | 312 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 | 543 |
545 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 544 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
546 std::unique_ptr<base::DictionaryValue> value( | 545 std::unique_ptr<base::DictionaryValue> value( |
547 syncer::sync_ui_util::ConstructAboutInformation( | 546 syncer::sync_ui_util::ConstructAboutInformation( |
548 service(), service()->signin(), chrome::GetChannel())); | 547 service(), service()->signin(), chrome::GetChannel())); |
549 std::string service_status; | 548 std::string service_status; |
550 base::JSONWriter::WriteWithOptions( | 549 base::JSONWriter::WriteWithOptions( |
551 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); | 550 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); |
552 return service_status; | 551 return service_status; |
553 } | 552 } |
OLD | NEW |