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

Side by Side Diff: chrome/browser/signin/easy_unlock_service_signin_chromeos.cc

Issue 1545223002: Switch to standard integer types in chrome/browser/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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 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 "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" 5 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h"
6 6
7 #include <stdint.h>
8
7 #include "base/base64url.h" 9 #include "base/base64url.h"
8 #include "base/basictypes.h"
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "base/sys_info.h" 15 #include "base/sys_info.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_challenge_wrappe r.h" 18 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_challenge_wrappe r.h"
18 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 19 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
19 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" 20 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
20 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h" 21 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
21 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 22 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
22 #include "chrome/browser/signin/easy_unlock_app_manager.h" 23 #include "chrome/browser/signin/easy_unlock_app_manager.h"
23 #include "chrome/browser/signin/easy_unlock_metrics.h" 24 #include "chrome/browser/signin/easy_unlock_metrics.h"
24 #include "chromeos/login/auth/user_context.h" 25 #include "chromeos/login/auth/user_context.h"
25 #include "chromeos/tpm/tpm_token_loader.h" 26 #include "chromeos/tpm/tpm_token_loader.h"
26 #include "components/proximity_auth/logging/logging.h" 27 #include "components/proximity_auth/logging/logging.h"
27 #include "components/proximity_auth/remote_device.h" 28 #include "components/proximity_auth/remote_device.h"
28 #include "components/proximity_auth/switches.h" 29 #include "components/proximity_auth/switches.h"
29 30
30 namespace { 31 namespace {
31 32
32 // The maximum allowed backoff interval when waiting for cryptohome to start. 33 // The maximum allowed backoff interval when waiting for cryptohome to start.
33 uint32 kMaxCryptohomeBackoffIntervalMs = 10000u; 34 uint32_t kMaxCryptohomeBackoffIntervalMs = 10000u;
34 35
35 // If the data load fails, the initial interval after which the load will be 36 // If the data load fails, the initial interval after which the load will be
36 // retried. Further intervals will exponentially increas by factor 2. 37 // retried. Further intervals will exponentially increas by factor 2.
37 uint32 kInitialCryptohomeBackoffIntervalMs = 200u; 38 uint32_t kInitialCryptohomeBackoffIntervalMs = 200u;
38 39
39 // Calculates the backoff interval that should be used next. 40 // Calculates the backoff interval that should be used next.
40 // |backoff| The last backoff interval used. 41 // |backoff| The last backoff interval used.
41 uint32 GetNextBackoffInterval(uint32 backoff) { 42 uint32_t GetNextBackoffInterval(uint32_t backoff) {
42 if (backoff == 0u) 43 if (backoff == 0u)
43 return kInitialCryptohomeBackoffIntervalMs; 44 return kInitialCryptohomeBackoffIntervalMs;
44 return backoff * 2; 45 return backoff * 2;
45 } 46 }
46 47
47 void LoadDataForUser( 48 void LoadDataForUser(
48 const AccountId& account_id, 49 const AccountId& account_id,
49 uint32 backoff_ms, 50 uint32_t backoff_ms,
50 const chromeos::EasyUnlockKeyManager::GetDeviceDataListCallback& callback); 51 const chromeos::EasyUnlockKeyManager::GetDeviceDataListCallback& callback);
51 52
52 // Callback passed to |LoadDataForUser()|. 53 // Callback passed to |LoadDataForUser()|.
53 // If |LoadDataForUser| function succeeded, it invokes |callback| with the 54 // If |LoadDataForUser| function succeeded, it invokes |callback| with the
54 // results. 55 // results.
55 // If |LoadDataForUser| failed and further retries are allowed, schedules new 56 // If |LoadDataForUser| failed and further retries are allowed, schedules new
56 // |LoadDataForUser| call with some backoff. If no further retires are allowed, 57 // |LoadDataForUser| call with some backoff. If no further retires are allowed,
57 // it invokes |callback| with the |LoadDataForUser| results. 58 // it invokes |callback| with the |LoadDataForUser| results.
58 void RetryDataLoadOnError( 59 void RetryDataLoadOnError(
59 const AccountId& account_id, 60 const AccountId& account_id,
60 uint32 backoff_ms, 61 uint32_t backoff_ms,
61 const chromeos::EasyUnlockKeyManager::GetDeviceDataListCallback& callback, 62 const chromeos::EasyUnlockKeyManager::GetDeviceDataListCallback& callback,
62 bool success, 63 bool success,
63 const chromeos::EasyUnlockDeviceKeyDataList& data_list) { 64 const chromeos::EasyUnlockDeviceKeyDataList& data_list) {
64 if (success) { 65 if (success) {
65 callback.Run(success, data_list); 66 callback.Run(success, data_list);
66 return; 67 return;
67 } 68 }
68 69
69 uint32 next_backoff_ms = GetNextBackoffInterval(backoff_ms); 70 uint32_t next_backoff_ms = GetNextBackoffInterval(backoff_ms);
70 if (next_backoff_ms > kMaxCryptohomeBackoffIntervalMs) { 71 if (next_backoff_ms > kMaxCryptohomeBackoffIntervalMs) {
71 callback.Run(false, data_list); 72 callback.Run(false, data_list);
72 return; 73 return;
73 } 74 }
74 75
75 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 76 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
76 FROM_HERE, 77 FROM_HERE,
77 base::Bind(&LoadDataForUser, account_id, next_backoff_ms, callback), 78 base::Bind(&LoadDataForUser, account_id, next_backoff_ms, callback),
78 base::TimeDelta::FromMilliseconds(next_backoff_ms)); 79 base::TimeDelta::FromMilliseconds(next_backoff_ms));
79 } 80 }
80 81
81 // Loads device data list associated with the user's Easy unlock keys. 82 // Loads device data list associated with the user's Easy unlock keys.
82 void LoadDataForUser( 83 void LoadDataForUser(
83 const AccountId& account_id, 84 const AccountId& account_id,
84 uint32 backoff_ms, 85 uint32_t backoff_ms,
85 const chromeos::EasyUnlockKeyManager::GetDeviceDataListCallback& callback) { 86 const chromeos::EasyUnlockKeyManager::GetDeviceDataListCallback& callback) {
86 chromeos::EasyUnlockKeyManager* key_manager = 87 chromeos::EasyUnlockKeyManager* key_manager =
87 chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); 88 chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager();
88 DCHECK(key_manager); 89 DCHECK(key_manager);
89 90
90 key_manager->GetDeviceDataList( 91 key_manager->GetDeviceDataList(
91 chromeos::UserContext(account_id), 92 chromeos::UserContext(account_id),
92 base::Bind(&RetryDataLoadOnError, account_id, backoff_ms, callback)); 93 base::Bind(&RetryDataLoadOnError, account_id, backoff_ms, callback));
93 } 94 }
94 95
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 198 }
198 199
199 EasyUnlockService::TurnOffFlowStatus 200 EasyUnlockService::TurnOffFlowStatus
200 EasyUnlockServiceSignin::GetTurnOffFlowStatus() const { 201 EasyUnlockServiceSignin::GetTurnOffFlowStatus() const {
201 return EasyUnlockService::IDLE; 202 return EasyUnlockService::IDLE;
202 } 203 }
203 204
204 std::string EasyUnlockServiceSignin::GetChallenge() const { 205 std::string EasyUnlockServiceSignin::GetChallenge() const {
205 const UserData* data = FindLoadedDataForCurrentUser(); 206 const UserData* data = FindLoadedDataForCurrentUser();
206 // TODO(xiyuan): Use correct remote device instead of hard coded first one. 207 // TODO(xiyuan): Use correct remote device instead of hard coded first one.
207 uint32 device_index = 0; 208 uint32_t device_index = 0;
208 if (!data || data->devices.size() <= device_index) 209 if (!data || data->devices.size() <= device_index)
209 return std::string(); 210 return std::string();
210 return data->devices[device_index].challenge; 211 return data->devices[device_index].challenge;
211 } 212 }
212 213
213 std::string EasyUnlockServiceSignin::GetWrappedSecret() const { 214 std::string EasyUnlockServiceSignin::GetWrappedSecret() const {
214 const UserData* data = FindLoadedDataForCurrentUser(); 215 const UserData* data = FindLoadedDataForCurrentUser();
215 // TODO(xiyuan): Use correct remote device instead of hard coded first one. 216 // TODO(xiyuan): Use correct remote device instead of hard coded first one.
216 uint32 device_index = 0; 217 uint32_t device_index = 0;
217 if (!data || data->devices.size() <= device_index) 218 if (!data || data->devices.size() <= device_index)
218 return std::string(); 219 return std::string();
219 return data->devices[device_index].wrapped_secret; 220 return data->devices[device_index].wrapped_secret;
220 } 221 }
221 222
222 void EasyUnlockServiceSignin::RecordEasySignInOutcome( 223 void EasyUnlockServiceSignin::RecordEasySignInOutcome(
223 const AccountId& account_id, 224 const AccountId& account_id,
224 bool success) const { 225 bool success) const {
225 DCHECK(GetAccountId() == account_id) 226 DCHECK(GetAccountId() == account_id)
226 << "GetAccountId()=" << GetAccountId().Serialize() 227 << "GetAccountId()=" << GetAccountId().Serialize()
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 if (account_id_.is_valid()) 470 if (account_id_.is_valid())
470 return nullptr; 471 return nullptr;
471 472
472 const auto it = user_data_.find(account_id_); 473 const auto it = user_data_.find(account_id_);
473 if (it == user_data_.end()) 474 if (it == user_data_.end())
474 return nullptr; 475 return nullptr;
475 if (it->second->state != USER_DATA_STATE_LOADED) 476 if (it->second->state != USER_DATA_STATE_LOADED)
476 return nullptr; 477 return nullptr;
477 return it->second; 478 return it->second;
478 } 479 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_regular.cc ('k') | chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698