| 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 "chrome/browser/google_apis/operation_runner.h" | 5 #include "chrome/browser/google_apis/operation_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/google_apis/auth_service.h" | 8 #include "chrome/browser/google_apis/auth_service.h" |
| 9 #include "chrome/browser/google_apis/base_operations.h" | 9 #include "chrome/browser/google_apis/base_operations.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 void OperationRunner::Initialize() { | 32 void OperationRunner::Initialize() { |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 34 auth_service_->Initialize(profile_); | 34 auth_service_->Initialize(profile_); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void OperationRunner::CancelAll() { | 37 void OperationRunner::CancelAll() { |
| 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 39 operation_registry_->CancelAll(); | 39 operation_registry_->CancelAll(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void OperationRunner::Authenticate(const AuthStatusCallback& callback) { | |
| 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 44 auth_service_->StartAuthentication(operation_registry_.get(), callback); | |
| 45 } | |
| 46 | |
| 47 void OperationRunner::StartOperationWithRetry( | 42 void OperationRunner::StartOperationWithRetry( |
| 48 AuthenticatedOperationInterface* operation) { | 43 AuthenticatedOperationInterface* operation) { |
| 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 50 | 45 |
| 51 // The re-authentication callback will run on UI thread. | 46 // The re-authentication callback will run on UI thread. |
| 52 operation->SetReAuthenticateCallback( | 47 operation->SetReAuthenticateCallback( |
| 53 base::Bind(&OperationRunner::RetryOperation, | 48 base::Bind(&OperationRunner::RetryOperation, |
| 54 weak_ptr_factory_.GetWeakPtr())); | 49 weak_ptr_factory_.GetWeakPtr())); |
| 55 StartOperation(operation); | 50 StartOperation(operation); |
| 56 } | 51 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 AuthenticatedOperationInterface* operation) { | 89 AuthenticatedOperationInterface* operation) { |
| 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 96 | 91 |
| 97 auth_service_->ClearAccessToken(); | 92 auth_service_->ClearAccessToken(); |
| 98 // User authentication might have expired - rerun the request to force | 93 // User authentication might have expired - rerun the request to force |
| 99 // auth token refresh. | 94 // auth token refresh. |
| 100 StartOperation(operation); | 95 StartOperation(operation); |
| 101 } | 96 } |
| 102 | 97 |
| 103 } // namespace google_apis | 98 } // namespace google_apis |
| OLD | NEW |