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

Side by Side Diff: components/browser_sync/browser/profile_sync_service.cc

Issue 2172373002: [Sync] Don't start up sync when FirstSetupCompleted is false and no setup in progress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | components/browser_sync/browser/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/browser_sync/browser/profile_sync_service.h" 5 #include "components/browser_sync/browser/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 #if !defined(OS_ANDROID) 372 #if !defined(OS_ANDROID)
373 DCHECK(sync_error_controller_ == NULL) 373 DCHECK(sync_error_controller_ == NULL)
374 << "Initialize() called more than once."; 374 << "Initialize() called more than once.";
375 sync_error_controller_.reset(new SyncErrorController(this)); 375 sync_error_controller_.reset(new SyncErrorController(this));
376 AddObserver(sync_error_controller_.get()); 376 AddObserver(sync_error_controller_.get());
377 #endif 377 #endif
378 378
379 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind( 379 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind(
380 &ProfileSyncService::OnMemoryPressure, weak_factory_.GetWeakPtr()))); 380 &ProfileSyncService::OnMemoryPressure, weak_factory_.GetWeakPtr())));
381 startup_controller_->Reset(GetRegisteredDataTypes()); 381 startup_controller_->Reset(GetRegisteredDataTypes());
382 startup_controller_->TryStart(); 382
383 // Auto-start means means the first time the profile starts up, sync should
384 // start up immediately.
385 if (start_behavior_ == AUTO_START && IsSyncRequested() &&
386 !IsFirstSetupComplete()) {
387 startup_controller_->TryStartImmediately();
388 } else {
389 startup_controller_->TryStart();
390 }
383 } 391 }
384 392
385 void ProfileSyncService::TrySyncDatatypePrefRecovery() { 393 void ProfileSyncService::TrySyncDatatypePrefRecovery() {
386 DCHECK(!IsBackendInitialized()); 394 DCHECK(!IsBackendInitialized());
387 if (!IsFirstSetupComplete()) 395 if (!IsFirstSetupComplete())
388 return; 396 return;
389 397
390 // There was a bug where OnUserChoseDatatypes was not properly called on 398 // There was a bug where OnUserChoseDatatypes was not properly called on
391 // configuration (see crbug.com/154940). We detect this by checking whether 399 // configuration (see crbug.com/154940). We detect this by checking whether
392 // kSyncKeepEverythingSynced has a default value. If so, and sync setup has 400 // kSyncKeepEverythingSynced has a default value. If so, and sync setup has
(...skipping 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 return NULL; 2355 return NULL;
2348 return signin_->GetOriginal(); 2356 return signin_->GetOriginal();
2349 } 2357 }
2350 2358
2351 void ProfileSyncService::RequestStart() { 2359 void ProfileSyncService::RequestStart() {
2352 if (!IsSyncAllowed()) { 2360 if (!IsSyncAllowed()) {
2353 // Sync cannot be requested if it's not allowed. 2361 // Sync cannot be requested if it's not allowed.
2354 return; 2362 return;
2355 } 2363 }
2356 DCHECK(sync_client_); 2364 DCHECK(sync_client_);
2357 sync_prefs_.SetSyncRequested(true); 2365 if (!IsSyncRequested()) {
2358 DCHECK(!signin_.get() || signin_->GetOriginal()->IsAuthenticated()); 2366 sync_prefs_.SetSyncRequested(true);
2359 startup_controller_->TryStart(); 2367 NotifyObservers();
2368 }
2369 startup_controller_->TryStartImmediately();
2360 } 2370 }
2361 2371
2362 void ProfileSyncService::ReconfigureDatatypeManager() { 2372 void ProfileSyncService::ReconfigureDatatypeManager() {
2363 // If we haven't initialized yet, don't configure the DTM as it could cause 2373 // If we haven't initialized yet, don't configure the DTM as it could cause
2364 // association to start before a Directory has even been created. 2374 // association to start before a Directory has even been created.
2365 if (backend_initialized_) { 2375 if (backend_initialized_) {
2366 DCHECK(backend_.get()); 2376 DCHECK(backend_.get());
2367 ConfigureDataTypeManager(); 2377 ConfigureDataTypeManager();
2368 } else if (HasUnrecoverableError()) { 2378 } else if (HasUnrecoverableError()) {
2369 // There is nothing more to configure. So inform the listeners, 2379 // There is nothing more to configure. So inform the listeners,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 } 2542 }
2533 2543
2534 std::string ProfileSyncService::unrecoverable_error_message() const { 2544 std::string ProfileSyncService::unrecoverable_error_message() const {
2535 return unrecoverable_error_message_; 2545 return unrecoverable_error_message_;
2536 } 2546 }
2537 2547
2538 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2548 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2539 const { 2549 const {
2540 return unrecoverable_error_location_; 2550 return unrecoverable_error_location_;
2541 } 2551 }
OLDNEW
« no previous file with comments | « no previous file | components/browser_sync/browser/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698