| 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 "google_apis/gaia/oauth2_token_service_request.h" | 5 #include "google_apis/gaia/oauth2_token_service_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 DCHECK(consumer_); | 213 DCHECK(consumer_); |
| 214 DCHECK(!account_id_.empty()); | 214 DCHECK(!account_id_.empty()); |
| 215 DCHECK(!scopes_.empty()); | 215 DCHECK(!scopes_.empty()); |
| 216 } | 216 } |
| 217 | 217 |
| 218 RequestCore::~RequestCore() { | 218 RequestCore::~RequestCore() { |
| 219 } | 219 } |
| 220 | 220 |
| 221 void RequestCore::StartOnTokenServiceThread() { | 221 void RequestCore::StartOnTokenServiceThread() { |
| 222 DCHECK(token_service_task_runner()->BelongsToCurrentThread()); | 222 DCHECK(token_service_task_runner()->BelongsToCurrentThread()); |
| 223 request_ = token_service()->StartRequest(account_id_, scopes_, this).Pass(); | 223 request_ = token_service()->StartRequest(account_id_, scopes_, this); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void RequestCore::StopOnTokenServiceThread() { | 226 void RequestCore::StopOnTokenServiceThread() { |
| 227 DCHECK(token_service_task_runner()->BelongsToCurrentThread()); | 227 DCHECK(token_service_task_runner()->BelongsToCurrentThread()); |
| 228 request_.reset(); | 228 request_.reset(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void RequestCore::OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 231 void RequestCore::OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 232 const std::string& access_token, | 232 const std::string& access_token, |
| 233 const base::Time& expiration_time) { | 233 const base::Time& expiration_time) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 scoped_ptr<OAuth2TokenServiceRequest> OAuth2TokenServiceRequest::CreateAndStart( | 329 scoped_ptr<OAuth2TokenServiceRequest> OAuth2TokenServiceRequest::CreateAndStart( |
| 330 const scoped_refptr<TokenServiceProvider>& provider, | 330 const scoped_refptr<TokenServiceProvider>& provider, |
| 331 const std::string& account_id, | 331 const std::string& account_id, |
| 332 const OAuth2TokenService::ScopeSet& scopes, | 332 const OAuth2TokenService::ScopeSet& scopes, |
| 333 OAuth2TokenService::Consumer* consumer) { | 333 OAuth2TokenService::Consumer* consumer) { |
| 334 scoped_ptr<OAuth2TokenServiceRequest> request( | 334 scoped_ptr<OAuth2TokenServiceRequest> request( |
| 335 new OAuth2TokenServiceRequest(account_id)); | 335 new OAuth2TokenServiceRequest(account_id)); |
| 336 scoped_refptr<Core> core( | 336 scoped_refptr<Core> core( |
| 337 new RequestCore(request.get(), provider, consumer, account_id, scopes)); | 337 new RequestCore(request.get(), provider, consumer, account_id, scopes)); |
| 338 request->StartWithCore(core); | 338 request->StartWithCore(core); |
| 339 return request.Pass(); | 339 return request; |
| 340 } | 340 } |
| 341 | 341 |
| 342 // static | 342 // static |
| 343 void OAuth2TokenServiceRequest::InvalidateToken( | 343 void OAuth2TokenServiceRequest::InvalidateToken( |
| 344 const scoped_refptr<TokenServiceProvider>& provider, | 344 const scoped_refptr<TokenServiceProvider>& provider, |
| 345 const std::string& account_id, | 345 const std::string& account_id, |
| 346 const OAuth2TokenService::ScopeSet& scopes, | 346 const OAuth2TokenService::ScopeSet& scopes, |
| 347 const std::string& access_token) { | 347 const std::string& access_token) { |
| 348 scoped_ptr<OAuth2TokenServiceRequest> request( | 348 scoped_ptr<OAuth2TokenServiceRequest> request( |
| 349 new OAuth2TokenServiceRequest(account_id)); | 349 new OAuth2TokenServiceRequest(account_id)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 364 const std::string& account_id) | 364 const std::string& account_id) |
| 365 : account_id_(account_id) { | 365 : account_id_(account_id) { |
| 366 DCHECK(!account_id_.empty()); | 366 DCHECK(!account_id_.empty()); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void OAuth2TokenServiceRequest::StartWithCore(const scoped_refptr<Core>& core) { | 369 void OAuth2TokenServiceRequest::StartWithCore(const scoped_refptr<Core>& core) { |
| 370 DCHECK(core.get()); | 370 DCHECK(core.get()); |
| 371 core_ = core; | 371 core_ = core; |
| 372 core_->Start(); | 372 core_->Start(); |
| 373 } | 373 } |
| OLD | NEW |