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

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

Issue 1849563005: [Sync] Add cookie jar mismatch logging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add integration test Created 4 years, 8 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
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT && 173 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT &&
174 error.action != syncer::RESET_LOCAL_SYNC_DATA); 174 error.action != syncer::RESET_LOCAL_SYNC_DATA);
175 } 175 }
176 176
177 ProfileSyncService::InitParams::InitParams() = default; 177 ProfileSyncService::InitParams::InitParams() = default;
178 ProfileSyncService::InitParams::~InitParams() = default; 178 ProfileSyncService::InitParams::~InitParams() = default;
179 ProfileSyncService::InitParams::InitParams(InitParams&& other) // NOLINT 179 ProfileSyncService::InitParams::InitParams(InitParams&& other) // NOLINT
180 : sync_client(std::move(other.sync_client)), 180 : sync_client(std::move(other.sync_client)),
181 signin_wrapper(std::move(other.signin_wrapper)), 181 signin_wrapper(std::move(other.signin_wrapper)),
182 oauth2_token_service(other.oauth2_token_service), 182 oauth2_token_service(other.oauth2_token_service),
183 gaia_cookie_manager_service(other.gaia_cookie_manager_service),
183 start_behavior(other.start_behavior), 184 start_behavior(other.start_behavior),
184 network_time_update_callback( 185 network_time_update_callback(
185 std::move(other.network_time_update_callback)), 186 std::move(other.network_time_update_callback)),
186 base_directory(std::move(other.base_directory)), 187 base_directory(std::move(other.base_directory)),
187 url_request_context(std::move(other.url_request_context)), 188 url_request_context(std::move(other.url_request_context)),
188 debug_identifier(std::move(other.debug_identifier)), 189 debug_identifier(std::move(other.debug_identifier)),
189 channel(other.channel), 190 channel(other.channel),
190 db_thread(std::move(other.db_thread)), 191 db_thread(std::move(other.db_thread)),
191 file_thread(std::move(other.file_thread)), 192 file_thread(std::move(other.file_thread)),
192 blocking_pool(other.blocking_pool) {} 193 blocking_pool(other.blocking_pool) {}
(...skipping 25 matching lines...) Expand all
218 expect_sync_configuration_aborted_(false), 219 expect_sync_configuration_aborted_(false),
219 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), 220 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()),
220 encrypt_everything_allowed_(true), 221 encrypt_everything_allowed_(true),
221 encrypt_everything_(false), 222 encrypt_everything_(false),
222 encryption_pending_(false), 223 encryption_pending_(false),
223 configure_status_(DataTypeManager::UNKNOWN), 224 configure_status_(DataTypeManager::UNKNOWN),
224 oauth2_token_service_(init_params.oauth2_token_service), 225 oauth2_token_service_(init_params.oauth2_token_service),
225 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), 226 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
226 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), 227 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED),
227 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), 228 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()),
229 gaia_cookie_manager_service_(init_params.gaia_cookie_manager_service),
228 network_resources_(new syncer::HttpBridgeNetworkResources), 230 network_resources_(new syncer::HttpBridgeNetworkResources),
229 start_behavior_(init_params.start_behavior), 231 start_behavior_(init_params.start_behavior),
230 directory_path_( 232 directory_path_(
231 base_directory_.Append(base::FilePath(kSyncDataFolderName))), 233 base_directory_.Append(base::FilePath(kSyncDataFolderName))),
232 catch_up_configure_in_progress_(false), 234 catch_up_configure_in_progress_(false),
233 passphrase_prompt_triggered_by_version_(false), 235 passphrase_prompt_triggered_by_version_(false),
234 weak_factory_(this), 236 weak_factory_(this),
235 startup_controller_weak_factory_(this) { 237 startup_controller_weak_factory_(this) {
236 DCHECK(thread_checker_.CalledOnValidThread()); 238 DCHECK(thread_checker_.CalledOnValidThread());
237 DCHECK(sync_client_); 239 DCHECK(sync_client_);
238 std::string last_version = sync_prefs_.GetLastRunVersion(); 240 std::string last_version = sync_prefs_.GetLastRunVersion();
239 std::string current_version = PRODUCT_VERSION; 241 std::string current_version = PRODUCT_VERSION;
240 sync_prefs_.SetLastRunVersion(current_version); 242 sync_prefs_.SetLastRunVersion(current_version);
241 243
242 // Check for a major version change. Note that the versions have format 244 // Check for a major version change. Note that the versions have format
243 // MAJOR.MINOR.BUILD.PATCH. 245 // MAJOR.MINOR.BUILD.PATCH.
244 if (last_version.substr(0, last_version.find('.')) != 246 if (last_version.substr(0, last_version.find('.')) !=
245 current_version.substr(0, current_version.find('.'))) { 247 current_version.substr(0, current_version.find('.'))) {
246 passphrase_prompt_triggered_by_version_ = true; 248 passphrase_prompt_triggered_by_version_ = true;
247 } 249 }
248 } 250 }
249 251
250 ProfileSyncService::~ProfileSyncService() { 252 ProfileSyncService::~ProfileSyncService() {
253 gaia_cookie_manager_service_->RemoveObserver(this);
251 sync_prefs_.RemoveSyncPrefObserver(this); 254 sync_prefs_.RemoveSyncPrefObserver(this);
252 // Shutdown() should have been called before destruction. 255 // Shutdown() should have been called before destruction.
253 CHECK(!backend_initialized_); 256 CHECK(!backend_initialized_);
254 } 257 }
255 258
256 bool ProfileSyncService::CanSyncStart() const { 259 bool ProfileSyncService::CanSyncStart() const {
257 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn(); 260 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn();
258 } 261 }
259 262
260 void ProfileSyncService::Initialize() { 263 void ProfileSyncService::Initialize() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 device_info_sync_service_.reset( 305 device_info_sync_service_.reset(
303 new DeviceInfoSyncService(local_device_.get())); 306 new DeviceInfoSyncService(local_device_.get()));
304 } 307 }
305 308
306 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod 309 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
307 register_platform_types_callback = 310 register_platform_types_callback =
308 sync_client_->GetRegisterPlatformTypesCallback(); 311 sync_client_->GetRegisterPlatformTypesCallback();
309 sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes( 312 sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes(
310 this, register_platform_types_callback); 313 this, register_platform_types_callback);
311 314
315 gaia_cookie_manager_service_->AddObserver(this);
316
312 // We clear this here (vs Shutdown) because we want to remember that an error 317 // We clear this here (vs Shutdown) because we want to remember that an error
313 // happened on shutdown so we can display details (message, location) about it 318 // happened on shutdown so we can display details (message, location) about it
314 // in about:sync. 319 // in about:sync.
315 ClearStaleErrors(); 320 ClearStaleErrors();
316 321
317 sync_prefs_.AddSyncPrefObserver(this); 322 sync_prefs_.AddSyncPrefObserver(this);
318 323
319 SyncInitialState sync_state = CAN_START; 324 SyncInitialState sync_state = CAN_START;
320 if (!IsSignedIn()) { 325 if (!IsSignedIn()) {
321 sync_state = NOT_SIGNED_IN; 326 sync_state = NOT_SIGNED_IN;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 } 973 }
969 974
970 // Auto-start means IsFirstSetupComplete gets set automatically. 975 // Auto-start means IsFirstSetupComplete gets set automatically.
971 if (start_behavior_ == AUTO_START && !IsFirstSetupComplete()) { 976 if (start_behavior_ == AUTO_START && !IsFirstSetupComplete()) {
972 // This will trigger a configure if it completes setup. 977 // This will trigger a configure if it completes setup.
973 SetFirstSetupComplete(); 978 SetFirstSetupComplete();
974 } else if (CanConfigureDataTypes()) { 979 } else if (CanConfigureDataTypes()) {
975 ConfigureDataTypeManager(); 980 ConfigureDataTypeManager();
976 } 981 }
977 982
983 // Check for a cookie jar mismatch.
984 std::vector<gaia::ListedAccount> accounts;
985 GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
986 if (gaia_cookie_manager_service_->ListAccounts(&accounts)) {
987 OnGaiaAccountsInCookieUpdated(accounts, error);
988 }
989
978 NotifyObservers(); 990 NotifyObservers();
979 } 991 }
980 992
981 void ProfileSyncService::OnBackendInitialized( 993 void ProfileSyncService::OnBackendInitialized(
982 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 994 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
983 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 995 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
984 debug_info_listener, 996 debug_info_listener,
985 const std::string& cache_guid, 997 const std::string& cache_guid,
986 bool success) { 998 bool success) {
987 UpdateBackendInitUMA(success); 999 UpdateBackendInitUMA(success);
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 } 2099 }
2088 2100
2089 void ProfileSyncService::GoogleSignedOut(const std::string& account_id, 2101 void ProfileSyncService::GoogleSignedOut(const std::string& account_id,
2090 const std::string& username) { 2102 const std::string& username) {
2091 sync_disabled_by_admin_ = false; 2103 sync_disabled_by_admin_ = false;
2092 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT, 2104 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT,
2093 syncer::STOP_SOURCE_LIMIT); 2105 syncer::STOP_SOURCE_LIMIT);
2094 RequestStop(CLEAR_DATA); 2106 RequestStop(CLEAR_DATA);
2095 } 2107 }
2096 2108
2109 void ProfileSyncService::OnGaiaAccountsInCookieUpdated(
2110 const std::vector<gaia::ListedAccount>& accounts,
2111 const GoogleServiceAuthError& error) {
2112 if (!IsBackendInitialized())
2113 return;
2114
2115 bool cookie_mismatch = true;
2116 std::string account_id = signin_->GetAccountIdToUse();
2117
2118 // Iterate through list of accounts, looking for current sync account.
2119 for (auto& iter : accounts) {
maxbogue 2016/04/01 22:30:48 const auto& account? iter doesn't really make sens
Nicolas Zea 2016/04/04 19:57:31 Done.
2120 if (iter.gaia_id == account_id) {
2121 cookie_mismatch = false;
2122 break;
2123 }
2124 }
2125
2126 DVLOG(1) << "Cookie jar mismatch: " << cookie_mismatch;
2127 backend_->OnCookieJarChanged(cookie_mismatch);
2128 }
2129
2097 void ProfileSyncService::AddObserver( 2130 void ProfileSyncService::AddObserver(
2098 sync_driver::SyncServiceObserver* observer) { 2131 sync_driver::SyncServiceObserver* observer) {
2099 observers_.AddObserver(observer); 2132 observers_.AddObserver(observer);
2100 } 2133 }
2101 2134
2102 void ProfileSyncService::RemoveObserver( 2135 void ProfileSyncService::RemoveObserver(
2103 sync_driver::SyncServiceObserver* observer) { 2136 sync_driver::SyncServiceObserver* observer) {
2104 observers_.RemoveObserver(observer); 2137 observers_.RemoveObserver(observer);
2105 } 2138 }
2106 2139
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 } 2516 }
2484 2517
2485 std::string ProfileSyncService::unrecoverable_error_message() const { 2518 std::string ProfileSyncService::unrecoverable_error_message() const {
2486 return unrecoverable_error_message_; 2519 return unrecoverable_error_message_;
2487 } 2520 }
2488 2521
2489 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2522 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2490 const { 2523 const {
2491 return unrecoverable_error_location_; 2524 return unrecoverable_error_location_;
2492 } 2525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698