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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_client_registration_helper.cc

Issue 506633004: Remove implicit conversions from scoped_refptr to T* in components/policy/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some more changes Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/policy/core/common/cloud/cloud_policy_client_registration_h elper.h" 5 #include "components/policy/core/common/cloud/cloud_policy_client_registration_h elper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 #endif 150 #endif
151 151
152 CloudPolicyClientRegistrationHelper::CloudPolicyClientRegistrationHelper( 152 CloudPolicyClientRegistrationHelper::CloudPolicyClientRegistrationHelper(
153 CloudPolicyClient* client, 153 CloudPolicyClient* client,
154 enterprise_management::DeviceRegisterRequest::Type registration_type) 154 enterprise_management::DeviceRegisterRequest::Type registration_type)
155 : context_(client->GetRequestContext()), 155 : context_(client->GetRequestContext()),
156 client_(client), 156 client_(client),
157 registration_type_(registration_type) { 157 registration_type_(registration_type) {
158 DCHECK(context_); 158 DCHECK(context_.get());
159 DCHECK(client_); 159 DCHECK(client_);
160 } 160 }
161 161
162 CloudPolicyClientRegistrationHelper::~CloudPolicyClientRegistrationHelper() { 162 CloudPolicyClientRegistrationHelper::~CloudPolicyClientRegistrationHelper() {
163 // Clean up any pending observers in case the browser is shutdown while 163 // Clean up any pending observers in case the browser is shutdown while
164 // trying to register for policy. 164 // trying to register for policy.
165 if (client_) 165 if (client_)
166 client_->RemoveObserver(this); 166 client_->RemoveObserver(this);
167 } 167 }
168 168
(...skipping 21 matching lines...) Expand all
190 const base::Closure& callback) { 190 const base::Closure& callback) {
191 DVLOG(1) << "Starting registration process with login token"; 191 DVLOG(1) << "Starting registration process with login token";
192 DCHECK(!client_->is_registered()); 192 DCHECK(!client_->is_registered());
193 callback_ = callback; 193 callback_ = callback;
194 client_->AddObserver(this); 194 client_->AddObserver(this);
195 195
196 login_token_helper_.reset( 196 login_token_helper_.reset(
197 new CloudPolicyClientRegistrationHelper::LoginTokenHelper()); 197 new CloudPolicyClientRegistrationHelper::LoginTokenHelper());
198 login_token_helper_->FetchAccessToken( 198 login_token_helper_->FetchAccessToken(
199 login_refresh_token, 199 login_refresh_token,
200 context_, 200 context_.get(),
201 base::Bind(&CloudPolicyClientRegistrationHelper::OnTokenFetched, 201 base::Bind(&CloudPolicyClientRegistrationHelper::OnTokenFetched,
202 base::Unretained(this))); 202 base::Unretained(this)));
203 } 203 }
204 204
205 void CloudPolicyClientRegistrationHelper::StartRegistrationWithAccessToken( 205 void CloudPolicyClientRegistrationHelper::StartRegistrationWithAccessToken(
206 const std::string& access_token, 206 const std::string& access_token,
207 const base::Closure& callback) { 207 const base::Closure& callback) {
208 DCHECK(!client_->is_registered()); 208 DCHECK(!client_->is_registered());
209 callback_ = callback; 209 callback_ = callback;
210 client_->AddObserver(this); 210 client_->AddObserver(this);
(...skipping 22 matching lines...) Expand all
233 << GaiaConstants::kDeviceManagementServiceOAuth; 233 << GaiaConstants::kDeviceManagementServiceOAuth;
234 RequestCompleted(); 234 RequestCompleted();
235 return; 235 return;
236 } 236 }
237 237
238 // Cache the access token to be used after the GetUserInfo call. 238 // Cache the access token to be used after the GetUserInfo call.
239 oauth_access_token_ = access_token; 239 oauth_access_token_ = access_token;
240 DVLOG(1) << "Fetched new scoped OAuth token:" << oauth_access_token_; 240 DVLOG(1) << "Fetched new scoped OAuth token:" << oauth_access_token_;
241 // Now we've gotten our access token - contact GAIA to see if this is a 241 // Now we've gotten our access token - contact GAIA to see if this is a
242 // hosted domain. 242 // hosted domain.
243 user_info_fetcher_.reset(new UserInfoFetcher(this, context_)); 243 user_info_fetcher_.reset(new UserInfoFetcher(this, context_.get()));
244 user_info_fetcher_->Start(oauth_access_token_); 244 user_info_fetcher_->Start(oauth_access_token_);
245 } 245 }
246 246
247 void CloudPolicyClientRegistrationHelper::OnGetUserInfoFailure( 247 void CloudPolicyClientRegistrationHelper::OnGetUserInfoFailure(
248 const GoogleServiceAuthError& error) { 248 const GoogleServiceAuthError& error) {
249 DVLOG(1) << "Failed to fetch user info from GAIA: " << error.state(); 249 DVLOG(1) << "Failed to fetch user info from GAIA: " << error.state();
250 user_info_fetcher_.reset(); 250 user_info_fetcher_.reset();
251 RequestCompleted(); 251 RequestCompleted();
252 } 252 }
253 253
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void CloudPolicyClientRegistrationHelper::RequestCompleted() { 298 void CloudPolicyClientRegistrationHelper::RequestCompleted() {
299 if (client_) { 299 if (client_) {
300 client_->RemoveObserver(this); 300 client_->RemoveObserver(this);
301 // |client_| may be freed by the callback so clear it now. 301 // |client_| may be freed by the callback so clear it now.
302 client_ = NULL; 302 client_ = NULL;
303 callback_.Run(); 303 callback_.Run();
304 } 304 }
305 } 305 }
306 306
307 } // namespace policy 307 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698