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 "components/browser_sync/profile_sync_components_factory_impl.h" | 5 #include "components/browser_sync/profile_sync_components_factory_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/debug/dump_without_crashing.h" | 9 #include "base/debug/dump_without_crashing.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "components/autofill/core/browser/autofill_wallet_data_type_controller.
h" | 15 #include "components/autofill/core/browser/autofill_wallet_data_type_controller.
h" |
16 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.h" | 16 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.h" |
17 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co
ntroller.h" | 17 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co
ntroller.h" |
18 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 18 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
19 #include "components/autofill/core/common/autofill_pref_names.h" | 19 #include "components/autofill/core/common/autofill_pref_names.h" |
20 #include "components/autofill/core/common/autofill_switches.h" | 20 #include "components/autofill/core/common/autofill_switches.h" |
21 #include "components/browser_sync/browser_sync_switches.h" | 21 #include "components/browser_sync/browser_sync_switches.h" |
22 #include "components/browser_sync/profile_sync_service.h" | 22 #include "components/browser_sync/profile_sync_service.h" |
23 #include "components/dom_distiller/core/dom_distiller_features.h" | 23 #include "components/dom_distiller/core/dom_distiller_features.h" |
24 #include "components/history/core/browser/history_delete_directives_data_type_co
ntroller.h" | 24 #include "components/history/core/browser/history_delete_directives_data_type_co
ntroller.h" |
25 #include "components/history/core/browser/typed_url_data_type_controller.h" | 25 #include "components/history/core/browser/typed_url_data_type_controller.h" |
26 #include "components/password_manager/core/browser/password_store.h" | 26 #include "components/password_manager/core/browser/password_store.h" |
27 #include "components/password_manager/sync/browser/password_data_type_controller
.h" | 27 #include "components/password_manager/sync/browser/password_data_type_controller
.h" |
28 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
| 29 #include "components/sync/api/attachments/attachment_service.h" |
29 #include "components/sync/base/report_unrecoverable_error.h" | 30 #include "components/sync/base/report_unrecoverable_error.h" |
30 #include "components/sync/core/attachments/attachment_downloader.h" | |
31 #include "components/sync/core/attachments/attachment_service.h" | |
32 #include "components/sync/core/attachments/attachment_service_impl.h" | |
33 #include "components/sync/core/attachments/attachment_uploader_impl.h" | |
34 #include "components/sync/device_info/device_info_data_type_controller.h" | 31 #include "components/sync/device_info/device_info_data_type_controller.h" |
35 #include "components/sync/device_info/local_device_info_provider_impl.h" | 32 #include "components/sync/device_info/local_device_info_provider_impl.h" |
36 #include "components/sync/driver/data_type_manager_impl.h" | 33 #include "components/sync/driver/data_type_manager_impl.h" |
37 #include "components/sync/driver/glue/sync_backend_host.h" | 34 #include "components/sync/driver/glue/sync_backend_host.h" |
38 #include "components/sync/driver/glue/sync_backend_host_impl.h" | 35 #include "components/sync/driver/glue/sync_backend_host_impl.h" |
39 #include "components/sync/driver/model_type_controller.h" | 36 #include "components/sync/driver/model_type_controller.h" |
40 #include "components/sync/driver/proxy_data_type_controller.h" | 37 #include "components/sync/driver/proxy_data_type_controller.h" |
41 #include "components/sync/driver/sync_client.h" | 38 #include "components/sync/driver/sync_client.h" |
42 #include "components/sync/driver/sync_driver_switches.h" | 39 #include "components/sync/driver/sync_driver_switches.h" |
43 #include "components/sync/driver/ui_data_type_controller.h" | 40 #include "components/sync/driver/ui_data_type_controller.h" |
| 41 #include "components/sync/engine/attachments/attachment_downloader.h" |
| 42 #include "components/sync/engine/attachments/attachment_uploader.h" |
44 #include "components/sync_bookmarks/bookmark_change_processor.h" | 43 #include "components/sync_bookmarks/bookmark_change_processor.h" |
45 #include "components/sync_bookmarks/bookmark_data_type_controller.h" | 44 #include "components/sync_bookmarks/bookmark_data_type_controller.h" |
46 #include "components/sync_bookmarks/bookmark_model_associator.h" | 45 #include "components/sync_bookmarks/bookmark_model_associator.h" |
47 #include "components/sync_sessions/session_data_type_controller.h" | 46 #include "components/sync_sessions/session_data_type_controller.h" |
48 #include "google_apis/gaia/oauth2_token_service.h" | 47 #include "google_apis/gaia/oauth2_token_service.h" |
49 #include "google_apis/gaia/oauth2_token_service_request.h" | 48 #include "google_apis/gaia/oauth2_token_service_request.h" |
50 #include "net/url_request/url_request_context_getter.h" | 49 #include "net/url_request/url_request_context_getter.h" |
51 | 50 |
52 using bookmarks::BookmarkModel; | 51 using bookmarks::BookmarkModel; |
53 using sync_bookmarks::BookmarkChangeProcessor; | 52 using sync_bookmarks::BookmarkChangeProcessor; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // credentials. We may not have sync credentials because there may not be a | 359 // credentials. We may not have sync credentials because there may not be a |
361 // signed in sync user. | 360 // signed in sync user. |
362 if (!user_share.sync_credentials.account_id.empty() && | 361 if (!user_share.sync_credentials.account_id.empty() && |
363 !user_share.sync_credentials.scope_set.empty()) { | 362 !user_share.sync_credentials.scope_set.empty()) { |
364 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> | 363 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> |
365 token_service_provider( | 364 token_service_provider( |
366 new TokenServiceProvider(ui_thread_, token_service_)); | 365 new TokenServiceProvider(ui_thread_, token_service_)); |
367 // TODO(maniscalco): Use shared (one per profile) thread-safe instances of | 366 // TODO(maniscalco): Use shared (one per profile) thread-safe instances of |
368 // AttachmentUploader and AttachmentDownloader instead of creating a new one | 367 // AttachmentUploader and AttachmentDownloader instead of creating a new one |
369 // per AttachmentService (bug 369536). | 368 // per AttachmentService (bug 369536). |
370 attachment_uploader.reset(new syncer::AttachmentUploaderImpl( | 369 attachment_uploader = syncer::AttachmentUploader::Create( |
371 sync_service_url_, url_request_context_getter_, | 370 sync_service_url_, url_request_context_getter_, |
372 user_share.sync_credentials.account_id, | 371 user_share.sync_credentials.account_id, |
373 user_share.sync_credentials.scope_set, token_service_provider, | 372 user_share.sync_credentials.scope_set, token_service_provider, |
374 store_birthday, model_type)); | 373 store_birthday, model_type); |
375 | 374 |
376 token_service_provider = | 375 token_service_provider = |
377 new TokenServiceProvider(ui_thread_, token_service_); | 376 new TokenServiceProvider(ui_thread_, token_service_); |
378 attachment_downloader = syncer::AttachmentDownloader::Create( | 377 attachment_downloader = syncer::AttachmentDownloader::Create( |
379 sync_service_url_, url_request_context_getter_, | 378 sync_service_url_, url_request_context_getter_, |
380 user_share.sync_credentials.account_id, | 379 user_share.sync_credentials.account_id, |
381 user_share.sync_credentials.scope_set, token_service_provider, | 380 user_share.sync_credentials.scope_set, token_service_provider, |
382 store_birthday, model_type); | 381 store_birthday, model_type); |
383 } | 382 } |
384 | 383 |
385 // It is important that the initial backoff delay is relatively large. For | 384 // It is important that the initial backoff delay is relatively large. For |
386 // whatever reason, the server may fail all requests for a short period of | 385 // whatever reason, the server may fail all requests for a short period of |
387 // time. When this happens we don't want to overwhelm the server with | 386 // time. When this happens we don't want to overwhelm the server with |
388 // requests so we use a large initial backoff. | 387 // requests so we use a large initial backoff. |
389 const base::TimeDelta initial_backoff_delay = | 388 const base::TimeDelta initial_backoff_delay = |
390 base::TimeDelta::FromMinutes(30); | 389 base::TimeDelta::FromMinutes(30); |
391 const base::TimeDelta max_backoff_delay = base::TimeDelta::FromHours(4); | 390 const base::TimeDelta max_backoff_delay = base::TimeDelta::FromHours(4); |
392 std::unique_ptr<syncer::AttachmentService> attachment_service( | 391 return syncer::AttachmentService::Create( |
393 new syncer::AttachmentServiceImpl( | 392 std::move(attachment_store), std::move(attachment_uploader), |
394 std::move(attachment_store), std::move(attachment_uploader), | 393 std::move(attachment_downloader), delegate, initial_backoff_delay, |
395 std::move(attachment_downloader), delegate, initial_backoff_delay, | 394 max_backoff_delay); |
396 max_backoff_delay)); | |
397 return attachment_service; | |
398 } | 395 } |
399 | 396 |
400 syncer::SyncApiComponentFactory::SyncComponents | 397 syncer::SyncApiComponentFactory::SyncComponents |
401 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents( | 398 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents( |
402 syncer::SyncService* sync_service, | 399 syncer::SyncService* sync_service, |
403 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) { | 400 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) { |
404 BookmarkModel* bookmark_model = | 401 BookmarkModel* bookmark_model = |
405 sync_service->GetSyncClient()->GetBookmarkModel(); | 402 sync_service->GetSyncClient()->GetBookmarkModel(); |
406 syncer::UserShare* user_share = sync_service->GetUserShare(); | 403 syncer::UserShare* user_share = sync_service->GetUserShare(); |
407 // TODO(akalin): We may want to propagate this switch up eventually. | 404 // TODO(akalin): We may want to propagate this switch up eventually. |
(...skipping 13 matching lines...) Expand all Loading... |
421 | 418 |
422 // static | 419 // static |
423 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) { | 420 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) { |
424 override_prefs_controller_to_uss_for_test_ = use_uss; | 421 override_prefs_controller_to_uss_for_test_ = use_uss; |
425 } | 422 } |
426 | 423 |
427 bool ProfileSyncComponentsFactoryImpl:: | 424 bool ProfileSyncComponentsFactoryImpl:: |
428 override_prefs_controller_to_uss_for_test_ = false; | 425 override_prefs_controller_to_uss_for_test_ = false; |
429 | 426 |
430 } // namespace browser_sync | 427 } // namespace browser_sync |
OLD | NEW |