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

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: Address comments. 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"
28 #include "chrome/browser/browsing_data/browsing_data_helper.h" 29 #include "chrome/browser/browsing_data/browsing_data_helper.h"
29 #include "chrome/browser/chrome_notification_types.h" 30 #include "chrome/browser/chrome_notification_types.h"
30 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 31 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
31 #include "chrome/browser/password_manager/password_store_factory.h" 32 #include "chrome/browser/password_manager/password_store_factory.h"
32 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/signin/about_signin_internals_factory.h" 34 #include "chrome/browser/signin/about_signin_internals_factory.h"
34 #include "chrome/browser/signin/chrome_signin_client_factory.h" 35 #include "chrome/browser/signin/chrome_signin_client_factory.h"
35 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 36 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
36 #include "chrome/browser/signin/signin_manager_factory.h" 37 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 error.action != syncer::DISABLE_SYNC_AND_ROLLBACK && 199 error.action != syncer::DISABLE_SYNC_AND_ROLLBACK &&
199 error.action != syncer::ROLLBACK_DONE && 200 error.action != syncer::ROLLBACK_DONE &&
200 error.action != syncer::RESET_LOCAL_SYNC_DATA); 201 error.action != syncer::RESET_LOCAL_SYNC_DATA);
201 } 202 }
202 203
203 ProfileSyncService::ProfileSyncService( 204 ProfileSyncService::ProfileSyncService(
204 scoped_ptr<sync_driver::SyncClient> sync_client, 205 scoped_ptr<sync_driver::SyncClient> sync_client,
205 Profile* profile, 206 Profile* profile,
206 scoped_ptr<SigninManagerWrapper> signin_wrapper, 207 scoped_ptr<SigninManagerWrapper> signin_wrapper,
207 ProfileOAuth2TokenService* oauth2_token_service, 208 ProfileOAuth2TokenService* oauth2_token_service,
208 ProfileSyncServiceStartBehavior start_behavior) 209 ProfileSyncServiceStartBehavior start_behavior,
210 const syncer::NetworkTimeUpdateCallback& network_time_update_callback)
209 : OAuth2TokenService::Consumer("sync"), 211 : OAuth2TokenService::Consumer("sync"),
210 last_auth_error_(AuthError::AuthErrorNone()), 212 last_auth_error_(AuthError::AuthErrorNone()),
211 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), 213 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED),
212 sync_client_(sync_client.Pass()), 214 sync_client_(sync_client.Pass()),
213 profile_(profile), 215 profile_(profile),
214 sync_prefs_(profile_->GetPrefs()), 216 sync_prefs_(profile_->GetPrefs()),
215 sync_service_url_( 217 sync_service_url_(
216 GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(), 218 GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(),
217 chrome::GetChannel())), 219 chrome::GetChannel())),
220 network_time_update_callback_(network_time_update_callback),
218 is_first_time_sync_configure_(false), 221 is_first_time_sync_configure_(false),
219 backend_initialized_(false), 222 backend_initialized_(false),
220 sync_disabled_by_admin_(false), 223 sync_disabled_by_admin_(false),
221 is_auth_in_progress_(false), 224 is_auth_in_progress_(false),
222 signin_(signin_wrapper.Pass()), 225 signin_(signin_wrapper.Pass()),
223 unrecoverable_error_reason_(ERROR_REASON_UNSET), 226 unrecoverable_error_reason_(ERROR_REASON_UNSET),
224 expect_sync_configuration_aborted_(false), 227 expect_sync_configuration_aborted_(false),
225 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), 228 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()),
226 encrypt_everything_allowed_(true), 229 encrypt_everything_allowed_(true),
227 encrypt_everything_(false), 230 encrypt_everything_(false),
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 523 }
521 524
522 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { 525 void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
523 if (!backend_) { 526 if (!backend_) {
524 NOTREACHED(); 527 NOTREACHED();
525 return; 528 return;
526 } 529 }
527 530
528 SyncCredentials credentials = GetCredentials(); 531 SyncCredentials credentials = GetCredentials();
529 532
530 scoped_refptr<net::URLRequestContextGetter> request_context_getter(
531 profile_->GetRequestContext());
532
533 if (backend_mode_ == SYNC && delete_stale_data) 533 if (backend_mode_ == SYNC && delete_stale_data)
534 ClearStaleErrors(); 534 ClearStaleErrors();
535 535
536 backend_->Initialize(this, sync_thread_.Pass(), 536 SyncBackendHost::HttpPostProviderFactoryGetter
537 content::BrowserThread::GetMessageLoopProxyForThread( 537 http_post_provider_factory_getter =
538 content::BrowserThread::DB), 538 base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory,
539 content::BrowserThread::GetMessageLoopProxyForThread( 539 base::Unretained(network_resources_.get()),
540 content::BrowserThread::FILE), 540 make_scoped_refptr(profile_->GetRequestContext()),
541 GetJsEventHandler(), sync_service_url_, 541 network_time_update_callback_);
542 local_device_->GetSyncUserAgent(), credentials, 542
543 delete_stale_data, 543 backend_->Initialize(
544 scoped_ptr<syncer::SyncManagerFactory>( 544 this, sync_thread_.Pass(),
545 new syncer::SyncManagerFactory(GetManagerType())) 545 content::BrowserThread::GetMessageLoopProxyForThread(
546 .Pass(), 546 content::BrowserThread::DB),
547 MakeWeakHandle(weak_factory_.GetWeakPtr()), 547 content::BrowserThread::GetMessageLoopProxyForThread(
548 base::Bind(browser_sync::ChromeReportUnrecoverableError, 548 content::BrowserThread::FILE),
549 chrome::GetChannel()), 549 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(),
550 network_resources_.get(), saved_nigori_state_.Pass()); 550 credentials, delete_stale_data,
551 scoped_ptr<syncer::SyncManagerFactory>(
552 new syncer::SyncManagerFactory(GetManagerType()))
553 .Pass(),
554 MakeWeakHandle(weak_factory_.GetWeakPtr()),
555 base::Bind(browser_sync::ChromeReportUnrecoverableError,
556 chrome::GetChannel()),
557 http_post_provider_factory_getter, saved_nigori_state_.Pass());
551 } 558 }
552 559
553 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { 560 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const {
554 if (encryption_pending()) 561 if (encryption_pending())
555 return true; 562 return true;
556 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); 563 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes();
557 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); 564 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes();
558 DCHECK(encrypted_types.Has(syncer::PASSWORDS)); 565 DCHECK(encrypted_types.Has(syncer::PASSWORDS));
559 return !Intersection(preferred_types, encrypted_types).Empty(); 566 return !Intersection(preferred_types, encrypted_types).Empty();
560 } 567 }
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 } 2745 }
2739 2746
2740 std::string ProfileSyncService::unrecoverable_error_message() const { 2747 std::string ProfileSyncService::unrecoverable_error_message() const {
2741 return unrecoverable_error_message_; 2748 return unrecoverable_error_message_;
2742 } 2749 }
2743 2750
2744 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2751 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2745 const { 2752 const {
2746 return unrecoverable_error_location_; 2753 return unrecoverable_error_location_;
2747 } 2754 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698