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_access_token_fetcher_immediate_error.h" | 5 #include "google_apis/gaia/oauth2_access_token_fetcher_immediate_error.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
9 #include "google_apis/gaia/google_service_auth_error.h" | 9 #include "google_apis/gaia/google_service_auth_error.h" |
10 | 10 |
11 | 11 |
12 OAuth2AccessTokenFetcherImmediateError::FailCaller::FailCaller( | 12 OAuth2AccessTokenFetcherImmediateError::FailCaller::FailCaller( |
13 OAuth2AccessTokenFetcherImmediateError* fetcher) | 13 OAuth2AccessTokenFetcherImmediateError* fetcher) |
14 : fetcher_(fetcher) { | 14 : fetcher_(fetcher) { |
15 base::MessageLoop* looper = base::MessageLoop::current(); | 15 base::ThreadTaskRunnerHandle::Get()->PostTask( |
16 DCHECK(looper); | |
17 looper->PostTask( | |
18 FROM_HERE, | 16 FROM_HERE, |
19 base::Bind(&OAuth2AccessTokenFetcherImmediateError::FailCaller::run, | 17 base::Bind(&OAuth2AccessTokenFetcherImmediateError::FailCaller::run, |
20 this)); | 18 this)); |
21 } | 19 } |
22 | 20 |
23 OAuth2AccessTokenFetcherImmediateError::FailCaller::~FailCaller() { | 21 OAuth2AccessTokenFetcherImmediateError::FailCaller::~FailCaller() { |
24 } | 22 } |
25 | 23 |
26 void OAuth2AccessTokenFetcherImmediateError::FailCaller::run() { | 24 void OAuth2AccessTokenFetcherImmediateError::FailCaller::run() { |
27 if (fetcher_) { | 25 if (fetcher_) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 61 } |
64 | 62 |
65 void OAuth2AccessTokenFetcherImmediateError::Fail() { | 63 void OAuth2AccessTokenFetcherImmediateError::Fail() { |
66 // The call below will likely destruct this object. We have to make a copy | 64 // 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 | 65 // 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 | 66 // be destroyed after which the copy-passed-by-reference will cause a |
69 // memory violation when accessed. | 67 // memory violation when accessed. |
70 GoogleServiceAuthError error_copy = immediate_error_; | 68 GoogleServiceAuthError error_copy = immediate_error_; |
71 FireOnGetTokenFailure(error_copy); | 69 FireOnGetTokenFailure(error_copy); |
72 } | 70 } |
OLD | NEW |