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

Side by Side Diff: chrome/browser/chromeos/login/signin/token_handle_util.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/login/signin/token_handle_util.h" 5 #include "chrome/browser/chromeos/login/signin/token_handle_util.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" 10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return true; 53 return true;
54 std::string status(kDefaultHandleStatus); 54 std::string status(kDefaultHandleStatus);
55 dict->GetString(kTokenHandleStatusPref, &status); 55 dict->GetString(kTokenHandleStatusPref, &status);
56 return kHandleStatusInvalid == status; 56 return kHandleStatusInvalid == status;
57 } 57 }
58 58
59 void TokenHandleUtil::DeleteHandle(const AccountId& account_id) { 59 void TokenHandleUtil::DeleteHandle(const AccountId& account_id) {
60 const base::DictionaryValue* dict = nullptr; 60 const base::DictionaryValue* dict = nullptr;
61 if (!user_manager::known_user::FindPrefs(account_id, &dict)) 61 if (!user_manager::known_user::FindPrefs(account_id, &dict))
62 return; 62 return;
63 scoped_ptr<base::DictionaryValue> dict_copy(dict->DeepCopy()); 63 std::unique_ptr<base::DictionaryValue> dict_copy(dict->DeepCopy());
64 dict_copy->Remove(kTokenHandlePref, nullptr); 64 dict_copy->Remove(kTokenHandlePref, nullptr);
65 dict_copy->Remove(kTokenHandleStatusPref, nullptr); 65 dict_copy->Remove(kTokenHandleStatusPref, nullptr);
66 user_manager::known_user::UpdatePrefs(account_id, *dict_copy.get(), 66 user_manager::known_user::UpdatePrefs(account_id, *dict_copy.get(),
67 /* replace values */ true); 67 /* replace values */ true);
68 } 68 }
69 69
70 void TokenHandleUtil::MarkHandleInvalid(const AccountId& account_id) { 70 void TokenHandleUtil::MarkHandleInvalid(const AccountId& account_id) {
71 user_manager::known_user::SetStringPref(account_id, kTokenHandleStatusPref, 71 user_manager::known_user::SetStringPref(account_id, kTokenHandleStatusPref,
72 kHandleStatusInvalid); 72 kHandleStatusInvalid);
73 } 73 }
(...skipping 11 matching lines...) Expand all
85 return; 85 return;
86 } 86 }
87 87
88 if (!gaia_client_.get()) { 88 if (!gaia_client_.get()) {
89 auto request_context = 89 auto request_context =
90 chromeos::ProfileHelper::Get()->GetSigninProfile()->GetRequestContext(); 90 chromeos::ProfileHelper::Get()->GetSigninProfile()->GetRequestContext();
91 gaia_client_.reset(new gaia::GaiaOAuthClient(request_context)); 91 gaia_client_.reset(new gaia::GaiaOAuthClient(request_context));
92 } 92 }
93 93
94 validation_delegates_.set( 94 validation_delegates_.set(
95 token, scoped_ptr<TokenDelegate>(new TokenDelegate( 95 token, std::unique_ptr<TokenDelegate>(new TokenDelegate(
96 weak_factory_.GetWeakPtr(), account_id, token, callback))); 96 weak_factory_.GetWeakPtr(), account_id, token, callback)));
97 gaia_client_->GetTokenHandleInfo(token, kMaxRetries, 97 gaia_client_->GetTokenHandleInfo(token, kMaxRetries,
98 validation_delegates_.get(token)); 98 validation_delegates_.get(token));
99 } 99 }
100 100
101 void TokenHandleUtil::StoreTokenHandle(const AccountId& account_id, 101 void TokenHandleUtil::StoreTokenHandle(const AccountId& account_id,
102 const std::string& handle) { 102 const std::string& handle) {
103 user_manager::known_user::SetStringPref(account_id, kTokenHandlePref, handle); 103 user_manager::known_user::SetStringPref(account_id, kTokenHandlePref, handle);
104 user_manager::known_user::SetStringPref(account_id, kTokenHandleStatusPref, 104 user_manager::known_user::SetStringPref(account_id, kTokenHandleStatusPref,
105 kHandleStatusValid); 105 kHandleStatusValid);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (owner_) 137 if (owner_)
138 owner_->OnValidationComplete(token_); 138 owner_->OnValidationComplete(token_);
139 } 139 }
140 140
141 void TokenHandleUtil::TokenDelegate::OnNetworkError(int response_code) { 141 void TokenHandleUtil::TokenDelegate::OnNetworkError(int response_code) {
142 callback_.Run(account_id_, UNKNOWN); 142 callback_.Run(account_id_, UNKNOWN);
143 NotifyDone(); 143 NotifyDone();
144 } 144 }
145 145
146 void TokenHandleUtil::TokenDelegate::OnGetTokenInfoResponse( 146 void TokenHandleUtil::TokenDelegate::OnGetTokenInfoResponse(
147 scoped_ptr<base::DictionaryValue> token_info) { 147 std::unique_ptr<base::DictionaryValue> token_info) {
148 TokenHandleStatus outcome = UNKNOWN; 148 TokenHandleStatus outcome = UNKNOWN;
149 if (!token_info->HasKey("error")) { 149 if (!token_info->HasKey("error")) {
150 int expires_in = 0; 150 int expires_in = 0;
151 if (token_info->GetInteger("expires_in", &expires_in)) 151 if (token_info->GetInteger("expires_in", &expires_in))
152 outcome = (expires_in < 0) ? INVALID : VALID; 152 outcome = (expires_in < 0) ? INVALID : VALID;
153 } 153 }
154 154
155 const base::TimeDelta duration = 155 const base::TimeDelta duration =
156 base::TimeTicks::Now() - tokeninfo_response_start_time_; 156 base::TimeTicks::Now() - tokeninfo_response_start_time_;
157 UMA_HISTOGRAM_TIMES("Login.TokenCheckResponseTime", duration); 157 UMA_HISTOGRAM_TIMES("Login.TokenCheckResponseTime", duration);
158 callback_.Run(account_id_, outcome); 158 callback_.Run(account_id_, outcome);
159 NotifyDone(); 159 NotifyDone();
160 } 160 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/signin/token_handle_util.h ('k') | chrome/browser/chromeos/login/signin_screen_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698