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

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

Issue 1410013008: [Sync] Remove some http-related chrome deps from SyncBackendHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary includes/forward decls. Created 5 years, 1 month 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/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/profiler/scoped_tracker.h" 21 #include "base/profiler/scoped_tracker.h"
22 #include "base/single_thread_task_runner.h" 22 #include "base/single_thread_task_runner.h"
23 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/thread_task_runner_handle.h" 25 #include "base/thread_task_runner_handle.h"
26 #include "base/threading/thread_restrictions.h" 26 #include "base/threading/thread_restrictions.h"
27 #include "base/time/time.h"
27 #include "build/build_config.h" 28 #include "build/build_config.h"
29 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/browsing_data/browsing_data_helper.h" 30 #include "chrome/browser/browsing_data/browsing_data_helper.h"
29 #include "chrome/browser/chrome_notification_types.h" 31 #include "chrome/browser/chrome_notification_types.h"
30 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 32 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
31 #include "chrome/browser/password_manager/password_store_factory.h" 33 #include "chrome/browser/password_manager/password_store_factory.h"
32 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/signin/about_signin_internals_factory.h" 35 #include "chrome/browser/signin/about_signin_internals_factory.h"
34 #include "chrome/browser/signin/chrome_signin_client_factory.h" 36 #include "chrome/browser/signin/chrome_signin_client_factory.h"
35 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 37 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
36 #include "chrome/browser/signin/signin_manager_factory.h" 38 #include "chrome/browser/signin/signin_manager_factory.h"
37 #include "chrome/browser/sync/glue/sync_backend_host.h" 39 #include "chrome/browser/sync/glue/sync_backend_host.h"
38 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" 40 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
39 #include "chrome/browser/sync/glue/sync_start_util.h" 41 #include "chrome/browser/sync/glue/sync_start_util.h"
40 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" 42 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h"
41 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" 43 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
42 #include "chrome/browser/sync/sync_type_preference_provider.h" 44 #include "chrome/browser/sync/sync_type_preference_provider.h"
43 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" 45 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h"
44 #include "chrome/common/channel_info.h" 46 #include "chrome/common/channel_info.h"
45 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
46 #include "chrome/common/pref_names.h" 48 #include "chrome/common/pref_names.h"
47 #include "chrome/grit/generated_resources.h" 49 #include "chrome/grit/generated_resources.h"
48 #include "components/autofill/core/common/autofill_pref_names.h" 50 #include "components/autofill/core/common/autofill_pref_names.h"
49 #include "components/history/core/browser/typed_url_data_type_controller.h" 51 #include "components/history/core/browser/typed_url_data_type_controller.h"
50 #include "components/invalidation/impl/profile_invalidation_provider.h" 52 #include "components/invalidation/impl/profile_invalidation_provider.h"
51 #include "components/invalidation/public/invalidation_service.h" 53 #include "components/invalidation/public/invalidation_service.h"
54 #include "components/network_time/network_time_tracker.h"
52 #include "components/password_manager/core/browser/password_store.h" 55 #include "components/password_manager/core/browser/password_store.h"
53 #include "components/pref_registry/pref_registry_syncable.h" 56 #include "components/pref_registry/pref_registry_syncable.h"
54 #include "components/signin/core/browser/about_signin_internals.h" 57 #include "components/signin/core/browser/about_signin_internals.h"
55 #include "components/signin/core/browser/profile_oauth2_token_service.h" 58 #include "components/signin/core/browser/profile_oauth2_token_service.h"
56 #include "components/signin/core/browser/signin_manager.h" 59 #include "components/signin/core/browser/signin_manager.h"
57 #include "components/signin/core/browser/signin_metrics.h" 60 #include "components/signin/core/browser/signin_metrics.h"
58 #include "components/sync_driver/backend_migrator.h" 61 #include "components/sync_driver/backend_migrator.h"
59 #include "components/sync_driver/change_processor.h" 62 #include "components/sync_driver/change_processor.h"
60 #include "components/sync_driver/data_type_controller.h" 63 #include "components/sync_driver/data_type_controller.h"
61 #include "components/sync_driver/device_info.h" 64 #include "components/sync_driver/device_info.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 184
182 // Perform the actual sync data folder deletion. 185 // Perform the actual sync data folder deletion.
183 // This should only be called on the sync thread. 186 // This should only be called on the sync thread.
184 void DeleteSyncDataFolder(const base::FilePath& directory_path) { 187 void DeleteSyncDataFolder(const base::FilePath& directory_path) {
185 if (base::DirectoryExists(directory_path)) { 188 if (base::DirectoryExists(directory_path)) {
186 if (!base::DeleteFile(directory_path, true)) 189 if (!base::DeleteFile(directory_path, true))
187 LOG(DFATAL) << "Could not delete the Sync Data folder."; 190 LOG(DFATAL) << "Could not delete the Sync Data folder.";
188 } 191 }
189 } 192 }
190 193
194 void UpdateNetworkTimeOnUIThread(base::Time network_time,
Nicolas Zea 2015/10/27 20:41:42 Were you planning to try to move this to the PSSFa
maxbogue 2015/10/27 23:53:08 Done.
195 base::TimeDelta resolution,
196 base::TimeDelta latency,
197 base::TimeTicks post_time) {
198 g_browser_process->network_time_tracker()->UpdateNetworkTime(
199 network_time, resolution, latency, post_time);
200 }
201
202 void UpdateNetworkTime(
203 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
204 const base::Time& network_time,
205 const base::TimeDelta& resolution,
206 const base::TimeDelta& latency) {
207 ui_thread->PostTask(FROM_HERE,
208 base::Bind(&UpdateNetworkTimeOnUIThread, network_time,
209 resolution, latency, base::TimeTicks::Now()));
210 }
211
191 } // anonymous namespace 212 } // anonymous namespace
192 213
193 bool ShouldShowActionOnUI( 214 bool ShouldShowActionOnUI(
194 const syncer::SyncProtocolError& error) { 215 const syncer::SyncProtocolError& error) {
195 return (error.action != syncer::UNKNOWN_ACTION && 216 return (error.action != syncer::UNKNOWN_ACTION &&
196 error.action != syncer::DISABLE_SYNC_ON_CLIENT && 217 error.action != syncer::DISABLE_SYNC_ON_CLIENT &&
197 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT && 218 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT &&
198 error.action != syncer::DISABLE_SYNC_AND_ROLLBACK && 219 error.action != syncer::DISABLE_SYNC_AND_ROLLBACK &&
199 error.action != syncer::ROLLBACK_DONE && 220 error.action != syncer::ROLLBACK_DONE &&
200 error.action != syncer::RESET_LOCAL_SYNC_DATA); 221 error.action != syncer::RESET_LOCAL_SYNC_DATA);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 541 }
521 542
522 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { 543 void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
523 if (!backend_) { 544 if (!backend_) {
524 NOTREACHED(); 545 NOTREACHED();
525 return; 546 return;
526 } 547 }
527 548
528 SyncCredentials credentials = GetCredentials(); 549 SyncCredentials credentials = GetCredentials();
529 550
530 scoped_refptr<net::URLRequestContextGetter> request_context_getter(
531 profile_->GetRequestContext());
532
533 if (backend_mode_ == SYNC && delete_stale_data) 551 if (backend_mode_ == SYNC && delete_stale_data)
534 ClearStaleErrors(); 552 ClearStaleErrors();
535 553
536 backend_->Initialize(this, sync_thread_.Pass(), 554 SyncBackendHost::HttpPostProviderFactoryGetter
537 content::BrowserThread::GetMessageLoopProxyForThread( 555 get_http_post_provider_factory = base::Bind(
538 content::BrowserThread::DB), 556 &syncer::NetworkResources::GetHttpPostProviderFactory,
539 content::BrowserThread::GetMessageLoopProxyForThread( 557 base::Unretained(network_resources_.get()),
540 content::BrowserThread::FILE), 558 make_scoped_refptr(profile_->GetRequestContext()),
541 GetJsEventHandler(), sync_service_url_, 559 base::Bind(&UpdateNetworkTime,
542 local_device_->GetSyncUserAgent(), credentials, 560 content::BrowserThread::GetMessageLoopProxyForThread(
543 delete_stale_data, 561 content::BrowserThread::UI)));
544 scoped_ptr<syncer::SyncManagerFactory>( 562
545 new syncer::SyncManagerFactory(GetManagerType())) 563 backend_->Initialize(
546 .Pass(), 564 this, sync_thread_.Pass(),
547 MakeWeakHandle(weak_factory_.GetWeakPtr()), 565 content::BrowserThread::GetMessageLoopProxyForThread(
548 base::Bind(browser_sync::ChromeReportUnrecoverableError, 566 content::BrowserThread::DB),
549 chrome::GetChannel()), 567 content::BrowserThread::GetMessageLoopProxyForThread(
550 network_resources_.get(), saved_nigori_state_.Pass()); 568 content::BrowserThread::FILE),
569 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(),
570 credentials, delete_stale_data,
571 scoped_ptr<syncer::SyncManagerFactory>(
572 new syncer::SyncManagerFactory(GetManagerType()))
573 .Pass(),
574 MakeWeakHandle(weak_factory_.GetWeakPtr()),
575 base::Bind(browser_sync::ChromeReportUnrecoverableError,
576 chrome::GetChannel()),
577 get_http_post_provider_factory, saved_nigori_state_.Pass());
551 } 578 }
552 579
553 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { 580 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const {
554 if (encryption_pending()) 581 if (encryption_pending())
555 return true; 582 return true;
556 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); 583 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes();
557 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); 584 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes();
558 DCHECK(encrypted_types.Has(syncer::PASSWORDS)); 585 DCHECK(encrypted_types.Has(syncer::PASSWORDS));
559 return !Intersection(preferred_types, encrypted_types).Empty(); 586 return !Intersection(preferred_types, encrypted_types).Empty();
560 } 587 }
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 } 2765 }
2739 2766
2740 std::string ProfileSyncService::unrecoverable_error_message() const { 2767 std::string ProfileSyncService::unrecoverable_error_message() const {
2741 return unrecoverable_error_message_; 2768 return unrecoverable_error_message_;
2742 } 2769 }
2743 2770
2744 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2771 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2745 const { 2772 const {
2746 return unrecoverable_error_location_; 2773 return unrecoverable_error_location_;
2747 } 2774 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698