| 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_DRIVE_DRIVE_SERVICE_INTERFACE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SERVICE_INTERFACE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SERVICE_INTERFACE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_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 |
| 11 // headers. http://crbug.com/141469 | 11 // headers. http://crbug.com/141469 |
| 12 // DownloadActionCallback/InitiateUploadParams/ResulmeUploadParams | 12 // DownloadActionCallback/InitiateUploadParams/ResulmeUploadParams |
| 13 #include "chrome/browser/google_apis/gdata_operations.h" | 13 #include "chrome/browser/google_apis/gdata_operations.h" |
| 14 #include "chrome/browser/google_apis/operations_base.h" | 14 #include "chrome/browser/google_apis/operations_base.h" |
| 15 | 15 |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 namespace gdata { | 18 namespace drive { |
| 19 | 19 |
| 20 class OperationRegistry; | 20 class OperationRegistry; |
| 21 | 21 |
| 22 // Document export format. | 22 // Document export format. |
| 23 enum DocumentExportFormat { | 23 enum DocumentExportFormat { |
| 24 PDF, // Portable Document Format. (all documents) | 24 PDF, // Portable Document Format. (all documents) |
| 25 PNG, // Portable Networks Graphic Image Format (all documents) | 25 PNG, // Portable Networks Graphic Image Format (all documents) |
| 26 HTML, // HTML Format (text documents and spreadsheets). | 26 HTML, // HTML Format (text documents and spreadsheets). |
| 27 TXT, // Text file (text documents and presentations). | 27 TXT, // Text file (text documents and presentations). |
| 28 DOC, // Word (text documents only). | 28 DOC, // Word (text documents only). |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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() {} | 48 virtual void OnReadyToPerformOperations() {} |
| 49 | 49 |
| 50 // Called when an operation started, made some progress, or finished. | 50 // Called when an operation started, made some progress, or finished. |
| 51 virtual void OnProgressUpdate(const OperationProgressStatusList& list) {} | 51 virtual void OnProgressUpdate( |
| 52 const gdata::OperationProgressStatusList& list) {} |
| 52 | 53 |
| 53 // Called when GData authentication failed. | 54 // Called when GData authentication failed. |
| 54 virtual void OnAuthenticationFailed(GDataErrorCode error) {} | 55 virtual void OnAuthenticationFailed(gdata::GDataErrorCode error) {} |
| 55 | 56 |
| 56 protected: | 57 protected: |
| 57 virtual ~DriveServiceObserver() {} | 58 virtual ~DriveServiceObserver() {} |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 // This defines an interface for sharing by DocumentService and | 61 // This defines an interface for sharing by DocumentService and |
| 61 // MockDocumentService so that we can do testing of clients of DocumentService. | 62 // MockDocumentService so that we can do testing of clients of DocumentService. |
| 62 // | 63 // |
| 63 // All functions must be called on UI thread. DocumentService is built on top | 64 // All functions must be called on UI thread. DocumentService is built on top |
| 64 // of URLFetcher that runs on UI thread. | 65 // of URLFetcher that runs on UI thread. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 virtual bool CanStartOperation() const = 0; | 85 virtual bool CanStartOperation() const = 0; |
| 85 | 86 |
| 86 // Cancels all in-flight operations. | 87 // Cancels all in-flight operations. |
| 87 virtual void CancelAll() = 0; | 88 virtual void CancelAll() = 0; |
| 88 | 89 |
| 89 // Cancels ongoing operation for a given virtual |file_path|. Returns true if | 90 // Cancels ongoing operation for a given virtual |file_path|. Returns true if |
| 90 // the operation was found and canceled. | 91 // the operation was found and canceled. |
| 91 virtual bool CancelForFilePath(const FilePath& file_path) = 0; | 92 virtual bool CancelForFilePath(const FilePath& file_path) = 0; |
| 92 | 93 |
| 93 // Obtains the list of currently active operations. | 94 // Obtains the list of currently active operations. |
| 94 virtual OperationProgressStatusList GetProgressStatusList() const = 0; | 95 virtual gdata::OperationProgressStatusList GetProgressStatusList() const = 0; |
| 95 | 96 |
| 96 // Authentication service: | 97 // Authentication service: |
| 97 | 98 |
| 98 // Authenticates the user by fetching the auth token as | 99 // Authenticates the user by fetching the auth token as |
| 99 // needed. |callback| will be run with the error code and the auth | 100 // needed. |callback| will be run with the error code and the auth |
| 100 // token, on the thread this function is run. | 101 // token, on the thread this function is run. |
| 101 virtual void Authenticate(const AuthStatusCallback& callback) = 0; | 102 virtual void Authenticate(const gdata::AuthStatusCallback& callback) = 0; |
| 102 | 103 |
| 103 // True if OAuth2 access token is retrieved and believed to be fresh. | 104 // True if OAuth2 access token is retrieved and believed to be fresh. |
| 104 virtual bool HasAccessToken() const = 0; | 105 virtual bool HasAccessToken() const = 0; |
| 105 | 106 |
| 106 // True if OAuth2 refresh token is present. | 107 // True if OAuth2 refresh token is present. |
| 107 virtual bool HasRefreshToken() const = 0; | 108 virtual bool HasRefreshToken() const = 0; |
| 108 | 109 |
| 109 // Document access: | 110 // Document access: |
| 110 | 111 |
| 111 // Fetches the document feed from |feed_url| with |start_changestamp|. If this | 112 // Fetches the document feed from |feed_url| with |start_changestamp|. If this |
| 112 // URL is empty, the call will fetch the default root or change document feed. | 113 // URL is empty, the call will fetch the default root or change document feed. |
| 113 // |start_changestamp| specifies the starting point from change feeds only. | 114 // |start_changestamp| specifies the starting point from change feeds only. |
| 114 // Value different than 0, it would trigger delta feed fetching. | 115 // Value different than 0, it would trigger delta feed fetching. |
| 115 // | 116 // |
| 116 // |search_query| specifies search query to be sent to the server. It will be | 117 // |search_query| specifies search query to be sent to the server. It will be |
| 117 // used only if |start_changestamp| is 0. If empty string is passed, | 118 // used only if |start_changestamp| is 0. If empty string is passed, |
| 118 // |search_query| is ignored. | 119 // |search_query| is ignored. |
| 119 // | 120 // |
| 120 // |directory_resource_id| specifies the directory from which documents are | 121 // |directory_resource_id| specifies the directory from which documents are |
| 121 // fetched. It will be used only if |start_changestamp| is 0. If empty | 122 // fetched. It will be used only if |start_changestamp| is 0. If empty |
| 122 // string is passed, |directory_resource_id| is ignored. | 123 // string is passed, |directory_resource_id| is ignored. |
| 123 // | 124 // |
| 124 // Upon completion, invokes |callback| with results on the calling thread. | 125 // Upon completion, invokes |callback| with results on the calling thread. |
| 125 // TODO(satorux): Refactor this function: crbug.com/128746 | 126 // TODO(satorux): Refactor this function: crbug.com/128746 |
| 126 virtual void GetDocuments(const GURL& feed_url, | 127 virtual void GetDocuments(const GURL& feed_url, |
| 127 int64 start_changestamp, | 128 int64 start_changestamp, |
| 128 const std::string& search_query, | 129 const std::string& search_query, |
| 129 const std::string& directory_resource_id, | 130 const std::string& directory_resource_id, |
| 130 const GetDataCallback& callback) = 0; | 131 const gdata::GetDataCallback& callback) = 0; |
| 131 | 132 |
| 132 // Fetches single entry metadata from server. The entry's resource id equals | 133 // Fetches single entry metadata from server. The entry's resource id equals |
| 133 // |resource_id|. | 134 // |resource_id|. |
| 134 // Upon completion, invokes |callback| with results on the calling thread. | 135 // Upon completion, invokes |callback| with results on the calling thread. |
| 135 virtual void GetDocumentEntry(const std::string& resource_id, | 136 virtual void GetDocumentEntry(const std::string& resource_id, |
| 136 const GetDataCallback& callback) = 0; | 137 const gdata::GetDataCallback& callback) = 0; |
| 137 | 138 |
| 138 // Gets the account metadata from the server using the default account | 139 // Gets the account metadata from the server using the default account |
| 139 // metadata URL. Upon completion, invokes |callback| with results on the | 140 // metadata URL. Upon completion, invokes |callback| with results on the |
| 140 // calling thread. | 141 // calling thread. |
| 141 virtual void GetAccountMetadata(const GetDataCallback& callback) = 0; | 142 virtual void GetAccountMetadata(const gdata::GetDataCallback& callback) = 0; |
| 142 | 143 |
| 143 // Gets the application information from the server. | 144 // Gets the application information from the server. |
| 144 // Upon completion, invokes |callback| with results on the calling thread. | 145 // Upon completion, invokes |callback| with results on the calling thread. |
| 145 virtual void GetApplicationInfo(const GetDataCallback& callback) = 0; | 146 virtual void GetApplicationInfo(const gdata::GetDataCallback& callback) = 0; |
| 146 | 147 |
| 147 // Deletes a document identified by its 'self' |url| and |etag|. | 148 // Deletes a document identified by its 'self' |url| and |etag|. |
| 148 // Upon completion, invokes |callback| with results on the calling thread. | 149 // Upon completion, invokes |callback| with results on the calling thread. |
| 149 virtual void DeleteDocument(const GURL& document_url, | 150 virtual void DeleteDocument(const GURL& document_url, |
| 150 const EntryActionCallback& callback) = 0; | 151 const gdata::EntryActionCallback& callback) = 0; |
| 151 | 152 |
| 152 // Downloads a document identified by its |content_url| in a given |format|. | 153 // Downloads a document identified by its |content_url| in a given |format|. |
| 153 // Upon completion, invokes |callback| with results on the calling thread. | 154 // Upon completion, invokes |callback| with results on the calling thread. |
| 154 virtual void DownloadDocument(const FilePath& virtual_path, | 155 virtual void DownloadDocument( |
| 155 const FilePath& local_cache_path, | 156 const FilePath& virtual_path, |
| 156 const GURL& content_url, | 157 const FilePath& local_cache_path, |
| 157 DocumentExportFormat format, | 158 const GURL& content_url, |
| 158 const DownloadActionCallback& callback) = 0; | 159 DocumentExportFormat format, |
| 160 const gdata::DownloadActionCallback& callback) = 0; |
| 159 | 161 |
| 160 // Makes a copy of a document identified by its |resource_id|. | 162 // Makes a copy of a document identified by its |resource_id|. |
| 161 // The copy is named as the UTF-8 encoded |new_name| and is not added to any | 163 // The copy is named as the UTF-8 encoded |new_name| and is not added to any |
| 162 // collection. Use AddResourceToDirectory() to add the copy to a collection | 164 // collection. Use AddResourceToDirectory() to add the copy to a collection |
| 163 // when needed. Upon completion, invokes |callback| with results on the | 165 // when needed. Upon completion, invokes |callback| with results on the |
| 164 // calling thread. | 166 // calling thread. |
| 165 virtual void CopyDocument(const std::string& resource_id, | 167 virtual void CopyDocument(const std::string& resource_id, |
| 166 const FilePath::StringType& new_name, | 168 const FilePath::StringType& new_name, |
| 167 const GetDataCallback& callback) = 0; | 169 const gdata::GetDataCallback& callback) = 0; |
| 168 | 170 |
| 169 // Renames a document or collection identified by its 'self' link | 171 // Renames a document or collection identified by its 'self' link |
| 170 // |document_url| to the UTF-8 encoded |new_name|. Upon completion, | 172 // |document_url| to the UTF-8 encoded |new_name|. Upon completion, |
| 171 // invokes |callback| with results on the calling thread. | 173 // invokes |callback| with results on the calling thread. |
| 172 virtual void RenameResource(const GURL& resource_url, | 174 virtual void RenameResource(const GURL& resource_url, |
| 173 const FilePath::StringType& new_name, | 175 const FilePath::StringType& new_name, |
| 174 const EntryActionCallback& callback) = 0; | 176 const gdata::EntryActionCallback& callback) = 0; |
| 175 | 177 |
| 176 // Adds a resource (document, file, or collection) identified by its | 178 // Adds a resource (document, file, or collection) identified by its |
| 177 // 'self' link |resource_url| to a collection with a content link | 179 // 'self' link |resource_url| to a collection with a content link |
| 178 // |parent_content_url|. Upon completion, invokes |callback| with | 180 // |parent_content_url|. Upon completion, invokes |callback| with |
| 179 // results on the calling thread. | 181 // results on the calling thread. |
| 180 virtual void AddResourceToDirectory(const GURL& parent_content_url, | 182 virtual void AddResourceToDirectory( |
| 181 const GURL& resource_url, | 183 const GURL& parent_content_url, |
| 182 const EntryActionCallback& callback) = 0; | 184 const GURL& resource_url, |
| 185 const gdata::EntryActionCallback& callback) = 0; |
| 183 | 186 |
| 184 // Removes a resource (document, file, collection) identified by its | 187 // Removes a resource (document, file, collection) identified by its |
| 185 // 'self' link |resource_url| from a collection with a content link | 188 // 'self' link |resource_url| from a collection with a content link |
| 186 // |parent_content_url|. Upon completion, invokes |callback| with | 189 // |parent_content_url|. Upon completion, invokes |callback| with |
| 187 // results on the calling thread. | 190 // results on the calling thread. |
| 188 virtual void RemoveResourceFromDirectory( | 191 virtual void RemoveResourceFromDirectory( |
| 189 const GURL& parent_content_url, | 192 const GURL& parent_content_url, |
| 190 const GURL& resource_url, | 193 const GURL& resource_url, |
| 191 const std::string& resource_id, | 194 const std::string& resource_id, |
| 192 const EntryActionCallback& callback) = 0; | 195 const gdata::EntryActionCallback& callback) = 0; |
| 193 | 196 |
| 194 // Creates new collection with |directory_name| under parent directory | 197 // Creates new collection with |directory_name| under parent directory |
| 195 // identified with |parent_content_url|. If |parent_content_url| is empty, | 198 // identified with |parent_content_url|. If |parent_content_url| is empty, |
| 196 // the new collection will be created in the root. Upon completion, | 199 // the new collection will be created in the root. Upon completion, |
| 197 // invokes |callback| and passes newly created entry on the calling thread. | 200 // invokes |callback| and passes newly created entry on the calling thread. |
| 198 virtual void CreateDirectory(const GURL& parent_content_url, | 201 virtual void CreateDirectory(const GURL& parent_content_url, |
| 199 const FilePath::StringType& directory_name, | 202 const FilePath::StringType& directory_name, |
| 200 const GetDataCallback& callback) = 0; | 203 const gdata::GetDataCallback& callback) = 0; |
| 201 | 204 |
| 202 // Downloads a file identified by its |content_url|. The downloaded file will | 205 // Downloads a file identified by its |content_url|. The downloaded file will |
| 203 // be stored at |local_cache_path| location. Upon completion, invokes | 206 // be stored at |local_cache_path| location. Upon completion, invokes |
| 204 // |download_action_callback| with results on the calling thread. | 207 // |download_action_callback| with results on the calling thread. |
| 205 // If |get_content_callback| is not empty, | 208 // If |get_content_callback| is not empty, |
| 206 // URLFetcherDelegate::OnURLFetchDownloadData will be called, which will in | 209 // URLFetcherDelegate::OnURLFetchDownloadData will be called, which will in |
| 207 // turn invoke |get_content_callback| on the calling thread. | 210 // turn invoke |get_content_callback| on the calling thread. |
| 208 virtual void DownloadFile( | 211 virtual void DownloadFile( |
| 209 const FilePath& virtual_path, | 212 const FilePath& virtual_path, |
| 210 const FilePath& local_cache_path, | 213 const FilePath& local_cache_path, |
| 211 const GURL& content_url, | 214 const GURL& content_url, |
| 212 const DownloadActionCallback& download_action_callback, | 215 const gdata::DownloadActionCallback& download_action_callback, |
| 213 const GetContentCallback& get_content_callback) = 0; | 216 const gdata::GetContentCallback& get_content_callback) = 0; |
| 214 | 217 |
| 215 // Initiates uploading of a document/file. | 218 // Initiates uploading of a document/file. |
| 216 virtual void InitiateUpload(const InitiateUploadParams& params, | 219 virtual void InitiateUpload( |
| 217 const InitiateUploadCallback& callback) = 0; | 220 const gdata::InitiateUploadParams& params, |
| 221 const gdata::InitiateUploadCallback& callback) = 0; |
| 218 | 222 |
| 219 // Resumes uploading of a document/file on the calling thread. | 223 // Resumes uploading of a document/file on the calling thread. |
| 220 virtual void ResumeUpload(const ResumeUploadParams& params, | 224 virtual void ResumeUpload(const gdata::ResumeUploadParams& params, |
| 221 const ResumeUploadCallback& callback) = 0; | 225 const gdata::ResumeUploadCallback& callback) = 0; |
| 222 | 226 |
| 223 // Authorizes a Drive app with the id |app_id| to open the given document. | 227 // Authorizes a Drive app with the id |app_id| to open the given document. |
| 224 // Upon completion, invokes |callback| with results on the calling thread. | 228 // Upon completion, invokes |callback| with results on the calling thread. |
| 225 virtual void AuthorizeApp(const GURL& resource_url, | 229 virtual void AuthorizeApp(const GURL& resource_url, |
| 226 const std::string& app_id, | 230 const std::string& app_id, |
| 227 const GetDataCallback& callback) = 0; | 231 const gdata::GetDataCallback& callback) = 0; |
| 228 }; | 232 }; |
| 229 | 233 |
| 230 } // namespace gdata | 234 } // namespace drive |
| 231 | 235 |
| 232 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SERVICE_INTERFACE_H_ | 236 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SERVICE_INTERFACE_H_ |
| OLD | NEW |