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

Side by Side Diff: google_apis/gaia/oauth2_token_service.cc

Issue 182573003: Extract OAuth2AccessTokenFetcher interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing file. Created 6 years, 9 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 | Annotate | Revision Log
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 "google_apis/gaia/oauth2_token_service.h" 5 #include "google_apis/gaia/oauth2_token_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "google_apis/gaia/gaia_urls.h" 16 #include "google_apis/gaia/gaia_urls.h"
17 #include "google_apis/gaia/google_service_auth_error.h" 17 #include "google_apis/gaia/google_service_auth_error.h"
18 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
18 #include "net/url_request/url_request_context_getter.h" 19 #include "net/url_request/url_request_context_getter.h"
19 20
20 int OAuth2TokenService::max_fetch_retry_num_ = 5; 21 int OAuth2TokenService::max_fetch_retry_num_ = 5;
21 22
22 OAuth2TokenService::RequestParameters::RequestParameters( 23 OAuth2TokenService::RequestParameters::RequestParameters(
23 const std::string& client_id, 24 const std::string& client_id,
24 const std::string& account_id, 25 const std::string& account_id,
25 const ScopeSet& scopes) 26 const ScopeSet& scopes)
26 : client_id(client_id), 27 : client_id(client_id),
27 account_id(account_id), 28 account_id(account_id),
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 waiting_requests_.push_back(waiting_request); 240 waiting_requests_.push_back(waiting_request);
240 } 241 }
241 242
242 OAuth2TokenService::Fetcher::~Fetcher() { 243 OAuth2TokenService::Fetcher::~Fetcher() {
243 // Inform the waiting requests if it has not done so. 244 // Inform the waiting requests if it has not done so.
244 if (waiting_requests_.size()) 245 if (waiting_requests_.size())
245 InformWaitingRequests(); 246 InformWaitingRequests();
246 } 247 }
247 248
248 void OAuth2TokenService::Fetcher::Start() { 249 void OAuth2TokenService::Fetcher::Start() {
249 fetcher_.reset(new OAuth2AccessTokenFetcher(this, getter_.get())); 250 fetcher_.reset(new OAuth2AccessTokenFetcherImpl(this, getter_.get()));
250 fetcher_->Start(client_id_, 251 fetcher_->Start(client_id_,
251 client_secret_, 252 client_secret_,
252 refresh_token_, 253 refresh_token_,
253 std::vector<std::string>(scopes_.begin(), scopes_.end())); 254 std::vector<std::string>(scopes_.begin(), scopes_.end()));
254 retry_timer_.Stop(); 255 retry_timer_.Stop();
255 } 256 }
256 257
257 void OAuth2TokenService::Fetcher::OnGetTokenSuccess( 258 void OAuth2TokenService::Fetcher::OnGetTokenSuccess(
258 const std::string& access_token, 259 const std::string& access_token,
259 const base::Time& expiration_date) { 260 const base::Time& expiration_date) {
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 const std::string& account_id, 798 const std::string& account_id,
798 const ScopeSet& scopes) const { 799 const ScopeSet& scopes) const {
799 PendingFetcherMap::const_iterator iter = pending_fetchers_.find( 800 PendingFetcherMap::const_iterator iter = pending_fetchers_.find(
800 OAuth2TokenService::RequestParameters( 801 OAuth2TokenService::RequestParameters(
801 client_id, 802 client_id,
802 account_id, 803 account_id,
803 scopes)); 804 scopes));
804 return iter == pending_fetchers_.end() ? 805 return iter == pending_fetchers_.end() ?
805 0 : iter->second->GetWaitingRequestCount(); 806 0 : iter->second->GetWaitingRequestCount();
806 } 807 }
OLDNEW
« no previous file with comments | « google_apis/gaia/oauth2_mint_token_flow.h ('k') | google_apis/gaia/oauth2_token_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698