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

Side by Side Diff: chrome/browser/sync/profile_sync_test_util.cc

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/profile_sync_test_util.h" 5 #include "chrome/browser/sync/profile_sync_test_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "chrome/browser/signin/signin_manager_factory.h" 13 #include "chrome/browser/signin/signin_manager_factory.h"
14 #include "chrome/browser/sync/chrome_sync_client.h" 14 #include "chrome/browser/sync/chrome_sync_client.h"
15 #include "chrome/common/channel_info.h" 15 #include "chrome/common/channel_info.h"
16 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "components/browser_sync/browser/profile_sync_service.h" 17 #include "components/browser_sync/browser/profile_sync_service.h"
18 #include "components/browser_sync/browser/profile_sync_test_util.h" 18 #include "components/browser_sync/browser/profile_sync_test_util.h"
19 #include "components/signin/core/browser/signin_manager.h" 19 #include "components/signin/core/browser/signin_manager.h"
20 #include "components/sync/driver/signin_manager_wrapper.h" 20 #include "components/sync/driver/signin_manager_wrapper.h"
21 #include "components/sync/driver/startup_controller.h" 21 #include "components/sync/driver/startup_controller.h"
22 #include "components/sync/driver/sync_api_component_factory_mock.h" 22 #include "components/sync/driver/sync_api_component_factory_mock.h"
23 23
24 ProfileSyncService::InitParams CreateProfileSyncServiceParamsForTest( 24 ProfileSyncService::InitParams CreateProfileSyncServiceParamsForTest(
25 Profile* profile) { 25 Profile* profile) {
26 auto sync_client = 26 auto sync_client = base::MakeUnique<browser_sync::ChromeSyncClient>(profile);
27 base::WrapUnique(new browser_sync::ChromeSyncClient(profile));
28 27
29 sync_client->SetSyncApiComponentFactoryForTesting( 28 sync_client->SetSyncApiComponentFactoryForTesting(
30 base::WrapUnique(new SyncApiComponentFactoryMock())); 29 base::MakeUnique<SyncApiComponentFactoryMock>());
31 30
32 ProfileSyncService::InitParams init_params = 31 ProfileSyncService::InitParams init_params =
33 CreateProfileSyncServiceParamsForTest(std::move(sync_client), profile); 32 CreateProfileSyncServiceParamsForTest(std::move(sync_client), profile);
34 33
35 return init_params; 34 return init_params;
36 } 35 }
37 36
38 ProfileSyncService::InitParams CreateProfileSyncServiceParamsForTest( 37 ProfileSyncService::InitParams CreateProfileSyncServiceParamsForTest(
39 std::unique_ptr<sync_driver::SyncClient> sync_client, 38 std::unique_ptr<sync_driver::SyncClient> sync_client,
40 Profile* profile) { 39 Profile* profile) {
41 ProfileSyncService::InitParams init_params; 40 ProfileSyncService::InitParams init_params;
42 41
43 init_params.signin_wrapper = base::WrapUnique( 42 init_params.signin_wrapper = base::MakeUnique<SigninManagerWrapper>(
44 new SigninManagerWrapper(SigninManagerFactory::GetForProfile(profile))); 43 SigninManagerFactory::GetForProfile(profile));
45 init_params.oauth2_token_service = 44 init_params.oauth2_token_service =
46 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 45 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
47 init_params.start_behavior = ProfileSyncService::MANUAL_START; 46 init_params.start_behavior = ProfileSyncService::MANUAL_START;
48 init_params.sync_client = std::move(sync_client); 47 init_params.sync_client = std::move(sync_client);
49 init_params.network_time_update_callback = 48 init_params.network_time_update_callback =
50 base::Bind(&browser_sync::EmptyNetworkTimeUpdate); 49 base::Bind(&browser_sync::EmptyNetworkTimeUpdate);
51 init_params.base_directory = profile->GetPath(); 50 init_params.base_directory = profile->GetPath();
52 init_params.url_request_context = profile->GetRequestContext(); 51 init_params.url_request_context = profile->GetRequestContext();
53 init_params.debug_identifier = profile->GetDebugName(); 52 init_params.debug_identifier = profile->GetDebugName();
54 init_params.channel = chrome::GetChannel(); 53 init_params.channel = chrome::GetChannel();
55 init_params.db_thread = content::BrowserThread::GetTaskRunnerForThread( 54 init_params.db_thread = content::BrowserThread::GetTaskRunnerForThread(
56 content::BrowserThread::DB); 55 content::BrowserThread::DB);
57 init_params.file_thread = content::BrowserThread::GetTaskRunnerForThread( 56 init_params.file_thread = content::BrowserThread::GetTaskRunnerForThread(
58 content::BrowserThread::FILE); 57 content::BrowserThread::FILE);
59 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); 58 init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
60 59
61 return init_params; 60 return init_params;
62 } 61 }
63 62
64 std::unique_ptr<TestingProfile> MakeSignedInTestingProfile() { 63 std::unique_ptr<TestingProfile> MakeSignedInTestingProfile() {
65 auto profile = base::WrapUnique(new TestingProfile()); 64 auto profile = base::MakeUnique<TestingProfile>();
66 SigninManagerFactory::GetForProfile(profile.get()) 65 SigninManagerFactory::GetForProfile(profile.get())
67 ->SetAuthenticatedAccountInfo("12345", "foo"); 66 ->SetAuthenticatedAccountInfo("12345", "foo");
68 return profile; 67 return profile;
69 } 68 }
70 69
71 std::unique_ptr<KeyedService> BuildMockProfileSyncService( 70 std::unique_ptr<KeyedService> BuildMockProfileSyncService(
72 content::BrowserContext* context) { 71 content::BrowserContext* context) {
73 return base::WrapUnique( 72 return base::MakeUnique<ProfileSyncServiceMock>(
74 new ProfileSyncServiceMock(CreateProfileSyncServiceParamsForTest( 73 CreateProfileSyncServiceParamsForTest(
75 Profile::FromBrowserContext(context)))); 74 Profile::FromBrowserContext(context)));
76 } 75 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_factory.cc ('k') | chrome/browser/sync/sync_error_notifier_ash_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698