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 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 invalidator_state_ : syncer::TRANSIENT_INVALIDATION_ERROR; | 2045 invalidator_state_ : syncer::TRANSIENT_INVALIDATION_ERROR; |
2046 DVLOG(1) << "New invalidator state: " | 2046 DVLOG(1) << "New invalidator state: " |
2047 << syncer::InvalidatorStateToString(invalidator_state_) | 2047 << syncer::InvalidatorStateToString(invalidator_state_) |
2048 << ", effective state: " | 2048 << ", effective state: " |
2049 << syncer::InvalidatorStateToString(effective_state); | 2049 << syncer::InvalidatorStateToString(effective_state); |
2050 invalidator_registrar_->UpdateInvalidatorState(effective_state); | 2050 invalidator_registrar_->UpdateInvalidatorState(effective_state); |
2051 } | 2051 } |
2052 | 2052 |
2053 void ProfileSyncService::ResetForTest() { | 2053 void ProfileSyncService::ResetForTest() { |
2054 Profile* profile = profile_; | 2054 Profile* profile = profile_; |
2055 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); | 2055 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
2056 ProfileSyncService::StartBehavior behavior = | 2056 ProfileSyncService::StartBehavior behavior = |
2057 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START | 2057 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START |
2058 : ProfileSyncService::MANUAL_START; | 2058 : ProfileSyncService::MANUAL_START; |
2059 | 2059 |
2060 // We call the destructor and placement new here because we want to explicitly | 2060 // We call the destructor and placement new here because we want to explicitly |
2061 // recreate a new ProfileSyncService instance at the same memory location as | 2061 // recreate a new ProfileSyncService instance at the same memory location as |
2062 // the old one. Doing so is fine because this code is run only from within | 2062 // the old one. Doing so is fine because this code is run only from within |
2063 // integration tests, and the message loop is not running at this point. | 2063 // integration tests, and the message loop is not running at this point. |
2064 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 2064 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
2065 ProfileSyncService* old_this = this; | 2065 ProfileSyncService* old_this = this; |
2066 this->~ProfileSyncService(); | 2066 this->~ProfileSyncService(); |
2067 new(old_this) ProfileSyncService( | 2067 new(old_this) ProfileSyncService( |
2068 new ProfileSyncComponentsFactoryImpl(profile, | 2068 new ProfileSyncComponentsFactoryImpl(profile, |
2069 CommandLine::ForCurrentProcess()), | 2069 CommandLine::ForCurrentProcess()), |
2070 profile, | 2070 profile, |
2071 signin, | 2071 signin, |
2072 behavior); | 2072 behavior); |
2073 } | 2073 } |
OLD | NEW |