OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/drive/auth_service.h" | 5 #include "google_apis/drive/auth_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 DCHECK(thread_checker_.CalledOnValidThread()); | 142 DCHECK(thread_checker_.CalledOnValidThread()); |
143 | 143 |
144 if (HasAccessToken()) { | 144 if (HasAccessToken()) { |
145 // We already have access token. Give it back to the caller asynchronously. | 145 // We already have access token. Give it back to the caller asynchronously. |
146 base::MessageLoop::current()->PostTask( | 146 base::MessageLoop::current()->PostTask( |
147 FROM_HERE, base::Bind(callback, HTTP_SUCCESS, access_token_)); | 147 FROM_HERE, base::Bind(callback, HTTP_SUCCESS, access_token_)); |
148 } else if (HasRefreshToken()) { | 148 } else if (HasRefreshToken()) { |
149 // We have refresh token, let's get an access token. | 149 // We have refresh token, let's get an access token. |
150 new AuthRequest(oauth2_token_service_, | 150 new AuthRequest(oauth2_token_service_, |
151 account_id_, | 151 account_id_, |
152 url_request_context_getter_, | 152 url_request_context_getter_.get(), |
153 base::Bind(&AuthService::OnAuthCompleted, | 153 base::Bind(&AuthService::OnAuthCompleted, |
154 weak_ptr_factory_.GetWeakPtr(), | 154 weak_ptr_factory_.GetWeakPtr(), |
155 callback), | 155 callback), |
156 scopes_); | 156 scopes_); |
157 } else { | 157 } else { |
158 base::MessageLoop::current()->PostTask( | 158 base::MessageLoop::current()->PostTask( |
159 FROM_HERE, base::Bind(callback, GDATA_NOT_READY, std::string())); | 159 FROM_HERE, base::Bind(callback, GDATA_NOT_READY, std::string())); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 void AuthService::OnHandleRefreshToken(bool has_refresh_token) { | 223 void AuthService::OnHandleRefreshToken(bool has_refresh_token) { |
224 access_token_.clear(); | 224 access_token_.clear(); |
225 has_refresh_token_ = has_refresh_token; | 225 has_refresh_token_ = has_refresh_token; |
226 | 226 |
227 FOR_EACH_OBSERVER(AuthServiceObserver, | 227 FOR_EACH_OBSERVER(AuthServiceObserver, |
228 observers_, | 228 observers_, |
229 OnOAuth2RefreshTokenChanged()); | 229 OnOAuth2RefreshTokenChanged()); |
230 } | 230 } |
231 | 231 |
232 } // namespace google_apis | 232 } // namespace google_apis |
OLD | NEW |