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

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

Issue 2751333007: [Sync] Try to fix race conditions in CookieJarMismatch. (Closed)
Patch Set: Created 3 years, 9 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/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 sync_disabled_by_admin_ = false; 1996 sync_disabled_by_admin_ = false;
1997 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT, 1997 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT,
1998 syncer::STOP_SOURCE_LIMIT); 1998 syncer::STOP_SOURCE_LIMIT);
1999 RequestStop(CLEAR_DATA); 1999 RequestStop(CLEAR_DATA);
2000 } 2000 }
2001 2001
2002 void ProfileSyncService::OnGaiaAccountsInCookieUpdated( 2002 void ProfileSyncService::OnGaiaAccountsInCookieUpdated(
2003 const std::vector<gaia::ListedAccount>& accounts, 2003 const std::vector<gaia::ListedAccount>& accounts,
2004 const std::vector<gaia::ListedAccount>& signed_out_accounts, 2004 const std::vector<gaia::ListedAccount>& signed_out_accounts,
2005 const GoogleServiceAuthError& error) { 2005 const GoogleServiceAuthError& error) {
2006 OnGaiaAccountsInCookieUpdatedWithCallback(accounts, signed_out_accounts,
2007 error, base::Closure());
2008 }
2009
2010 void ProfileSyncService::OnGaiaAccountsInCookieUpdatedWithCallback(
2011 const std::vector<gaia::ListedAccount>& accounts,
2012 const std::vector<gaia::ListedAccount>& signed_out_accounts,
2013 const GoogleServiceAuthError& error,
2014 const base::Closure& callback) {
2006 DCHECK(thread_checker_.CalledOnValidThread()); 2015 DCHECK(thread_checker_.CalledOnValidThread());
2007 if (!IsEngineInitialized()) 2016 if (!IsEngineInitialized())
2008 return; 2017 return;
2009 2018
2010 bool cookie_jar_mismatch = true; 2019 bool cookie_jar_mismatch = true;
2011 bool cookie_jar_empty = accounts.size() == 0; 2020 bool cookie_jar_empty = accounts.size() == 0;
2012 std::string account_id = signin_->GetAccountIdToUse(); 2021 std::string account_id = signin_->GetAccountIdToUse();
2013 2022
2014 // Iterate through list of accounts, looking for current sync account. 2023 // Iterate through list of accounts, looking for current sync account.
2015 for (const auto& account : accounts) { 2024 for (const auto& account : accounts) {
2016 if (account.id == account_id) { 2025 if (account.id == account_id) {
2017 cookie_jar_mismatch = false; 2026 cookie_jar_mismatch = false;
2018 break; 2027 break;
2019 } 2028 }
2020 } 2029 }
2021 2030
2022 DVLOG(1) << "Cookie jar mismatch: " << cookie_jar_mismatch; 2031 DVLOG(1) << "Cookie jar mismatch: " << cookie_jar_mismatch;
2023 DVLOG(1) << "Cookie jar empty: " << cookie_jar_empty; 2032 DVLOG(1) << "Cookie jar empty: " << cookie_jar_empty;
2024 engine_->OnCookieJarChanged(cookie_jar_mismatch, cookie_jar_empty); 2033 engine_->OnCookieJarChanged(cookie_jar_mismatch, cookie_jar_empty, callback);
2025 } 2034 }
2026 2035
2027 void ProfileSyncService::AddProtocolEventObserver( 2036 void ProfileSyncService::AddProtocolEventObserver(
2028 ProtocolEventObserver* observer) { 2037 ProtocolEventObserver* observer) {
2029 DCHECK(thread_checker_.CalledOnValidThread()); 2038 DCHECK(thread_checker_.CalledOnValidThread());
2030 protocol_event_observers_.AddObserver(observer); 2039 protocol_event_observers_.AddObserver(observer);
2031 if (HasSyncingEngine()) { 2040 if (HasSyncingEngine()) {
2032 engine_->RequestBufferedProtocolEventsAndEnableForwarding(); 2041 engine_->RequestBufferedProtocolEventsAndEnableForwarding();
2033 } 2042 }
2034 } 2043 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 return; 2446 return;
2438 2447
2439 DCHECK(startup_controller_->IsSetupInProgress()); 2448 DCHECK(startup_controller_->IsSetupInProgress());
2440 startup_controller_->SetSetupInProgress(false); 2449 startup_controller_->SetSetupInProgress(false);
2441 2450
2442 if (IsEngineInitialized()) 2451 if (IsEngineInitialized())
2443 ReconfigureDatatypeManager(); 2452 ReconfigureDatatypeManager();
2444 NotifyObservers(); 2453 NotifyObservers();
2445 } 2454 }
2446 } // namespace browser_sync 2455 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698