OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h" | 5 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/time/time.h" | |
9 #include "components/browser_sync/browser/profile_sync_service_mock.h" | 8 #include "components/browser_sync/browser/profile_sync_service_mock.h" |
| 9 #include "components/browser_sync/browser/profile_sync_test_util.h" |
10 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 10 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
11 #include "components/signin/core/browser/signin_manager.h" | 11 #include "components/signin/core/browser/signin_manager.h" |
12 #include "components/sync_driver/signin_manager_wrapper.h" | 12 #include "components/sync_driver/signin_manager_wrapper.h" |
13 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h" | 13 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h" |
14 #include "ios/chrome/browser/signin/signin_manager_factory.h" | 14 #include "ios/chrome/browser/signin/signin_manager_factory.h" |
15 #include "ios/chrome/browser/sync/ios_chrome_sync_client.h" | 15 #include "ios/chrome/browser/sync/ios_chrome_sync_client.h" |
16 #include "ios/chrome/common/channel_info.h" | 16 #include "ios/chrome/common/channel_info.h" |
17 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" | 17 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" |
18 #include "ios/web/public/web_thread.h" | 18 #include "ios/web/public/web_thread.h" |
19 | 19 |
20 namespace { | |
21 | |
22 void EmptyNetworkTimeUpdate(const base::Time&, | |
23 const base::TimeDelta&, | |
24 const base::TimeDelta&) {} | |
25 | |
26 } // namespace | |
27 | |
28 ProfileSyncService::InitParams CreateProfileSyncServiceParamsForTest( | 20 ProfileSyncService::InitParams CreateProfileSyncServiceParamsForTest( |
29 scoped_ptr<sync_driver::SyncClient> sync_client, | 21 scoped_ptr<sync_driver::SyncClient> sync_client, |
30 ios::ChromeBrowserState* browser_state) { | 22 ios::ChromeBrowserState* browser_state) { |
31 ProfileSyncService::InitParams init_params; | 23 ProfileSyncService::InitParams init_params; |
32 | 24 |
33 init_params.signin_wrapper = make_scoped_ptr(new SigninManagerWrapper( | 25 init_params.signin_wrapper = make_scoped_ptr(new SigninManagerWrapper( |
34 ios::SigninManagerFactory::GetForBrowserState(browser_state))); | 26 ios::SigninManagerFactory::GetForBrowserState(browser_state))); |
35 init_params.oauth2_token_service = | 27 init_params.oauth2_token_service = |
36 OAuth2TokenServiceFactory::GetForBrowserState(browser_state); | 28 OAuth2TokenServiceFactory::GetForBrowserState(browser_state); |
37 init_params.start_behavior = browser_sync::MANUAL_START; | 29 init_params.start_behavior = browser_sync::MANUAL_START; |
38 init_params.sync_client = | 30 init_params.sync_client = |
39 sync_client ? std::move(sync_client) | 31 sync_client ? std::move(sync_client) |
40 : make_scoped_ptr(new IOSChromeSyncClient(browser_state)); | 32 : make_scoped_ptr(new IOSChromeSyncClient(browser_state)); |
41 init_params.network_time_update_callback = | 33 init_params.network_time_update_callback = |
42 base::Bind(&EmptyNetworkTimeUpdate); | 34 base::Bind(&browser_sync::EmptyNetworkTimeUpdate); |
43 init_params.base_directory = browser_state->GetStatePath(); | 35 init_params.base_directory = browser_state->GetStatePath(); |
44 init_params.url_request_context = browser_state->GetRequestContext(); | 36 init_params.url_request_context = browser_state->GetRequestContext(); |
45 init_params.debug_identifier = browser_state->GetDebugName(); | 37 init_params.debug_identifier = browser_state->GetDebugName(); |
46 init_params.channel = ::GetChannel(); | 38 init_params.channel = ::GetChannel(); |
47 init_params.db_thread = | 39 init_params.db_thread = |
48 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB); | 40 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB); |
49 init_params.file_thread = | 41 init_params.file_thread = |
50 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE); | 42 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE); |
51 init_params.blocking_pool = web::WebThread::GetBlockingPool(); | 43 init_params.blocking_pool = web::WebThread::GetBlockingPool(); |
52 | 44 |
53 return init_params; | 45 return init_params; |
54 } | 46 } |
55 | 47 |
56 scoped_ptr<KeyedService> BuildMockProfileSyncService( | 48 scoped_ptr<KeyedService> BuildMockProfileSyncService( |
57 web::BrowserState* context) { | 49 web::BrowserState* context) { |
58 return make_scoped_ptr( | 50 return make_scoped_ptr( |
59 new ProfileSyncServiceMock(CreateProfileSyncServiceParamsForTest( | 51 new ProfileSyncServiceMock(CreateProfileSyncServiceParamsForTest( |
60 nullptr, ios::ChromeBrowserState::FromBrowserState(context)))); | 52 nullptr, ios::ChromeBrowserState::FromBrowserState(context)))); |
61 } | 53 } |
OLD | NEW |