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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 bool ShouldShowActionOnUI( | 125 bool ShouldShowActionOnUI( |
126 const syncer::SyncProtocolError& error) { | 126 const syncer::SyncProtocolError& error) { |
127 return (error.action != syncer::UNKNOWN_ACTION && | 127 return (error.action != syncer::UNKNOWN_ACTION && |
128 error.action != syncer::DISABLE_SYNC_ON_CLIENT); | 128 error.action != syncer::DISABLE_SYNC_ON_CLIENT); |
129 } | 129 } |
130 | 130 |
131 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, | 131 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, |
132 Profile* profile, | 132 Profile* profile, |
133 SigninManager* signin_manager, | 133 SigninManagerBase* signin_manager, |
134 StartBehavior start_behavior) | 134 StartBehavior start_behavior) |
135 : last_auth_error_(AuthError::AuthErrorNone()), | 135 : last_auth_error_(AuthError::AuthErrorNone()), |
136 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), | 136 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), |
137 factory_(factory), | 137 factory_(factory), |
138 profile_(profile), | 138 profile_(profile), |
139 // |profile| may be NULL in unit tests. | 139 // |profile| may be NULL in unit tests. |
140 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), | 140 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), |
141 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), | 141 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), |
142 sync_service_url_(kDevServerUrl), | 142 sync_service_url_(kDevServerUrl), |
143 is_first_time_sync_configure_(false), | 143 is_first_time_sync_configure_(false), |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 invalidator_state_ : syncer::TRANSIENT_INVALIDATION_ERROR; | 2007 invalidator_state_ : syncer::TRANSIENT_INVALIDATION_ERROR; |
2008 DVLOG(1) << "New invalidator state: " | 2008 DVLOG(1) << "New invalidator state: " |
2009 << syncer::InvalidatorStateToString(invalidator_state_) | 2009 << syncer::InvalidatorStateToString(invalidator_state_) |
2010 << ", effective state: " | 2010 << ", effective state: " |
2011 << syncer::InvalidatorStateToString(effective_state); | 2011 << syncer::InvalidatorStateToString(effective_state); |
2012 invalidator_registrar_->UpdateInvalidatorState(effective_state); | 2012 invalidator_registrar_->UpdateInvalidatorState(effective_state); |
2013 } | 2013 } |
2014 | 2014 |
2015 void ProfileSyncService::ResetForTest() { | 2015 void ProfileSyncService::ResetForTest() { |
2016 Profile* profile = profile_; | 2016 Profile* profile = profile_; |
2017 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); | 2017 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
2018 ProfileSyncService::StartBehavior behavior = | 2018 ProfileSyncService::StartBehavior behavior = |
2019 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START | 2019 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START |
2020 : ProfileSyncService::MANUAL_START; | 2020 : ProfileSyncService::MANUAL_START; |
2021 | 2021 |
2022 // We call the destructor and placement new here because we want to explicitly | 2022 // We call the destructor and placement new here because we want to explicitly |
2023 // recreate a new ProfileSyncService instance at the same memory location as | 2023 // recreate a new ProfileSyncService instance at the same memory location as |
2024 // the old one. Doing so is fine because this code is run only from within | 2024 // the old one. Doing so is fine because this code is run only from within |
2025 // integration tests, and the message loop is not running at this point. | 2025 // integration tests, and the message loop is not running at this point. |
2026 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 2026 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
2027 ProfileSyncService* old_this = this; | 2027 ProfileSyncService* old_this = this; |
2028 this->~ProfileSyncService(); | 2028 this->~ProfileSyncService(); |
2029 new(old_this) ProfileSyncService( | 2029 new(old_this) ProfileSyncService( |
2030 new ProfileSyncComponentsFactoryImpl(profile, | 2030 new ProfileSyncComponentsFactoryImpl(profile, |
2031 CommandLine::ForCurrentProcess()), | 2031 CommandLine::ForCurrentProcess()), |
2032 profile, | 2032 profile, |
2033 signin, | 2033 signin, |
2034 behavior); | 2034 behavior); |
2035 } | 2035 } |
OLD | NEW |