| 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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATION_RUNNER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATION_RUNNER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATION_RUNNER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATION_RUNNER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/chromeos/gdata/auth_service.h" | 13 #include "chrome/browser/chromeos/gdata/auth_service.h" |
| 14 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 14 #include "chrome/browser/chromeos/gdata/drive_errorcode.h" |
| 15 | 15 |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 namespace gdata { | 18 namespace gdata { |
| 19 | 19 |
| 20 class GDataOperationInterface; | 20 class GDataOperationInterface; |
| 21 class OperationRegistry; | 21 class OperationRegistry; |
| 22 | 22 |
| 23 // Helper class that runs GDataOperationInterface objects, handling retries and | 23 // Helper class that runs GDataOperationInterface objects, handling retries and |
| 24 // authentication. | 24 // authentication. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 // Starts an operation implementing the GDataOperationInterface interface, and | 46 // Starts an operation implementing the GDataOperationInterface interface, and |
| 47 // makes the operation retry upon authentication failures by calling back to | 47 // makes the operation retry upon authentication failures by calling back to |
| 48 // RetryOperation. | 48 // RetryOperation. |
| 49 void StartOperationWithRetry(GDataOperationInterface* operation); | 49 void StartOperationWithRetry(GDataOperationInterface* operation); |
| 50 | 50 |
| 51 // Starts an operation implementing the GDataOperationInterface interface. | 51 // Starts an operation implementing the GDataOperationInterface interface. |
| 52 void StartOperation(GDataOperationInterface* operation); | 52 void StartOperation(GDataOperationInterface* operation); |
| 53 | 53 |
| 54 // Called when the authentication token is refreshed. | 54 // Called when the authentication token is refreshed. |
| 55 void OnOperationAuthRefresh(GDataOperationInterface* operation, | 55 void OnOperationAuthRefresh(GDataOperationInterface* operation, |
| 56 GDataErrorCode error, | 56 DriveErrorCode error, |
| 57 const std::string& auth_token); | 57 const std::string& auth_token); |
| 58 | 58 |
| 59 // Clears any authentication token and retries the operation, which | 59 // Clears any authentication token and retries the operation, which |
| 60 // forces an authentication token refresh. | 60 // forces an authentication token refresh. |
| 61 void RetryOperation(GDataOperationInterface* operation); | 61 void RetryOperation(GDataOperationInterface* operation); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 // AuthService::Observer override. | 64 // AuthService::Observer override. |
| 65 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; | 65 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; |
| 66 | 66 |
| 67 Profile* profile_; // not owned | 67 Profile* profile_; // not owned |
| 68 | 68 |
| 69 scoped_ptr<AuthService> auth_service_; | 69 scoped_ptr<AuthService> auth_service_; |
| 70 scoped_ptr<OperationRegistry> operation_registry_; | 70 scoped_ptr<OperationRegistry> operation_registry_; |
| 71 | 71 |
| 72 // Note: This should remain the last member so it'll be destroyed and | 72 // Note: This should remain the last member so it'll be destroyed and |
| 73 // invalidate its weak pointers before any other members are destroyed. | 73 // invalidate its weak pointers before any other members are destroyed. |
| 74 base::WeakPtrFactory<OperationRunner> weak_ptr_factory_; | 74 base::WeakPtrFactory<OperationRunner> weak_ptr_factory_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(OperationRunner); | 76 DISALLOW_COPY_AND_ASSIGN(OperationRunner); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace gdata | 79 } // namespace gdata |
| 80 | 80 |
| 81 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATION_RUNNER_H_ | 81 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATION_RUNNER_H_ |
| OLD | NEW |