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_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/google_apis/base_operations.h" | 11 #include "chrome/browser/google_apis/base_operations.h" |
12 #include "chrome/browser/google_apis/drive_upload_mode.h" | 12 #include "chrome/browser/google_apis/drive_upload_mode.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 | 14 |
15 namespace google_apis { | 15 namespace google_apis { |
16 | 16 |
17 class GDataEntry; | 17 class GDataWapiUrlGenerator; |
18 class DocumentEntry; | 18 class DocumentEntry; |
19 | 19 |
20 //============================ GetDocumentsOperation =========================== | 20 //============================ GetDocumentsOperation =========================== |
21 | 21 |
22 // This class performs the operation for fetching a document list. | 22 // This class performs the operation for fetching a document list. |
23 class GetDocumentsOperation : public GetDataOperation { | 23 class GetDocumentsOperation : public GetDataOperation { |
24 public: | 24 public: |
25 // |start_changestamp| specifies the starting point of change list or 0 if | 25 // |start_changestamp| specifies the starting point of change list or 0 if |
26 // all changes are necessary. | 26 // all changes are necessary. |
27 // If |shared_with_me| is true, it searches for the files shared to the user, | 27 // If |shared_with_me| is true, it searches for the files shared to the user, |
28 // otherwise searches for the files owned by the user. | 28 // otherwise searches for the files owned by the user. |
29 // |url| specifies URL for documents feed fetching operation. If empty URL is | 29 // |url| specifies URL for documents feed fetching operation. If empty URL is |
30 // passed, the default URL is used and returns the first page of the result. | 30 // passed, the default URL is used and returns the first page of the result. |
31 // When non-first page result is requested, |url| should be specified. | 31 // When non-first page result is requested, |url| should be specified. |
32 GetDocumentsOperation(OperationRegistry* registry, | 32 GetDocumentsOperation(OperationRegistry* registry, |
| 33 const GDataWapiUrlGenerator& url_generator, |
33 const GURL& url, | 34 const GURL& url, |
34 int start_changestamp, | 35 int start_changestamp, |
35 const std::string& search_string, | 36 const std::string& search_string, |
36 bool shared_with_me, | 37 bool shared_with_me, |
37 const std::string& directory_resource_id, | 38 const std::string& directory_resource_id, |
38 const GetDataCallback& callback); | 39 const GetDataCallback& callback); |
39 virtual ~GetDocumentsOperation(); | 40 virtual ~GetDocumentsOperation(); |
40 | 41 |
41 protected: | 42 protected: |
42 // Overridden from GetDataOperation. | 43 // Overridden from GetDataOperation. |
43 virtual GURL GetURL() const OVERRIDE; | 44 virtual GURL GetURL() const OVERRIDE; |
44 | 45 |
45 private: | 46 private: |
| 47 const GDataWapiUrlGenerator& url_generator_; |
46 GURL override_url_; | 48 GURL override_url_; |
47 int start_changestamp_; | 49 int start_changestamp_; |
48 std::string search_string_; | 50 std::string search_string_; |
49 bool shared_with_me_; | 51 bool shared_with_me_; |
50 std::string directory_resource_id_; | 52 std::string directory_resource_id_; |
51 | 53 |
52 DISALLOW_COPY_AND_ASSIGN(GetDocumentsOperation); | 54 DISALLOW_COPY_AND_ASSIGN(GetDocumentsOperation); |
53 }; | 55 }; |
54 | 56 |
55 //========================= GetDocumentEntryOperation ========================== | 57 //========================= GetDocumentEntryOperation ========================== |
56 | 58 |
57 // This class performs the operation for fetching a single document entry. | 59 // This class performs the operation for fetching a single document entry. |
58 class GetDocumentEntryOperation : public GetDataOperation { | 60 class GetDocumentEntryOperation : public GetDataOperation { |
59 public: | 61 public: |
60 GetDocumentEntryOperation(OperationRegistry* registry, | 62 GetDocumentEntryOperation(OperationRegistry* registry, |
| 63 const GDataWapiUrlGenerator& url_generator, |
61 const std::string& resource_id, | 64 const std::string& resource_id, |
62 const GetDataCallback& callback); | 65 const GetDataCallback& callback); |
63 virtual ~GetDocumentEntryOperation(); | 66 virtual ~GetDocumentEntryOperation(); |
64 | 67 |
65 protected: | 68 protected: |
66 // Overridden from GetGdataOperation. | 69 // Overridden from GetGdataOperation. |
67 virtual GURL GetURL() const OVERRIDE; | 70 virtual GURL GetURL() const OVERRIDE; |
68 | 71 |
69 private: | 72 private: |
| 73 const GDataWapiUrlGenerator& url_generator_; |
70 // Resource id of the requested entry. | 74 // Resource id of the requested entry. |
71 std::string resource_id_; | 75 std::string resource_id_; |
72 | 76 |
73 DISALLOW_COPY_AND_ASSIGN(GetDocumentEntryOperation); | 77 DISALLOW_COPY_AND_ASSIGN(GetDocumentEntryOperation); |
74 }; | 78 }; |
75 | 79 |
76 //========================= GetAccountMetadataOperation ======================== | 80 //========================= GetAccountMetadataOperation ======================== |
77 | 81 |
78 // This class performs the operation for fetching account metadata. | 82 // This class performs the operation for fetching account metadata. |
79 class GetAccountMetadataOperation : public GetDataOperation { | 83 class GetAccountMetadataOperation : public GetDataOperation { |
80 public: | 84 public: |
81 GetAccountMetadataOperation(OperationRegistry* registry, | 85 GetAccountMetadataOperation(OperationRegistry* registry, |
| 86 const GDataWapiUrlGenerator& url_generator, |
82 const GetDataCallback& callback); | 87 const GetDataCallback& callback); |
83 virtual ~GetAccountMetadataOperation(); | 88 virtual ~GetAccountMetadataOperation(); |
84 | 89 |
85 protected: | 90 protected: |
86 // Overridden from GetDataOperation. | 91 // Overridden from GetDataOperation. |
87 virtual GURL GetURL() const OVERRIDE; | 92 virtual GURL GetURL() const OVERRIDE; |
88 | 93 |
89 private: | 94 private: |
| 95 const GDataWapiUrlGenerator& url_generator_; |
90 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); | 96 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); |
91 }; | 97 }; |
92 | 98 |
93 //============================ DownloadFileOperation =========================== | 99 //============================ DownloadFileOperation =========================== |
94 | 100 |
95 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface | 101 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface |
96 // calls. | 102 // calls. |
97 typedef base::Callback<void(GDataErrorCode error, | 103 typedef base::Callback<void(GDataErrorCode error, |
98 const GURL& content_url, | 104 const GURL& content_url, |
99 const FilePath& temp_file)> DownloadActionCallback; | 105 const FilePath& temp_file)> DownloadActionCallback; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 DISALLOW_COPY_AND_ASSIGN(DeleteDocumentOperation); | 160 DISALLOW_COPY_AND_ASSIGN(DeleteDocumentOperation); |
155 }; | 161 }; |
156 | 162 |
157 //========================== CreateDirectoryOperation ========================== | 163 //========================== CreateDirectoryOperation ========================== |
158 | 164 |
159 // This class performs the operation for creating a directory. | 165 // This class performs the operation for creating a directory. |
160 class CreateDirectoryOperation : public GetDataOperation { | 166 class CreateDirectoryOperation : public GetDataOperation { |
161 public: | 167 public: |
162 // Empty |parent_content_url| will create the directory in the root folder. | 168 // Empty |parent_content_url| will create the directory in the root folder. |
163 CreateDirectoryOperation(OperationRegistry* registry, | 169 CreateDirectoryOperation(OperationRegistry* registry, |
| 170 const GDataWapiUrlGenerator& url_generator, |
164 const GetDataCallback& callback, | 171 const GetDataCallback& callback, |
165 const GURL& parent_content_url, | 172 const GURL& parent_content_url, |
166 const FilePath::StringType& directory_name); | 173 const FilePath::StringType& directory_name); |
167 virtual ~CreateDirectoryOperation(); | 174 virtual ~CreateDirectoryOperation(); |
168 | 175 |
169 protected: | 176 protected: |
170 // Overridden from UrlFetchOperationBase. | 177 // Overridden from UrlFetchOperationBase. |
171 virtual GURL GetURL() const OVERRIDE; | 178 virtual GURL GetURL() const OVERRIDE; |
172 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 179 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
173 | 180 |
174 // Overridden from UrlFetchOperationBase. | 181 // Overridden from UrlFetchOperationBase. |
175 virtual bool GetContentData(std::string* upload_content_type, | 182 virtual bool GetContentData(std::string* upload_content_type, |
176 std::string* upload_content) OVERRIDE; | 183 std::string* upload_content) OVERRIDE; |
177 | 184 |
178 private: | 185 private: |
| 186 const GDataWapiUrlGenerator& url_generator_; |
179 GURL parent_content_url_; | 187 GURL parent_content_url_; |
180 FilePath::StringType directory_name_; | 188 FilePath::StringType directory_name_; |
181 | 189 |
182 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation); | 190 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation); |
183 }; | 191 }; |
184 | 192 |
185 //============================ CopyDocumentOperation =========================== | 193 //============================ CopyDocumentOperation =========================== |
186 | 194 |
187 // This class performs the operation for making a copy of a document. | 195 // This class performs the operation for making a copy of a document. |
188 class CopyDocumentOperation : public GetDataOperation { | 196 class CopyDocumentOperation : public GetDataOperation { |
189 public: | 197 public: |
190 CopyDocumentOperation(OperationRegistry* registry, | 198 CopyDocumentOperation(OperationRegistry* registry, |
| 199 const GDataWapiUrlGenerator& url_generator, |
191 const GetDataCallback& callback, | 200 const GetDataCallback& callback, |
192 const std::string& resource_id, | 201 const std::string& resource_id, |
193 const FilePath::StringType& new_name); | 202 const FilePath::StringType& new_name); |
194 virtual ~CopyDocumentOperation(); | 203 virtual ~CopyDocumentOperation(); |
195 | 204 |
196 protected: | 205 protected: |
197 // Overridden from GetDataOperation. | 206 // Overridden from GetDataOperation. |
198 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 207 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
199 | 208 |
200 // Overridden from UrlFetchOperationBase. | 209 // Overridden from UrlFetchOperationBase. |
201 virtual GURL GetURL() const OVERRIDE; | 210 virtual GURL GetURL() const OVERRIDE; |
202 virtual bool GetContentData(std::string* upload_content_type, | 211 virtual bool GetContentData(std::string* upload_content_type, |
203 std::string* upload_content) OVERRIDE; | 212 std::string* upload_content) OVERRIDE; |
204 | 213 |
205 private: | 214 private: |
| 215 const GDataWapiUrlGenerator& url_generator_; |
206 std::string resource_id_; | 216 std::string resource_id_; |
207 FilePath::StringType new_name_; | 217 FilePath::StringType new_name_; |
208 | 218 |
209 DISALLOW_COPY_AND_ASSIGN(CopyDocumentOperation); | 219 DISALLOW_COPY_AND_ASSIGN(CopyDocumentOperation); |
210 }; | 220 }; |
211 | 221 |
212 //=========================== RenameResourceOperation ========================== | 222 //=========================== RenameResourceOperation ========================== |
213 | 223 |
214 // This class performs the operation for renaming a document/file/directory. | 224 // This class performs the operation for renaming a document/file/directory. |
215 class RenameResourceOperation : public EntryActionOperation { | 225 class RenameResourceOperation : public EntryActionOperation { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppsOperation); | 282 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppsOperation); |
273 }; | 283 }; |
274 | 284 |
275 //======================= AddResourceToDirectoryOperation ====================== | 285 //======================= AddResourceToDirectoryOperation ====================== |
276 | 286 |
277 // This class performs the operation for adding a document/file/directory | 287 // This class performs the operation for adding a document/file/directory |
278 // to a directory. | 288 // to a directory. |
279 class AddResourceToDirectoryOperation : public EntryActionOperation { | 289 class AddResourceToDirectoryOperation : public EntryActionOperation { |
280 public: | 290 public: |
281 AddResourceToDirectoryOperation(OperationRegistry* registry, | 291 AddResourceToDirectoryOperation(OperationRegistry* registry, |
| 292 const GDataWapiUrlGenerator& url_generator, |
282 const EntryActionCallback& callback, | 293 const EntryActionCallback& callback, |
283 const GURL& parent_content_url, | 294 const GURL& parent_content_url, |
284 const GURL& document_url); | 295 const GURL& document_url); |
285 virtual ~AddResourceToDirectoryOperation(); | 296 virtual ~AddResourceToDirectoryOperation(); |
286 | 297 |
287 protected: | 298 protected: |
288 // Overridden from UrlFetchOperationBase. | 299 // Overridden from UrlFetchOperationBase. |
289 virtual GURL GetURL() const OVERRIDE; | 300 virtual GURL GetURL() const OVERRIDE; |
290 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 301 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
291 virtual bool GetContentData(std::string* upload_content_type, | 302 virtual bool GetContentData(std::string* upload_content_type, |
292 std::string* upload_content) OVERRIDE; | 303 std::string* upload_content) OVERRIDE; |
293 | 304 |
294 private: | 305 private: |
| 306 const GDataWapiUrlGenerator& url_generator_; |
295 GURL parent_content_url_; | 307 GURL parent_content_url_; |
296 | 308 |
297 DISALLOW_COPY_AND_ASSIGN(AddResourceToDirectoryOperation); | 309 DISALLOW_COPY_AND_ASSIGN(AddResourceToDirectoryOperation); |
298 }; | 310 }; |
299 | 311 |
300 //==================== RemoveResourceFromDirectoryOperation ==================== | 312 //==================== RemoveResourceFromDirectoryOperation ==================== |
301 | 313 |
302 // This class performs the operation for adding a document/file/directory | 314 // This class performs the operation for adding a document/file/directory |
303 // from a directory. | 315 // from a directory. |
304 class RemoveResourceFromDirectoryOperation : public EntryActionOperation { | 316 class RemoveResourceFromDirectoryOperation : public EntryActionOperation { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 ResumeUploadCallback callback_; | 472 ResumeUploadCallback callback_; |
461 ResumeUploadParams params_; | 473 ResumeUploadParams params_; |
462 bool last_chunk_completed_; | 474 bool last_chunk_completed_; |
463 | 475 |
464 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); | 476 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); |
465 }; | 477 }; |
466 | 478 |
467 } // namespace google_apis | 479 } // namespace google_apis |
468 | 480 |
469 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 481 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
OLD | NEW |