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

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: Fix tests again 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 if (gaia_cookie_manager_service_)
254 gaia_cookie_manager_service_->RemoveObserver(this);
251 sync_prefs_.RemoveSyncPrefObserver(this); 255 sync_prefs_.RemoveSyncPrefObserver(this);
252 // Shutdown() should have been called before destruction. 256 // Shutdown() should have been called before destruction.
253 CHECK(!backend_initialized_); 257 CHECK(!backend_initialized_);
254 } 258 }
255 259
256 bool ProfileSyncService::CanSyncStart() const { 260 bool ProfileSyncService::CanSyncStart() const {
257 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn(); 261 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn();
258 } 262 }
259 263
260 void ProfileSyncService::Initialize() { 264 void ProfileSyncService::Initialize() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 device_info_sync_service_.reset( 306 device_info_sync_service_.reset(
303 new DeviceInfoSyncService(local_device_.get())); 307 new DeviceInfoSyncService(local_device_.get()));
304 } 308 }
305 309
306 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod 310 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
307 register_platform_types_callback = 311 register_platform_types_callback =
308 sync_client_->GetRegisterPlatformTypesCallback(); 312 sync_client_->GetRegisterPlatformTypesCallback();
309 sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes( 313 sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes(
310 this, register_platform_types_callback); 314 this, register_platform_types_callback);
311 315
316 if (gaia_cookie_manager_service_)
317 gaia_cookie_manager_service_->AddObserver(this);
318
312 // We clear this here (vs Shutdown) because we want to remember that an error 319 // 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 320 // happened on shutdown so we can display details (message, location) about it
314 // in about:sync. 321 // in about:sync.
315 ClearStaleErrors(); 322 ClearStaleErrors();
316 323
317 sync_prefs_.AddSyncPrefObserver(this); 324 sync_prefs_.AddSyncPrefObserver(this);
318 325
319 SyncInitialState sync_state = CAN_START; 326 SyncInitialState sync_state = CAN_START;
320 if (!IsSignedIn()) { 327 if (!IsSignedIn()) {
321 sync_state = NOT_SIGNED_IN; 328 sync_state = NOT_SIGNED_IN;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 } 975 }
969 976
970 // Auto-start means IsFirstSetupComplete gets set automatically. 977 // Auto-start means IsFirstSetupComplete gets set automatically.
971 if (start_behavior_ == AUTO_START && !IsFirstSetupComplete()) { 978 if (start_behavior_ == AUTO_START && !IsFirstSetupComplete()) {
972 // This will trigger a configure if it completes setup. 979 // This will trigger a configure if it completes setup.
973 SetFirstSetupComplete(); 980 SetFirstSetupComplete();
974 } else if (CanConfigureDataTypes()) { 981 } else if (CanConfigureDataTypes()) {
975 ConfigureDataTypeManager(); 982 ConfigureDataTypeManager();
976 } 983 }
977 984
985 // Check for a cookie jar mismatch.
986 std::vector<gaia::ListedAccount> accounts;
987 GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
988 if (gaia_cookie_manager_service_ &&
989 gaia_cookie_manager_service_->ListAccounts(&accounts)) {
990 OnGaiaAccountsInCookieUpdated(accounts, error);
991 }
992
978 NotifyObservers(); 993 NotifyObservers();
979 } 994 }
980 995
981 void ProfileSyncService::OnBackendInitialized( 996 void ProfileSyncService::OnBackendInitialized(
982 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 997 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
983 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 998 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
984 debug_info_listener, 999 debug_info_listener,
985 const std::string& cache_guid, 1000 const std::string& cache_guid,
986 bool success) { 1001 bool success) {
987 UpdateBackendInitUMA(success); 1002 UpdateBackendInitUMA(success);
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 } 2102 }
2088 2103
2089 void ProfileSyncService::GoogleSignedOut(const std::string& account_id, 2104 void ProfileSyncService::GoogleSignedOut(const std::string& account_id,
2090 const std::string& username) { 2105 const std::string& username) {
2091 sync_disabled_by_admin_ = false; 2106 sync_disabled_by_admin_ = false;
2092 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT, 2107 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT,
2093 syncer::STOP_SOURCE_LIMIT); 2108 syncer::STOP_SOURCE_LIMIT);
2094 RequestStop(CLEAR_DATA); 2109 RequestStop(CLEAR_DATA);
2095 } 2110 }
2096 2111
2112 void ProfileSyncService::OnGaiaAccountsInCookieUpdated(
2113 const std::vector<gaia::ListedAccount>& accounts,
2114 const GoogleServiceAuthError& error) {
2115 if (!IsBackendInitialized())
2116 return;
2117
2118 bool cookie_mismatch = true;
2119 std::string account_id = signin_->GetAccountIdToUse();
2120
2121 // Iterate through list of accounts, looking for current sync account.
2122 for (const auto& account : accounts) {
2123 if (account.gaia_id == account_id) {
2124 cookie_mismatch = false;
2125 break;
2126 }
2127 }
2128
2129 DVLOG(1) << "Cookie jar mismatch: " << cookie_mismatch;
2130 backend_->OnCookieJarChanged(cookie_mismatch);
2131 }
2132
2097 void ProfileSyncService::AddObserver( 2133 void ProfileSyncService::AddObserver(
2098 sync_driver::SyncServiceObserver* observer) { 2134 sync_driver::SyncServiceObserver* observer) {
2099 observers_.AddObserver(observer); 2135 observers_.AddObserver(observer);
2100 } 2136 }
2101 2137
2102 void ProfileSyncService::RemoveObserver( 2138 void ProfileSyncService::RemoveObserver(
2103 sync_driver::SyncServiceObserver* observer) { 2139 sync_driver::SyncServiceObserver* observer) {
2104 observers_.RemoveObserver(observer); 2140 observers_.RemoveObserver(observer);
2105 } 2141 }
2106 2142
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 } 2519 }
2484 2520
2485 std::string ProfileSyncService::unrecoverable_error_message() const { 2521 std::string ProfileSyncService::unrecoverable_error_message() const {
2486 return unrecoverable_error_message_; 2522 return unrecoverable_error_message_;
2487 } 2523 }
2488 2524
2489 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2525 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2490 const { 2526 const {
2491 return unrecoverable_error_location_; 2527 return unrecoverable_error_location_;
2492 } 2528 }
OLDNEW
« no previous file with comments | « components/browser_sync/browser/profile_sync_service.h ('k') | components/sync_driver/glue/sync_backend_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698