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

Side by Side Diff: chrome/browser/cryptauth/chrome_cryptauth_service.cc

Issue 2911583003: ChromeCryptAuthService: only perform device sync once enrollment is complete. (Closed)
Patch Set: Fix comment. Created 3 years, 7 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
« no previous file with comments | « chrome/browser/cryptauth/chrome_cryptauth_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/cryptauth/chrome_cryptauth_service.h" 5 #include "chrome/browser/cryptauth/chrome_cryptauth_service.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "base/time/default_clock.h" 10 #include "base/time/default_clock.h"
11 #include "base/version.h" 11 #include "base/version.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_content_browser_client.h" 13 #include "chrome/browser/chrome_content_browser_client.h"
14 #include "chrome/browser/gcm/gcm_profile_service_factory.h" 14 #include "chrome/browser/gcm/gcm_profile_service_factory.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
17 #include "chrome/browser/signin/signin_manager_factory.h" 17 #include "chrome/browser/signin/signin_manager_factory.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "components/cryptauth/cryptauth_client.h" 19 #include "components/cryptauth/cryptauth_client.h"
20 #include "components/cryptauth/cryptauth_client_impl.h" 20 #include "components/cryptauth/cryptauth_client_impl.h"
21 #include "components/cryptauth/cryptauth_device_manager.h" 21 #include "components/cryptauth/cryptauth_device_manager.h"
22 #include "components/cryptauth/cryptauth_enroller.h" 22 #include "components/cryptauth/cryptauth_enroller.h"
23 #include "components/cryptauth/cryptauth_enroller_impl.h" 23 #include "components/cryptauth/cryptauth_enroller_impl.h"
24 #include "components/cryptauth/cryptauth_enrollment_manager.h"
25 #include "components/cryptauth/cryptauth_enrollment_utils.h" 24 #include "components/cryptauth/cryptauth_enrollment_utils.h"
26 #include "components/cryptauth/cryptauth_gcm_manager_impl.h" 25 #include "components/cryptauth/cryptauth_gcm_manager_impl.h"
27 #include "components/cryptauth/proto/cryptauth_api.pb.h" 26 #include "components/cryptauth/proto/cryptauth_api.pb.h"
28 #include "components/cryptauth/secure_message_delegate.h" 27 #include "components/cryptauth/secure_message_delegate.h"
29 #include "components/gcm_driver/gcm_profile_service.h" 28 #include "components/gcm_driver/gcm_profile_service.h"
30 #include "components/prefs/pref_service.h" 29 #include "components/prefs/pref_service.h"
31 #include "components/proximity_auth/logging/logging.h" 30 #include "components/proximity_auth/logging/logging.h"
32 #include "components/signin/core/browser/profile_oauth2_token_service.h" 31 #include "components/signin/core/browser/profile_oauth2_token_service.h"
33 #include "components/signin/core/browser/signin_manager.h" 32 #include "components/signin/core/browser/signin_manager.h"
34 #include "components/translate/core/browser/translate_download_manager.h" 33 #include "components/translate/core/browser/translate_download_manager.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 device_manager_(std::move(device_manager)), 218 device_manager_(std::move(device_manager)),
220 profile_(profile), 219 profile_(profile),
221 token_service_(token_service) { 220 token_service_(token_service) {
222 gcm_manager_->StartListening(); 221 gcm_manager_->StartListening();
223 222
224 if (!token_service_->RefreshTokenIsAvailable(GetAccountId())) { 223 if (!token_service_->RefreshTokenIsAvailable(GetAccountId())) {
225 PA_LOG(INFO) << "Refresh token not yet available; " 224 PA_LOG(INFO) << "Refresh token not yet available; "
226 << "waiting before starting CryptAuth managers."; 225 << "waiting before starting CryptAuth managers.";
227 token_service_->AddObserver(this); 226 token_service_->AddObserver(this);
228 } else { 227 } else {
229 enrollment_manager_->Start(); 228 PerformEnrollmentAndDeviceSync();
230 device_manager_->Start();
231 } 229 }
232 } 230 }
233 231
234 ChromeCryptAuthService::~ChromeCryptAuthService() {} 232 ChromeCryptAuthService::~ChromeCryptAuthService() {}
235 233
236 void ChromeCryptAuthService::Shutdown() { 234 void ChromeCryptAuthService::Shutdown() {
237 token_service_->RemoveObserver(this); 235 token_service_->RemoveObserver(this);
238 enrollment_manager_.reset(); 236 enrollment_manager_.reset();
239 device_manager_.reset(); 237 device_manager_.reset();
240 gcm_manager_.reset(); 238 gcm_manager_.reset();
(...skipping 20 matching lines...) Expand all
261 std::unique_ptr<cryptauth::SecureMessageDelegate> 259 std::unique_ptr<cryptauth::SecureMessageDelegate>
262 ChromeCryptAuthService::CreateSecureMessageDelegate() { 260 ChromeCryptAuthService::CreateSecureMessageDelegate() {
263 return CreateSecureMessageDelegateImpl(); 261 return CreateSecureMessageDelegateImpl();
264 } 262 }
265 263
266 std::unique_ptr<cryptauth::CryptAuthClientFactory> 264 std::unique_ptr<cryptauth::CryptAuthClientFactory>
267 ChromeCryptAuthService::CreateCryptAuthClientFactory() { 265 ChromeCryptAuthService::CreateCryptAuthClientFactory() {
268 return CreateCryptAuthClientFactoryImpl(profile_); 266 return CreateCryptAuthClientFactoryImpl(profile_);
269 } 267 }
270 268
269 void ChromeCryptAuthService::OnEnrollmentStarted() {}
270
271 void ChromeCryptAuthService::OnEnrollmentFinished(bool success) {
khorimoto 2017/05/30 21:38:18 If !success, the device manager won't actually wor
Tim Song 2017/05/31 00:04:21 The enrollment manager should have its own retry l
Ryan Hansberry 2017/05/31 17:08:09 Done.
272 device_manager_->Start();
273 enrollment_manager_->RemoveObserver(this);
274 }
275
271 void ChromeCryptAuthService::OnRefreshTokenAvailable( 276 void ChromeCryptAuthService::OnRefreshTokenAvailable(
272 const std::string& account_id) { 277 const std::string& account_id) {
278 PA_LOG(ERROR) << "ChromeCAS: OnRefreshTokenAvailable";
khorimoto 2017/05/30 21:38:18 Remove these logs.
Ryan Hansberry 2017/05/31 17:08:09 Oops, removed.
273 if (account_id == GetAccountId()) { 279 if (account_id == GetAccountId()) {
280 PA_LOG(ERROR) << "ChromeCAS: OnRefreshTokenAvailable starting managers";
274 token_service_->RemoveObserver(this); 281 token_service_->RemoveObserver(this);
275 enrollment_manager_->Start(); 282 PerformEnrollmentAndDeviceSync();
276 device_manager_->Start();
277 } 283 }
278 } 284 }
285
286 void ChromeCryptAuthService::PerformEnrollmentAndDeviceSync() {
287 // If enrollment is not valid, wait for the new enrollment attempt to finish
khorimoto 2017/05/30 21:38:18 nit: This comment should probably be moved to the
Ryan Hansberry 2017/05/31 17:08:09 Done.
288 // before starting CryptAuthDeviceManager. See OnEnrollmentFinished(),
289 if (enrollment_manager_->IsEnrollmentValid())
290 device_manager_->Start();
291 else
292 enrollment_manager_->AddObserver(this);
293
294 enrollment_manager_->Start();
khorimoto 2017/05/30 21:38:18 Do we still need to call Start() here if the enrol
Ryan Hansberry 2017/05/31 17:08:09 Yes, in order for EnrollmentManager to schedule it
khorimoto 2017/05/31 17:53:38 nit: Thanks for the explanation - please add a com
Ryan Hansberry 2017/05/31 18:14:32 Done.
295 }
OLDNEW
« no previous file with comments | « chrome/browser/cryptauth/chrome_cryptauth_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698