OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/core/browser/account_reconcilor.h" | 5 #include "components/signin/core/browser/account_reconcilor.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 SigninClient* client) | 58 SigninClient* client) |
59 : token_service_(token_service), | 59 : token_service_(token_service), |
60 signin_manager_(signin_manager), | 60 signin_manager_(signin_manager), |
61 client_(client), | 61 client_(client), |
62 merge_session_helper_(token_service_, | 62 merge_session_helper_(token_service_, |
63 GaiaConstants::kReconcilorSource, | 63 GaiaConstants::kReconcilorSource, |
64 client->GetURLRequestContext(), | 64 client->GetURLRequestContext(), |
65 NULL), | 65 NULL), |
66 registered_with_token_service_(false), | 66 registered_with_token_service_(false), |
67 registered_with_merge_session_helper_(false), | 67 registered_with_merge_session_helper_(false), |
| 68 registered_with_content_settings_(false), |
68 is_reconcile_started_(false), | 69 is_reconcile_started_(false), |
69 first_execution_(true), | 70 first_execution_(true), |
70 are_gaia_accounts_set_(false), | 71 are_gaia_accounts_set_(false), |
71 chrome_accounts_changed_(false) { | 72 chrome_accounts_changed_(false) { |
72 VLOG(1) << "AccountReconcilor::AccountReconcilor"; | 73 VLOG(1) << "AccountReconcilor::AccountReconcilor"; |
73 } | 74 } |
74 | 75 |
75 AccountReconcilor::~AccountReconcilor() { | 76 AccountReconcilor::~AccountReconcilor() { |
76 VLOG(1) << "AccountReconcilor::~AccountReconcilor"; | 77 VLOG(1) << "AccountReconcilor::~AccountReconcilor"; |
77 // Make sure shutdown was called first. | 78 // Make sure shutdown was called first. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 138 |
138 void AccountReconcilor::RegisterWithSigninManager() { | 139 void AccountReconcilor::RegisterWithSigninManager() { |
139 signin_manager_->AddObserver(this); | 140 signin_manager_->AddObserver(this); |
140 } | 141 } |
141 | 142 |
142 void AccountReconcilor::UnregisterWithSigninManager() { | 143 void AccountReconcilor::UnregisterWithSigninManager() { |
143 signin_manager_->RemoveObserver(this); | 144 signin_manager_->RemoveObserver(this); |
144 } | 145 } |
145 | 146 |
146 void AccountReconcilor::RegisterWithContentSettings() { | 147 void AccountReconcilor::RegisterWithContentSettings() { |
| 148 VLOG(1) << "AccountReconcilor::RegisterWithContentSettings"; |
| 149 // During re-auth, the reconcilor will get a callback about successful signin |
| 150 // even when the profile is already connected. Avoid re-registering |
| 151 // with the token service since this will DCHECK. |
| 152 if (registered_with_content_settings_) |
| 153 return; |
| 154 |
147 client_->AddContentSettingsObserver(this); | 155 client_->AddContentSettingsObserver(this); |
| 156 registered_with_content_settings_ = true; |
148 } | 157 } |
149 | 158 |
150 void AccountReconcilor::UnregisterWithContentSettings() { | 159 void AccountReconcilor::UnregisterWithContentSettings() { |
| 160 VLOG(1) << "AccountReconcilor::UnregisterWithContentSettings"; |
| 161 if (!registered_with_content_settings_) |
| 162 return; |
| 163 |
151 client_->RemoveContentSettingsObserver(this); | 164 client_->RemoveContentSettingsObserver(this); |
| 165 registered_with_content_settings_ = false; |
152 } | 166 } |
153 | 167 |
154 void AccountReconcilor::RegisterWithTokenService() { | 168 void AccountReconcilor::RegisterWithTokenService() { |
155 VLOG(1) << "AccountReconcilor::RegisterWithTokenService"; | 169 VLOG(1) << "AccountReconcilor::RegisterWithTokenService"; |
156 // During re-auth, the reconcilor will get a callback about successful signin | 170 // During re-auth, the reconcilor will get a callback about successful signin |
157 // even when the profile is already connected. Avoid re-registering | 171 // even when the profile is already connected. Avoid re-registering |
158 // with the token service since this will DCHECK. | 172 // with the token service since this will DCHECK. |
159 if (registered_with_token_service_) | 173 if (registered_with_token_service_) |
160 return; | 174 return; |
161 | 175 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 556 |
543 void AccountReconcilor::GetCheckConnectionInfoCompleted(bool succeeded) { | 557 void AccountReconcilor::GetCheckConnectionInfoCompleted(bool succeeded) { |
544 base::TimeDelta time_to_check_connections = | 558 base::TimeDelta time_to_check_connections = |
545 base::Time::Now() - m_reconcile_start_time_; | 559 base::Time::Now() - m_reconcile_start_time_; |
546 signin_metrics::LogExternalCcResultFetches(succeeded, | 560 signin_metrics::LogExternalCcResultFetches(succeeded, |
547 time_to_check_connections); | 561 time_to_check_connections); |
548 GetAccountsFromCookie(base::Bind( | 562 GetAccountsFromCookie(base::Bind( |
549 &AccountReconcilor::ContinueReconcileActionAfterGetGaiaAccounts, | 563 &AccountReconcilor::ContinueReconcileActionAfterGetGaiaAccounts, |
550 base::Unretained(this))); | 564 base::Unretained(this))); |
551 } | 565 } |
OLD | NEW |