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/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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 DCHECK(sync_error_controller_ == NULL) | 374 DCHECK(sync_error_controller_ == NULL) |
375 << "Initialize() called more than once."; | 375 << "Initialize() called more than once."; |
376 sync_error_controller_.reset(new SyncErrorController(this)); | 376 sync_error_controller_.reset(new SyncErrorController(this)); |
377 AddObserver(sync_error_controller_.get()); | 377 AddObserver(sync_error_controller_.get()); |
378 #endif | 378 #endif |
379 | 379 |
380 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 380 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
381 base::Bind(&ProfileSyncService::OnMemoryPressure, | 381 base::Bind(&ProfileSyncService::OnMemoryPressure, |
382 sync_enabled_weak_factory_.GetWeakPtr()))); | 382 sync_enabled_weak_factory_.GetWeakPtr()))); |
383 startup_controller_->Reset(GetRegisteredDataTypes()); | 383 startup_controller_->Reset(GetRegisteredDataTypes()); |
384 startup_controller_->TryStart(); | 384 |
| 385 // Auto-start means means the first time the profile starts up, sync should |
| 386 // start up immediately. |
| 387 if (start_behavior_ == AUTO_START && IsSyncRequested() && |
| 388 !IsFirstSetupComplete()) { |
| 389 startup_controller_->TryStartImmediately(); |
| 390 } else { |
| 391 startup_controller_->TryStart(); |
| 392 } |
385 } | 393 } |
386 | 394 |
387 void ProfileSyncService::StartSyncingWithServer() { | 395 void ProfileSyncService::StartSyncingWithServer() { |
388 DCHECK(thread_checker_.CalledOnValidThread()); | 396 DCHECK(thread_checker_.CalledOnValidThread()); |
389 | 397 |
390 if (base::FeatureList::IsEnabled( | 398 if (base::FeatureList::IsEnabled( |
391 switches::kSyncClearDataOnPassphraseEncryption) && | 399 switches::kSyncClearDataOnPassphraseEncryption) && |
392 sync_prefs_.GetPassphraseEncryptionTransitionInProgress()) { | 400 sync_prefs_.GetPassphraseEncryptionTransitionInProgress()) { |
393 BeginConfigureCatchUpBeforeClear(); | 401 BeginConfigureCatchUpBeforeClear(); |
394 return; | 402 return; |
(...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 void ProfileSyncService::RequestStart() { | 2336 void ProfileSyncService::RequestStart() { |
2329 if (!IsSyncAllowed()) { | 2337 if (!IsSyncAllowed()) { |
2330 // Sync cannot be requested if it's not allowed. | 2338 // Sync cannot be requested if it's not allowed. |
2331 return; | 2339 return; |
2332 } | 2340 } |
2333 DCHECK(sync_client_); | 2341 DCHECK(sync_client_); |
2334 if (!IsSyncRequested()) { | 2342 if (!IsSyncRequested()) { |
2335 sync_prefs_.SetSyncRequested(true); | 2343 sync_prefs_.SetSyncRequested(true); |
2336 NotifyObservers(); | 2344 NotifyObservers(); |
2337 } | 2345 } |
2338 startup_controller_->TryStart(); | 2346 startup_controller_->TryStartImmediately(); |
2339 } | 2347 } |
2340 | 2348 |
2341 void ProfileSyncService::ReconfigureDatatypeManager() { | 2349 void ProfileSyncService::ReconfigureDatatypeManager() { |
2342 // If we haven't initialized yet, don't configure the DTM as it could cause | 2350 // If we haven't initialized yet, don't configure the DTM as it could cause |
2343 // association to start before a Directory has even been created. | 2351 // association to start before a Directory has even been created. |
2344 if (backend_initialized_) { | 2352 if (backend_initialized_) { |
2345 DCHECK(backend_.get()); | 2353 DCHECK(backend_.get()); |
2346 ConfigureDataTypeManager(); | 2354 ConfigureDataTypeManager(); |
2347 } else if (HasUnrecoverableError()) { | 2355 } else if (HasUnrecoverableError()) { |
2348 // There is nothing more to configure. So inform the listeners, | 2356 // There is nothing more to configure. So inform the listeners, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2526 if (--outstanding_setup_in_progress_handles_ != 0) | 2534 if (--outstanding_setup_in_progress_handles_ != 0) |
2527 return; | 2535 return; |
2528 | 2536 |
2529 DCHECK(startup_controller_->IsSetupInProgress()); | 2537 DCHECK(startup_controller_->IsSetupInProgress()); |
2530 startup_controller_->SetSetupInProgress(false); | 2538 startup_controller_->SetSetupInProgress(false); |
2531 | 2539 |
2532 if (IsBackendInitialized()) | 2540 if (IsBackendInitialized()) |
2533 ReconfigureDatatypeManager(); | 2541 ReconfigureDatatypeManager(); |
2534 NotifyObservers(); | 2542 NotifyObservers(); |
2535 } | 2543 } |
OLD | NEW |