Chromium Code Reviews| 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 "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 <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 | 498 |
| 499 void ProfileSyncService::StartUp(StartUpDeferredOption deferred_option) { | 499 void ProfileSyncService::StartUp(StartUpDeferredOption deferred_option) { |
| 500 // Don't start up multiple times. | 500 // Don't start up multiple times. |
| 501 if (backend_) { | 501 if (backend_) { |
| 502 DVLOG(1) << "Skipping bringing up backend host."; | 502 DVLOG(1) << "Skipping bringing up backend host."; |
| 503 return; | 503 return; |
| 504 } | 504 } |
| 505 | 505 |
| 506 DCHECK(IsSyncEnabledAndLoggedIn()); | 506 DCHECK(IsSyncEnabledAndLoggedIn()); |
| 507 | 507 |
| 508 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); | 508 if (start_up_time_.is_null()) { |
|
haitaol1
2013/05/15 20:20:31
Do you have to put all the block in if? Is it ok t
tim (not reviewing)
2013/05/15 23:18:14
It is currently used to report the time spent defe
haitaol1
2013/05/16 00:05:57
Lock-free shutdown may be an issue in future becau
haitaol1
2013/05/16 00:06:59
Actually, that could happen today, right?
On 2013
tim (not reviewing)
2013/05/16 00:17:25
OnBackendInitialized should always be called if we
haitaol1
2013/05/16 16:17:33
SyncBackendHost::StopSyncingForShutdown nulls fron
| |
| 509 | 509 start_up_time_ = base::Time::Now(); |
| 510 DCHECK(start_up_time_.is_null()); | 510 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); |
| 511 start_up_time_ = base::Time::Now(); | |
| 512 | 511 |
| 513 #if defined(OS_CHROMEOS) | 512 #if defined(OS_CHROMEOS) |
| 514 std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken(); | 513 std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken(); |
| 515 if (bootstrap_token.empty()) { | 514 if (bootstrap_token.empty()) { |
| 516 sync_prefs_.SetEncryptionBootstrapToken( | 515 sync_prefs_.SetEncryptionBootstrapToken( |
| 517 sync_prefs_.GetSpareBootstrapToken()); | 516 sync_prefs_.GetSpareBootstrapToken()); |
| 518 } | 517 } |
| 519 #endif | 518 #endif |
| 520 | 519 |
| 521 if (!sync_global_error_) { | 520 if (!sync_global_error_) { |
| 522 #if !defined(OS_ANDROID) | 521 #if !defined(OS_ANDROID) |
| 523 sync_global_error_.reset(new SyncGlobalError(this, signin())); | 522 sync_global_error_.reset(new SyncGlobalError(this, signin())); |
| 524 #endif | 523 #endif |
| 525 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | 524 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( |
| 526 sync_global_error_.get()); | 525 sync_global_error_.get()); |
|
haitaol1
2013/05/16 00:05:57
sync_global_error_ is NULL if defined(OS_ANDROID).
tim (not reviewing)
2013/05/16 00:17:25
I believe so, because we don't have errors showing
| |
| 527 AddObserver(sync_global_error_.get()); | 526 AddObserver(sync_global_error_.get()); |
| 527 } | |
| 528 } else { | |
| 529 // We don't care to prevent multiple calls to StartUp in deferred mode | |
| 530 // because it's fast and has no side effects. | |
| 531 DCHECK_EQ(STARTUP_BACKEND_DEFERRED, deferred_option); | |
| 528 } | 532 } |
| 529 | 533 |
| 530 if (deferred_option == STARTUP_BACKEND_DEFERRED && | 534 if (deferred_option == STARTUP_BACKEND_DEFERRED && |
| 531 CommandLine::ForCurrentProcess()-> | 535 CommandLine::ForCurrentProcess()-> |
| 532 HasSwitch(switches::kSyncEnableDeferredStartup)) { | 536 HasSwitch(switches::kSyncEnableDeferredStartup)) { |
| 533 return; | 537 return; |
| 534 } | 538 } |
| 535 | 539 |
| 536 StartUpSlowBackendComponents(); | 540 StartUpSlowBackendComponents(); |
| 537 } | 541 } |
| (...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2099 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 2103 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
| 2100 ProfileSyncService* old_this = this; | 2104 ProfileSyncService* old_this = this; |
| 2101 this->~ProfileSyncService(); | 2105 this->~ProfileSyncService(); |
| 2102 new(old_this) ProfileSyncService( | 2106 new(old_this) ProfileSyncService( |
| 2103 new ProfileSyncComponentsFactoryImpl(profile, | 2107 new ProfileSyncComponentsFactoryImpl(profile, |
| 2104 CommandLine::ForCurrentProcess()), | 2108 CommandLine::ForCurrentProcess()), |
| 2105 profile, | 2109 profile, |
| 2106 signin, | 2110 signin, |
| 2107 behavior); | 2111 behavior); |
| 2108 } | 2112 } |
| OLD | NEW |