| 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_DRIVE_SERVICE_INTERFACE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 // TODO(kochi): Further split gdata_operations.h and include only necessary | 10 // TODO(kochi): Further split gdata_operations.h and include only necessary |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 CSV, // Excel (spreadsheets only). | 38 CSV, // Excel (spreadsheets only). |
| 39 ODS, // Open Document Spreadsheet (spreadsheets only). | 39 ODS, // Open Document Spreadsheet (spreadsheets only). |
| 40 TSV, // Tab Separated Value (spreadsheets only). Only the first worksheet | 40 TSV, // Tab Separated Value (spreadsheets only). Only the first worksheet |
| 41 // is returned in TSV by default. | 41 // is returned in TSV by default. |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // Observer interface for DriveServiceInterface. | 44 // Observer interface for DriveServiceInterface. |
| 45 class DriveServiceObserver { | 45 class DriveServiceObserver { |
| 46 public: | 46 public: |
| 47 // Triggered when the service gets ready to perform operations. | 47 // Triggered when the service gets ready to perform operations. |
| 48 virtual void OnReadyToPerformOperations() = 0; | 48 virtual void OnReadyToPerformOperations() {} |
| 49 |
| 50 // Called when an operation started, made some progress, or finished. |
| 51 virtual void OnProgressUpdate(const OperationProgressStatusList& list) {} |
| 52 |
| 53 // Called when GData authentication failed. |
| 54 virtual void OnAuthenticationFailed() {} |
| 49 | 55 |
| 50 protected: | 56 protected: |
| 51 virtual ~DriveServiceObserver() {} | 57 virtual ~DriveServiceObserver() {} |
| 52 }; | 58 }; |
| 53 | 59 |
| 54 // This defines an interface for sharing by DocumentService and | 60 // This defines an interface for sharing by DocumentService and |
| 55 // MockDocumentService so that we can do testing of clients of DocumentService. | 61 // MockDocumentService so that we can do testing of clients of DocumentService. |
| 56 // | 62 // |
| 57 // All functions must be called on UI thread. DocumentService is built on top | 63 // All functions must be called on UI thread. DocumentService is built on top |
| 58 // of URLFetcher that runs on UI thread. | 64 // of URLFetcher that runs on UI thread. |
| 59 // | 65 // |
| 60 // TODO(zel,benchan): Make the terminology/naming convention (e.g. file vs | 66 // TODO(zel,benchan): Make the terminology/naming convention (e.g. file vs |
| 61 // document vs resource, directory vs collection) more consistent and precise. | 67 // document vs resource, directory vs collection) more consistent and precise. |
| 62 class DriveServiceInterface { | 68 class DriveServiceInterface { |
| 63 public: | 69 public: |
| 64 virtual ~DriveServiceInterface() {} | 70 virtual ~DriveServiceInterface() {} |
| 65 | 71 |
| 66 // Common service: | 72 // Common service: |
| 67 | 73 |
| 68 // Initializes the documents service tied with |profile|. | 74 // Initializes the documents service tied with |profile|. |
| 69 virtual void Initialize(Profile* profile) = 0; | 75 virtual void Initialize(Profile* profile) = 0; |
| 70 | 76 |
| 71 // Adds an observer. | 77 // Adds an observer. |
| 72 virtual void AddObserver(DriveServiceObserver* observer) = 0; | 78 virtual void AddObserver(DriveServiceObserver* observer) = 0; |
| 73 | 79 |
| 74 // Removes an observer. | 80 // Removes an observer. |
| 75 virtual void RemoveObserver(DriveServiceObserver* observer) = 0; | 81 virtual void RemoveObserver(DriveServiceObserver* observer) = 0; |
| 76 | 82 |
| 77 // Retrieves the operation registry. | |
| 78 virtual OperationRegistry* operation_registry() const = 0; | |
| 79 | |
| 80 // True if ready to start operations. | 83 // True if ready to start operations. |
| 81 virtual bool CanStartOperation() const = 0; | 84 virtual bool CanStartOperation() const = 0; |
| 82 | 85 |
| 83 // Cancels all in-flight operations. | 86 // Cancels all in-flight operations. |
| 84 virtual void CancelAll() = 0; | 87 virtual void CancelAll() = 0; |
| 85 | 88 |
| 89 // Cancels ongoing operation for a given virtual |file_path|. Returns true if |
| 90 // the operation was found and canceled. |
| 91 virtual bool CancelForFilePath(const FilePath& file_path) = 0; |
| 92 |
| 93 // Obtains the list of currently active operations. |
| 94 virtual OperationProgressStatusList GetProgressStatusList() const = 0; |
| 95 |
| 86 // Authentication service: | 96 // Authentication service: |
| 87 | 97 |
| 88 // Authenticates the user by fetching the auth token as | 98 // Authenticates the user by fetching the auth token as |
| 89 // needed. |callback| will be run with the error code and the auth | 99 // needed. |callback| will be run with the error code and the auth |
| 90 // token, on the thread this function is run. | 100 // token, on the thread this function is run. |
| 91 virtual void Authenticate(const AuthStatusCallback& callback) = 0; | 101 virtual void Authenticate(const AuthStatusCallback& callback) = 0; |
| 92 | 102 |
| 93 // True if OAuth2 access token is retrieved and believed to be fresh. | 103 // True if OAuth2 access token is retrieved and believed to be fresh. |
| 94 virtual bool HasAccessToken() const = 0; | 104 virtual bool HasAccessToken() const = 0; |
| 95 | 105 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Authorizes a Drive app with the id |app_id| to open the given document. | 223 // Authorizes a Drive app with the id |app_id| to open the given document. |
| 214 // Upon completion, invokes |callback| with results on the calling thread. | 224 // Upon completion, invokes |callback| with results on the calling thread. |
| 215 virtual void AuthorizeApp(const GURL& resource_url, | 225 virtual void AuthorizeApp(const GURL& resource_url, |
| 216 const std::string& app_id, | 226 const std::string& app_id, |
| 217 const GetDataCallback& callback) = 0; | 227 const GetDataCallback& callback) = 0; |
| 218 }; | 228 }; |
| 219 | 229 |
| 220 } // namespace gdata | 230 } // namespace gdata |
| 221 | 231 |
| 222 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ | 232 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ |
| OLD | NEW |