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
3 // found in the LICENSE file.
5 #include "google_apis/gaia/oauth2_access_token_fetcher_immediate_error.h"
8 #include "base/message_loop/message_loop.h"
9 #include "google_apis/gaia/google_service_auth_error.h"
12 OAuth2AccessTokenFetcherImmediateError::FailCaller::FailCaller(
13 OAuth2AccessTokenFetcherImmediateError
* fetcher
)
15 base::MessageLoop
* looper
= base::MessageLoop::current();
19 base::Bind(&OAuth2AccessTokenFetcherImmediateError::FailCaller::run
,
23 OAuth2AccessTokenFetcherImmediateError::FailCaller::~FailCaller() {
26 void OAuth2AccessTokenFetcherImmediateError::FailCaller::run() {
33 void OAuth2AccessTokenFetcherImmediateError::FailCaller::detach() {
38 OAuth2AccessTokenFetcherImmediateError::OAuth2AccessTokenFetcherImmediateError(
39 OAuth2AccessTokenConsumer
* consumer
,
40 const GoogleServiceAuthError
& error
)
41 : OAuth2AccessTokenFetcher(consumer
),
42 immediate_error_(error
) {
43 DCHECK(immediate_error_
!= GoogleServiceAuthError::AuthErrorNone());
46 OAuth2AccessTokenFetcherImmediateError::
47 ~OAuth2AccessTokenFetcherImmediateError() {
51 void OAuth2AccessTokenFetcherImmediateError::CancelRequest() {
58 void OAuth2AccessTokenFetcherImmediateError::Start(
59 const std::string
& client_id
,
60 const std::string
& client_secret
,
61 const std::vector
<std::string
>& scopes
) {
62 failer_
= new FailCaller(this);
65 void OAuth2AccessTokenFetcherImmediateError::Fail() {
66 // The call below will likely destruct this object. We have to make a copy
67 // of the error into a local variable because the class member thus will
68 // be destroyed after which the copy-passed-by-reference will cause a
69 // memory violation when accessed.
70 GoogleServiceAuthError error_copy
= immediate_error_
;
71 FireOnGetTokenFailure(error_copy
);