OLD | NEW |
---|---|
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" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 const OAuth2TokenService::ScopeSet& scopes, | 207 const OAuth2TokenService::ScopeSet& scopes, |
208 base::WeakPtr<RequestImpl> waiting_request) { | 208 base::WeakPtr<RequestImpl> waiting_request) { |
209 OAuth2TokenService::Fetcher* fetcher = new Fetcher( | 209 OAuth2TokenService::Fetcher* fetcher = new Fetcher( |
210 oauth2_token_service, | 210 oauth2_token_service, |
211 account_id, | 211 account_id, |
212 getter, | 212 getter, |
213 client_id, | 213 client_id, |
214 client_secret, | 214 client_secret, |
215 scopes, | 215 scopes, |
216 waiting_request); | 216 waiting_request); |
217 | |
218 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed. | |
219 tracked_objects::ScopedTracker tracking_profile( | |
220 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
221 "422460 OAuth2TokenService::Fetcher::CreateAndStart")); | |
222 | |
217 fetcher->Start(); | 223 fetcher->Start(); |
218 return fetcher; | 224 return fetcher; |
219 } | 225 } |
220 | 226 |
221 OAuth2TokenService::Fetcher::Fetcher( | 227 OAuth2TokenService::Fetcher::Fetcher( |
222 OAuth2TokenService* oauth2_token_service, | 228 OAuth2TokenService* oauth2_token_service, |
223 const std::string& account_id, | 229 const std::string& account_id, |
224 net::URLRequestContextGetter* getter, | 230 net::URLRequestContextGetter* getter, |
225 const std::string& client_id, | 231 const std::string& client_id, |
226 const std::string& client_secret, | 232 const std::string& client_secret, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 } | 410 } |
405 | 411 |
406 std::vector<std::string> OAuth2TokenService::GetAccounts() { | 412 std::vector<std::string> OAuth2TokenService::GetAccounts() { |
407 return std::vector<std::string>(); | 413 return std::vector<std::string>(); |
408 } | 414 } |
409 | 415 |
410 scoped_ptr<OAuth2TokenService::Request> OAuth2TokenService::StartRequest( | 416 scoped_ptr<OAuth2TokenService::Request> OAuth2TokenService::StartRequest( |
411 const std::string& account_id, | 417 const std::string& account_id, |
412 const OAuth2TokenService::ScopeSet& scopes, | 418 const OAuth2TokenService::ScopeSet& scopes, |
413 OAuth2TokenService::Consumer* consumer) { | 419 OAuth2TokenService::Consumer* consumer) { |
420 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed. | |
421 tracked_objects::ScopedTracker tracking_profile( | |
422 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
423 "422460 OAuth2TokenService::StartRequest")); | |
424 | |
Roger Tawa OOO till Jul 10th
2014/11/04 16:28:08
I wonder if this trace is needed given that this f
vadimt
2014/11/04 16:47:53
Done.
| |
414 return StartRequestForClientWithContext( | 425 return StartRequestForClientWithContext( |
415 account_id, | 426 account_id, |
416 GetRequestContext(), | 427 GetRequestContext(), |
417 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), | 428 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), |
418 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), | 429 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), |
419 scopes, | 430 scopes, |
420 consumer); | 431 consumer); |
421 } | 432 } |
422 | 433 |
423 scoped_ptr<OAuth2TokenService::Request> | 434 scoped_ptr<OAuth2TokenService::Request> |
(...skipping 30 matching lines...) Expand all Loading... | |
454 scoped_ptr<OAuth2TokenService::Request> | 465 scoped_ptr<OAuth2TokenService::Request> |
455 OAuth2TokenService::StartRequestForClientWithContext( | 466 OAuth2TokenService::StartRequestForClientWithContext( |
456 const std::string& account_id, | 467 const std::string& account_id, |
457 net::URLRequestContextGetter* getter, | 468 net::URLRequestContextGetter* getter, |
458 const std::string& client_id, | 469 const std::string& client_id, |
459 const std::string& client_secret, | 470 const std::string& client_secret, |
460 const ScopeSet& scopes, | 471 const ScopeSet& scopes, |
461 Consumer* consumer) { | 472 Consumer* consumer) { |
462 DCHECK(CalledOnValidThread()); | 473 DCHECK(CalledOnValidThread()); |
463 | 474 |
475 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed. | |
476 tracked_objects::ScopedTracker tracking_profile1( | |
477 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
478 "422460 OAuth2TokenService::StartRequestForClientWithContext 1")); | |
479 | |
464 scoped_ptr<RequestImpl> request(new RequestImpl(account_id, consumer)); | 480 scoped_ptr<RequestImpl> request(new RequestImpl(account_id, consumer)); |
465 FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_, | 481 FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_, |
466 OnAccessTokenRequested(account_id, | 482 OnAccessTokenRequested(account_id, |
467 consumer->id(), | 483 consumer->id(), |
468 scopes)); | 484 scopes)); |
469 | 485 |
470 if (!RefreshTokenIsAvailable(account_id)) { | 486 if (!RefreshTokenIsAvailable(account_id)) { |
487 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed. | |
488 tracked_objects::ScopedTracker tracking_profile2( | |
489 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
490 "422460 OAuth2TokenService::StartRequestForClientWithContext 2")); | |
491 | |
471 GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP); | 492 GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP); |
472 | 493 |
473 FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_, | 494 FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_, |
474 OnFetchAccessTokenComplete( | 495 OnFetchAccessTokenComplete( |
475 account_id, consumer->id(), scopes, error, | 496 account_id, consumer->id(), scopes, error, |
476 base::Time())); | 497 base::Time())); |
477 | 498 |
478 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 499 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
479 &RequestImpl::InformConsumer, | 500 &RequestImpl::InformConsumer, |
480 request->AsWeakPtr(), | 501 request->AsWeakPtr(), |
481 error, | 502 error, |
482 std::string(), | 503 std::string(), |
483 base::Time())); | 504 base::Time())); |
484 return request.Pass(); | 505 return request.Pass(); |
485 } | 506 } |
486 | 507 |
487 RequestParameters request_parameters(client_id, | 508 RequestParameters request_parameters(client_id, |
488 account_id, | 509 account_id, |
489 scopes); | 510 scopes); |
490 if (HasCacheEntry(request_parameters)) { | 511 if (HasCacheEntry(request_parameters)) { |
512 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed. | |
513 tracked_objects::ScopedTracker tracking_profile3( | |
514 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
515 "422460 OAuth2TokenService::StartRequestForClientWithContext 3")); | |
516 | |
491 StartCacheLookupRequest(request.get(), request_parameters, consumer); | 517 StartCacheLookupRequest(request.get(), request_parameters, consumer); |
492 } else { | 518 } else { |
493 FetchOAuth2Token(request.get(), | 519 FetchOAuth2Token(request.get(), |
494 account_id, | 520 account_id, |
495 getter, | 521 getter, |
496 client_id, | 522 client_id, |
497 client_secret, | 523 client_secret, |
498 scopes); | 524 scopes); |
499 } | 525 } |
500 return request.Pass(); | 526 return request.Pass(); |
501 } | 527 } |
502 | 528 |
503 void OAuth2TokenService::FetchOAuth2Token(RequestImpl* request, | 529 void OAuth2TokenService::FetchOAuth2Token(RequestImpl* request, |
504 const std::string& account_id, | 530 const std::string& account_id, |
505 net::URLRequestContextGetter* getter, | 531 net::URLRequestContextGetter* getter, |
506 const std::string& client_id, | 532 const std::string& client_id, |
507 const std::string& client_secret, | 533 const std::string& client_secret, |
508 const ScopeSet& scopes) { | 534 const ScopeSet& scopes) { |
535 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed. | |
536 tracked_objects::ScopedTracker tracking_profile( | |
537 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
538 "422460 OAuth2TokenService::FetchOAuth2Token")); | |
539 | |
509 // If there is already a pending fetcher for |scopes| and |account_id|, | 540 // If there is already a pending fetcher for |scopes| and |account_id|, |
510 // simply register this |request| for those results rather than starting | 541 // simply register this |request| for those results rather than starting |
511 // a new fetcher. | 542 // a new fetcher. |
512 RequestParameters request_parameters = RequestParameters(client_id, | 543 RequestParameters request_parameters = RequestParameters(client_id, |
513 account_id, | 544 account_id, |
514 scopes); | 545 scopes); |
515 std::map<RequestParameters, Fetcher*>::iterator iter = | 546 std::map<RequestParameters, Fetcher*>::iterator iter = |
516 pending_fetchers_.find(request_parameters); | 547 pending_fetchers_.find(request_parameters); |
517 if (iter != pending_fetchers_.end()) { | 548 if (iter != pending_fetchers_.end()) { |
518 iter->second->AddWaitingRequest(request->AsWeakPtr()); | 549 iter->second->AddWaitingRequest(request->AsWeakPtr()); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 const std::string& account_id, | 840 const std::string& account_id, |
810 const ScopeSet& scopes) const { | 841 const ScopeSet& scopes) const { |
811 PendingFetcherMap::const_iterator iter = pending_fetchers_.find( | 842 PendingFetcherMap::const_iterator iter = pending_fetchers_.find( |
812 OAuth2TokenService::RequestParameters( | 843 OAuth2TokenService::RequestParameters( |
813 client_id, | 844 client_id, |
814 account_id, | 845 account_id, |
815 scopes)); | 846 scopes)); |
816 return iter == pending_fetchers_.end() ? | 847 return iter == pending_fetchers_.end() ? |
817 0 : iter->second->GetWaitingRequestCount(); | 848 0 : iter->second->GetWaitingRequestCount(); |
818 } | 849 } |
OLD | NEW |