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