Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 1882243004: Convert //chrome/browser/sync from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
11 #include <memory>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
16 #include "base/guid.h" 17 #include "base/guid.h"
18 #include "base/memory/ptr_util.h"
17 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
20 #include "base/path_service.h" 21 #include "base/path_service.h"
21 #include "base/process/launch.h" 22 #include "base/process/launch.h"
22 #include "base/strings/string_split.h" 23 #include "base/strings/string_split.h"
23 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
26 #include "base/synchronization/waitable_event.h" 27 #include "base/synchronization/waitable_event.h"
27 #include "base/test/test_timeouts.h" 28 #include "base/test/test_timeouts.h"
28 #include "base/threading/platform_thread.h" 29 #include "base/threading/platform_thread.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 explicit EncryptionChecker(ProfileSyncService* service) 166 explicit EncryptionChecker(ProfileSyncService* service)
166 : SingleClientStatusChangeChecker(service) {} 167 : SingleClientStatusChangeChecker(service) {}
167 168
168 bool IsExitConditionSatisfied() override { 169 bool IsExitConditionSatisfied() override {
169 return IsEncryptionComplete(service()); 170 return IsEncryptionComplete(service());
170 } 171 }
171 172
172 std::string GetDebugMessage() const override { return "Encryption"; } 173 std::string GetDebugMessage() const override { return "Encryption"; }
173 }; 174 };
174 175
175 scoped_ptr<KeyedService> BuildFakeServerProfileInvalidationProvider( 176 std::unique_ptr<KeyedService> BuildFakeServerProfileInvalidationProvider(
176 content::BrowserContext* context) { 177 content::BrowserContext* context) {
177 return make_scoped_ptr(new invalidation::ProfileInvalidationProvider( 178 return base::WrapUnique(new invalidation::ProfileInvalidationProvider(
178 scoped_ptr<invalidation::InvalidationService>( 179 std::unique_ptr<invalidation::InvalidationService>(
179 new fake_server::FakeServerInvalidationService))); 180 new fake_server::FakeServerInvalidationService)));
180 } 181 }
181 182
182 scoped_ptr<KeyedService> BuildP2PProfileInvalidationProvider( 183 std::unique_ptr<KeyedService> BuildP2PProfileInvalidationProvider(
183 content::BrowserContext* context, 184 content::BrowserContext* context,
184 syncer::P2PNotificationTarget notification_target) { 185 syncer::P2PNotificationTarget notification_target) {
185 Profile* profile = static_cast<Profile*>(context); 186 Profile* profile = static_cast<Profile*>(context);
186 return make_scoped_ptr(new invalidation::ProfileInvalidationProvider( 187 return base::WrapUnique(new invalidation::ProfileInvalidationProvider(
187 scoped_ptr<invalidation::InvalidationService>( 188 std::unique_ptr<invalidation::InvalidationService>(
188 new invalidation::P2PInvalidationService( 189 new invalidation::P2PInvalidationService(
189 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( 190 std::unique_ptr<IdentityProvider>(new ProfileIdentityProvider(
190 SigninManagerFactory::GetForProfile(profile), 191 SigninManagerFactory::GetForProfile(profile),
191 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 192 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
192 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile( 193 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(
193 profile))), 194 profile))),
194 profile->GetRequestContext(), notification_target)))); 195 profile->GetRequestContext(), notification_target))));
195 } 196 }
196 197
197 scoped_ptr<KeyedService> BuildSelfNotifyingP2PProfileInvalidationProvider( 198 std::unique_ptr<KeyedService> BuildSelfNotifyingP2PProfileInvalidationProvider(
198 content::BrowserContext* context) { 199 content::BrowserContext* context) {
199 return BuildP2PProfileInvalidationProvider(context, syncer::NOTIFY_ALL); 200 return BuildP2PProfileInvalidationProvider(context, syncer::NOTIFY_ALL);
200 } 201 }
201 202
202 scoped_ptr<KeyedService> BuildRealisticP2PProfileInvalidationProvider( 203 std::unique_ptr<KeyedService> BuildRealisticP2PProfileInvalidationProvider(
203 content::BrowserContext* context) { 204 content::BrowserContext* context) {
204 return BuildP2PProfileInvalidationProvider(context, syncer::NOTIFY_OTHERS); 205 return BuildP2PProfileInvalidationProvider(context, syncer::NOTIFY_OTHERS);
205 } 206 }
206 207
207 } // namespace 208 } // namespace
208 209
209 SyncTest::SyncTest(TestType test_type) 210 SyncTest::SyncTest(TestType test_type)
210 : test_type_(test_type), 211 : test_type_(test_type),
211 server_type_(SERVER_TYPE_UNDECIDED), 212 server_type_(SERVER_TYPE_UNDECIDED),
212 num_clients_(-1), 213 num_clients_(-1),
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 531
531 // Make sure the ProfileSyncService has been created before creating the 532 // Make sure the ProfileSyncService has been created before creating the
532 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to 533 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to
533 // already exist. 534 // already exist.
534 ProfileSyncService* profile_sync_service = 535 ProfileSyncService* profile_sync_service =
535 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); 536 ProfileSyncServiceFactory::GetForProfile(GetProfile(index));
536 537
537 if (server_type_ == IN_PROCESS_FAKE_SERVER) { 538 if (server_type_ == IN_PROCESS_FAKE_SERVER) {
538 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. 539 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer.
539 profile_sync_service->OverrideNetworkResourcesForTest( 540 profile_sync_service->OverrideNetworkResourcesForTest(
540 make_scoped_ptr<syncer::NetworkResources>( 541 base::WrapUnique<syncer::NetworkResources>(
541 new fake_server::FakeServerNetworkResources( 542 new fake_server::FakeServerNetworkResources(
542 fake_server_->AsWeakPtr()))); 543 fake_server_->AsWeakPtr())));
543 } 544 }
544 545
545 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers() 546 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers()
546 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN 547 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN
547 : ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN; 548 : ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN;
548 549
549 clients_[index] = 550 clients_[index] =
550 ProfileSyncServiceHarness::Create(GetProfile(index), 551 ProfileSyncServiceHarness::Create(GetProfile(index),
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 base::PlatformThread::Sleep(wait / intervals); 966 base::PlatformThread::Sleep(wait / intervals);
966 } 967 }
967 return false; 968 return false;
968 } 969 }
969 970
970 bool SyncTest::IsTestServerRunning() { 971 bool SyncTest::IsTestServerRunning() {
971 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); 972 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
972 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL); 973 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL);
973 GURL sync_url_status(sync_url.append("/healthz")); 974 GURL sync_url_status(sync_url.append("/healthz"));
974 SyncServerStatusChecker delegate; 975 SyncServerStatusChecker delegate;
975 scoped_ptr<net::URLFetcher> fetcher = 976 std::unique_ptr<net::URLFetcher> fetcher =
976 net::URLFetcher::Create(sync_url_status, net::URLFetcher::GET, &delegate); 977 net::URLFetcher::Create(sync_url_status, net::URLFetcher::GET, &delegate);
977 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | 978 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE |
978 net::LOAD_DO_NOT_SEND_COOKIES | 979 net::LOAD_DO_NOT_SEND_COOKIES |
979 net::LOAD_DO_NOT_SAVE_COOKIES); 980 net::LOAD_DO_NOT_SAVE_COOKIES);
980 fetcher->SetRequestContext(g_browser_process->system_request_context()); 981 fetcher->SetRequestContext(g_browser_process->system_request_context());
981 fetcher->Start(); 982 fetcher->Start();
982 content::RunMessageLoop(); 983 content::RunMessageLoop();
983 return delegate.running(); 984 return delegate.running();
984 } 985 }
985 986
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 1129
1129 void SyncTest::TriggerSyncForModelTypes(int index, 1130 void SyncTest::TriggerSyncForModelTypes(int index,
1130 syncer::ModelTypeSet model_types) { 1131 syncer::ModelTypeSet model_types) {
1131 GetSyncService(index)->TriggerRefresh(model_types); 1132 GetSyncService(index)->TriggerRefresh(model_types);
1132 } 1133 }
1133 1134
1134 void SyncTest::SetPreexistingPreferencesFileContents( 1135 void SyncTest::SetPreexistingPreferencesFileContents(
1135 const std::string& contents) { 1136 const std::string& contents) {
1136 preexisting_preferences_file_contents_ = contents; 1137 preexisting_preferences_file_contents_ = contents;
1137 } 1138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698