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 "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 weak_ptr_factory_.GetWeakPtr())); | 59 weak_ptr_factory_.GetWeakPtr())); |
60 } | 60 } |
61 | 61 |
62 void OperationRunner::OnAccessTokenFetched( | 62 void OperationRunner::OnAccessTokenFetched( |
63 const base::WeakPtr<AuthenticatedOperationInterface>& operation, | 63 const base::WeakPtr<AuthenticatedOperationInterface>& operation, |
64 GDataErrorCode code, | 64 GDataErrorCode code, |
65 const std::string& /* access_token */) { | 65 const std::string& /* access_token */) { |
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
67 | 67 |
68 // Do nothing if the operation is canceled during authentication. | 68 // Do nothing if the operation is canceled during authentication. |
69 if (!operation) | 69 if (!operation.get()) |
70 return; | 70 return; |
71 | 71 |
72 if (code == HTTP_SUCCESS) { | 72 if (code == HTTP_SUCCESS) { |
73 DCHECK(auth_service_->HasAccessToken()); | 73 DCHECK(auth_service_->HasAccessToken()); |
74 StartOperationWithRetry(operation); | 74 StartOperationWithRetry(operation.get()); |
75 } else { | 75 } else { |
76 operation->OnAuthFailed(code); | 76 operation->OnAuthFailed(code); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void OperationRunner::RetryOperation( | 80 void OperationRunner::RetryOperation( |
81 AuthenticatedOperationInterface* operation) { | 81 AuthenticatedOperationInterface* operation) { |
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
83 | 83 |
84 auth_service_->ClearAccessToken(); | 84 auth_service_->ClearAccessToken(); |
85 // User authentication might have expired - rerun the request to force | 85 // User authentication might have expired - rerun the request to force |
86 // auth token refresh. | 86 // auth token refresh. |
87 StartOperationWithRetry(operation); | 87 StartOperationWithRetry(operation); |
88 } | 88 } |
89 | 89 |
90 } // namespace google_apis | 90 } // namespace google_apis |
OLD | NEW |