| Index: chrome/browser/google_apis/request_sender.cc
|
| diff --git a/chrome/browser/google_apis/operation_runner.cc b/chrome/browser/google_apis/request_sender.cc
|
| similarity index 64%
|
| rename from chrome/browser/google_apis/operation_runner.cc
|
| rename to chrome/browser/google_apis/request_sender.cc
|
| index 21be6fb3b7b5a7c161a7d0ef9e82aeb788ea0261..6d9810a5e4c3338e408a9b87a56480133804487c 100644
|
| --- a/chrome/browser/google_apis/operation_runner.cc
|
| +++ b/chrome/browser/google_apis/request_sender.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/google_apis/operation_runner.h"
|
| +#include "chrome/browser/google_apis/request_sender.h"
|
|
|
| #include "base/bind.h"
|
| #include "chrome/browser/google_apis/auth_service.h"
|
| @@ -13,7 +13,7 @@ using content::BrowserThread;
|
|
|
| namespace google_apis {
|
|
|
| -OperationRunner::OperationRunner(
|
| +RequestSender::RequestSender(
|
| Profile* profile,
|
| net::URLRequestContextGetter* url_request_context_getter,
|
| const std::vector<std::string>& scopes,
|
| @@ -26,65 +26,65 @@ OperationRunner::OperationRunner(
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| }
|
|
|
| -OperationRunner::~OperationRunner() {
|
| +RequestSender::~RequestSender() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| }
|
|
|
| -void OperationRunner::Initialize() {
|
| +void RequestSender::Initialize() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| auth_service_->Initialize(profile_);
|
| }
|
|
|
| -void OperationRunner::CancelAll() {
|
| +void RequestSender::CancelAll() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| operation_registry_->CancelAll();
|
| }
|
|
|
| -void OperationRunner::StartOperationWithRetry(
|
| - AuthenticatedRequestInterface* operation) {
|
| +void RequestSender::StartRequestWithRetry(
|
| + AuthenticatedRequestInterface* request) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| if (!auth_service_->HasAccessToken()) {
|
| // Fetch OAuth2 access token from the refresh token first.
|
| auth_service_->StartAuthentication(
|
| - base::Bind(&OperationRunner::OnAccessTokenFetched,
|
| + base::Bind(&RequestSender::OnAccessTokenFetched,
|
| weak_ptr_factory_.GetWeakPtr(),
|
| - operation->GetWeakPtr()));
|
| + request->GetWeakPtr()));
|
| return;
|
| }
|
|
|
| - operation->Start(auth_service_->access_token(),
|
| - custom_user_agent_,
|
| - base::Bind(&OperationRunner::RetryOperation,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| + request->Start(auth_service_->access_token(),
|
| + custom_user_agent_,
|
| + base::Bind(&RequestSender::RetryRequest,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| -void OperationRunner::OnAccessTokenFetched(
|
| - const base::WeakPtr<AuthenticatedRequestInterface>& operation,
|
| +void RequestSender::OnAccessTokenFetched(
|
| + const base::WeakPtr<AuthenticatedRequestInterface>& request,
|
| GDataErrorCode code,
|
| const std::string& /* access_token */) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| - // Do nothing if the operation is canceled during authentication.
|
| - if (!operation.get())
|
| + // Do nothing if the request is canceled during authentication.
|
| + if (!request.get())
|
| return;
|
|
|
| if (code == HTTP_SUCCESS) {
|
| DCHECK(auth_service_->HasAccessToken());
|
| - StartOperationWithRetry(operation.get());
|
| + StartRequestWithRetry(request.get());
|
| } else {
|
| - operation->OnAuthFailed(code);
|
| + request->OnAuthFailed(code);
|
| }
|
| }
|
|
|
| -void OperationRunner::RetryOperation(
|
| - AuthenticatedRequestInterface* operation) {
|
| +void RequestSender::RetryRequest(
|
| + AuthenticatedRequestInterface* request) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| auth_service_->ClearAccessToken();
|
| // User authentication might have expired - rerun the request to force
|
| // auth token refresh.
|
| - StartOperationWithRetry(operation);
|
| + StartRequestWithRetry(request);
|
| }
|
|
|
| } // namespace google_apis
|
|
|