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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/location.h" | 6 #include "base/location.h" |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "components/gcm_driver/gcm_driver.h" | 9 #include "components/gcm_driver/gcm_driver.h" |
10 #include "components/invalidation/impl/gcm_invalidation_bridge.h" | 10 #include "components/invalidation/impl/gcm_invalidation_bridge.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope); | 207 scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope); |
208 access_token_request_ = identity_provider_->GetTokenService()->StartRequest( | 208 access_token_request_ = identity_provider_->GetTokenService()->StartRequest( |
209 identity_provider_->GetActiveAccountId(), scopes, this); | 209 identity_provider_->GetActiveAccountId(), scopes, this); |
210 } | 210 } |
211 | 211 |
212 void GCMInvalidationBridge::OnGetTokenSuccess( | 212 void GCMInvalidationBridge::OnGetTokenSuccess( |
213 const OAuth2TokenService::Request* request, | 213 const OAuth2TokenService::Request* request, |
214 const std::string& access_token, | 214 const std::string& access_token, |
215 const base::Time& expiration_time) { | 215 const base::Time& expiration_time) { |
216 DCHECK(CalledOnValidThread()); | 216 DCHECK(CalledOnValidThread()); |
217 DCHECK_EQ(access_token_request_, request); | 217 DCHECK_EQ(access_token_request_.get(), request); |
218 core_thread_task_runner_->PostTask( | 218 core_thread_task_runner_->PostTask( |
219 FROM_HERE, | 219 FROM_HERE, |
220 base::Bind(&GCMInvalidationBridge::Core::RequestTokenFinished, | 220 base::Bind(&GCMInvalidationBridge::Core::RequestTokenFinished, |
221 core_, | 221 core_, |
222 request_token_callback_, | 222 request_token_callback_, |
223 GoogleServiceAuthError::AuthErrorNone(), | 223 GoogleServiceAuthError::AuthErrorNone(), |
224 access_token)); | 224 access_token)); |
225 request_token_callback_.Reset(); | 225 request_token_callback_.Reset(); |
226 access_token_request_.reset(); | 226 access_token_request_.reset(); |
227 } | 227 } |
228 | 228 |
229 void GCMInvalidationBridge::OnGetTokenFailure( | 229 void GCMInvalidationBridge::OnGetTokenFailure( |
230 const OAuth2TokenService::Request* request, | 230 const OAuth2TokenService::Request* request, |
231 const GoogleServiceAuthError& error) { | 231 const GoogleServiceAuthError& error) { |
232 DCHECK(CalledOnValidThread()); | 232 DCHECK(CalledOnValidThread()); |
233 DCHECK_EQ(access_token_request_, request); | 233 DCHECK_EQ(access_token_request_.get(), request); |
234 core_thread_task_runner_->PostTask( | 234 core_thread_task_runner_->PostTask( |
235 FROM_HERE, | 235 FROM_HERE, |
236 base::Bind(&GCMInvalidationBridge::Core::RequestTokenFinished, | 236 base::Bind(&GCMInvalidationBridge::Core::RequestTokenFinished, |
237 core_, | 237 core_, |
238 request_token_callback_, | 238 request_token_callback_, |
239 error, | 239 error, |
240 std::string())); | 240 std::string())); |
241 request_token_callback_.Reset(); | 241 request_token_callback_.Reset(); |
242 access_token_request_.reset(); | 242 access_token_request_.reset(); |
243 } | 243 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 367 |
368 void GCMInvalidationBridge::OnDisconnected() { | 368 void GCMInvalidationBridge::OnDisconnected() { |
369 core_thread_task_runner_->PostTask( | 369 core_thread_task_runner_->PostTask( |
370 FROM_HERE, | 370 FROM_HERE, |
371 base::Bind(&GCMInvalidationBridge::Core::OnConnectionStateChanged, | 371 base::Bind(&GCMInvalidationBridge::Core::OnConnectionStateChanged, |
372 core_, | 372 core_, |
373 false)); | 373 false)); |
374 } | 374 } |
375 | 375 |
376 } // namespace invalidation | 376 } // namespace invalidation |
OLD | NEW |