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_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_OPERATIONS_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_OPERATIONS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_OPERATIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 96 |
97 // This class performs the operation for downloading of a given document/file. | 97 // This class performs the operation for downloading of a given document/file. |
98 class DownloadFileOperation : public UrlFetchOperationBase { | 98 class DownloadFileOperation : public UrlFetchOperationBase { |
99 public: | 99 public: |
100 DownloadFileOperation( | 100 DownloadFileOperation( |
101 OperationRegistry* registry, | 101 OperationRegistry* registry, |
102 const DownloadActionCallback& download_action_callback, | 102 const DownloadActionCallback& download_action_callback, |
103 const GetContentCallback& get_content_callback, | 103 const GetContentCallback& get_content_callback, |
104 const GURL& document_url, | 104 const GURL& document_url, |
105 const FilePath& virtual_path, | 105 const FilePath& virtual_path, |
106 const FilePath& output_file_path); | 106 const FilePath& output_file_path, |
107 const std::string& etag); | |
107 virtual ~DownloadFileOperation(); | 108 virtual ~DownloadFileOperation(); |
108 | 109 |
109 protected: | 110 protected: |
110 // Overridden from UrlFetchOperationBase. | 111 // Overridden from UrlFetchOperationBase. |
111 virtual GURL GetURL() const OVERRIDE; | 112 virtual GURL GetURL() const OVERRIDE; |
112 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 113 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
113 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | 114 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; |
115 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | |
114 | 116 |
115 // Overridden from net::URLFetcherDelegate. | 117 // Overridden from net::URLFetcherDelegate. |
116 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, | 118 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, |
117 int64 current, int64 total) OVERRIDE; | 119 int64 current, int64 total) OVERRIDE; |
118 virtual bool ShouldSendDownloadData() OVERRIDE; | 120 virtual bool ShouldSendDownloadData() OVERRIDE; |
119 virtual void OnURLFetchDownloadData( | 121 virtual void OnURLFetchDownloadData( |
120 const net::URLFetcher* source, | 122 const net::URLFetcher* source, |
121 scoped_ptr<std::string> download_data) OVERRIDE; | 123 scoped_ptr<std::string> download_data) OVERRIDE; |
122 | 124 |
123 private: | 125 private: |
124 DownloadActionCallback download_action_callback_; | 126 DownloadActionCallback download_action_callback_; |
125 GetContentCallback get_content_callback_; | 127 GetContentCallback get_content_callback_; |
126 GURL document_url_; | 128 GURL document_url_; |
129 std::string etag_; | |
127 | 130 |
128 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); | 131 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); |
129 }; | 132 }; |
130 | 133 |
131 //=========================== DeleteDocumentOperation ========================== | 134 //=========================== DeleteDocumentOperation ========================== |
132 | 135 |
133 // This class performs the operation for deleting a document. | 136 // This class performs the operation for deleting a document. |
134 class DeleteDocumentOperation : public EntryActionOperation { | 137 class DeleteDocumentOperation : public EntryActionOperation { |
135 public: | 138 public: |
136 DeleteDocumentOperation(OperationRegistry* registry, | 139 DeleteDocumentOperation(OperationRegistry* registry, |
137 const EntryActionCallback& callback, | 140 const EntryActionCallback& callback, |
138 const GURL& document_url); | 141 const GURL& document_url, |
142 const std::string& etag); | |
139 virtual ~DeleteDocumentOperation(); | 143 virtual ~DeleteDocumentOperation(); |
140 | 144 |
141 protected: | 145 protected: |
142 // Overridden from UrlFetchOperationBase. | 146 // Overridden from UrlFetchOperationBase. |
143 virtual GURL GetURL() const OVERRIDE; | 147 virtual GURL GetURL() const OVERRIDE; |
144 | 148 |
145 // Overridden from EntryActionOperation. | 149 // Overridden from EntryActionOperation. |
146 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 150 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
147 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 151 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
148 | 152 |
149 private: | 153 private: |
154 std::string etag_; | |
155 | |
150 DISALLOW_COPY_AND_ASSIGN(DeleteDocumentOperation); | 156 DISALLOW_COPY_AND_ASSIGN(DeleteDocumentOperation); |
151 }; | 157 }; |
152 | 158 |
153 //========================== CreateDirectoryOperation ========================== | 159 //========================== CreateDirectoryOperation ========================== |
154 | 160 |
155 // This class performs the operation for creating a directory. | 161 // This class performs the operation for creating a directory. |
156 class CreateDirectoryOperation : public GetDataOperation { | 162 class CreateDirectoryOperation : public GetDataOperation { |
157 public: | 163 public: |
158 // Empty |parent_content_url| will create the directory in the root folder. | 164 // Empty |parent_content_url| will create the directory in the root folder. |
159 CreateDirectoryOperation(OperationRegistry* registry, | 165 CreateDirectoryOperation(OperationRegistry* registry, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 }; | 326 }; |
321 | 327 |
322 //=========================== InitiateUploadOperation ========================== | 328 //=========================== InitiateUploadOperation ========================== |
323 | 329 |
324 // Struct for passing params needed for DriveServiceInterface::InitiateUpload() | 330 // Struct for passing params needed for DriveServiceInterface::InitiateUpload() |
325 // calls. | 331 // calls. |
326 // | 332 // |
327 // When uploading a new file (UPLOAD_NEW_FILE): | 333 // When uploading a new file (UPLOAD_NEW_FILE): |
328 // - |title| should be set. | 334 // - |title| should be set. |
329 // - |upload_location| should be the upload_url() of the parent directory. | 335 // - |upload_location| should be the upload_url() of the parent directory. |
336 // - |etag| should be empty. | |
330 // | 337 // |
331 // When updating an existing file (UPLOAD_EXISTING_FILE): | 338 // When updating an existing file (UPLOAD_EXISTING_FILE): |
332 // - |title| should be empty | 339 // - |title| should be empty. |
333 // - |upload_location| should be the upload_url() of the existing file. | 340 // - |upload_location| should be the upload_url() of the existing file. |
334 struct InitiateUploadParams { | 341 struct InitiateUploadParams { |
335 InitiateUploadParams(UploadMode upload_mode, | 342 InitiateUploadParams(UploadMode upload_mode, |
336 const std::string& title, | 343 const std::string& title, |
337 const std::string& content_type, | 344 const std::string& content_type, |
338 int64 content_length, | 345 int64 content_length, |
339 const GURL& upload_location, | 346 const GURL& upload_location, |
340 const FilePath& virtual_path); | 347 const FilePath& virtual_path, |
348 const std::string& etag); | |
341 ~InitiateUploadParams(); | 349 ~InitiateUploadParams(); |
342 | 350 |
343 UploadMode upload_mode; | 351 UploadMode upload_mode; |
344 std::string title; | 352 std::string title; |
345 std::string content_type; | 353 std::string content_type; |
346 int64 content_length; | 354 int64 content_length; |
347 GURL upload_location; | 355 GURL upload_location; |
348 const FilePath& virtual_path; | 356 FilePath virtual_path; |
kochi
2012/10/16 05:04:58
Why unconst for virtual_path?
tzik
2012/10/16 05:48:05
Just to keep it consistent with other place in thi
kochi
2012/10/16 06:31:21
Okay, could you do this in a separate CL?
tzik
2012/10/16 06:46:18
OK, reverted.
| |
357 const std::string etag; | |
tzik
2012/10/16 06:46:18
This const looks not consistent with others. I'll
| |
349 }; | 358 }; |
350 | 359 |
351 // Callback type for DocumentServiceInterface::InitiateUpload. | 360 // Callback type for DocumentServiceInterface::InitiateUpload. |
352 typedef base::Callback<void(GDataErrorCode error, | 361 typedef base::Callback<void(GDataErrorCode error, |
353 const GURL& upload_url)> InitiateUploadCallback; | 362 const GURL& upload_url)> InitiateUploadCallback; |
354 | 363 |
355 // This class performs the operation for initiating the upload of a file. | 364 // This class performs the operation for initiating the upload of a file. |
356 class InitiateUploadOperation : public UrlFetchOperationBase { | 365 class InitiateUploadOperation : public UrlFetchOperationBase { |
357 public: | 366 public: |
358 InitiateUploadOperation(OperationRegistry* registry, | 367 InitiateUploadOperation(OperationRegistry* registry, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 UploadMode upload_mode; // Mode of the upload. | 421 UploadMode upload_mode; // Mode of the upload. |
413 int64 start_range; // Start of range of contents currently stored in |buf|. | 422 int64 start_range; // Start of range of contents currently stored in |buf|. |
414 int64 end_range; // End of range of contents currently stored in |buf|. | 423 int64 end_range; // End of range of contents currently stored in |buf|. |
415 int64 content_length; // File content-Length. | 424 int64 content_length; // File content-Length. |
416 std::string content_type; // Content-Type of file. | 425 std::string content_type; // Content-Type of file. |
417 scoped_refptr<net::IOBuffer> buf; // Holds current content to be uploaded. | 426 scoped_refptr<net::IOBuffer> buf; // Holds current content to be uploaded. |
418 GURL upload_location; // Url of where to upload the file to. | 427 GURL upload_location; // Url of where to upload the file to. |
419 // Virtual GData path of the file seen in the UI. Not necessary for | 428 // Virtual GData path of the file seen in the UI. Not necessary for |
420 // resuming an upload, but used for adding an entry to OperationRegistry. | 429 // resuming an upload, but used for adding an entry to OperationRegistry. |
421 FilePath virtual_path; | 430 FilePath virtual_path; |
431 std::string etag; | |
422 }; | 432 }; |
423 | 433 |
424 // Callback type for DocumentServiceInterface::ResumeUpload. | 434 // Callback type for DocumentServiceInterface::ResumeUpload. |
425 typedef base::Callback<void( | 435 typedef base::Callback<void( |
426 const ResumeUploadResponse& response, | 436 const ResumeUploadResponse& response, |
427 scoped_ptr<gdata::DocumentEntry> new_entry)> ResumeUploadCallback; | 437 scoped_ptr<gdata::DocumentEntry> new_entry)> ResumeUploadCallback; |
428 | 438 |
429 // This class performs the operation for resuming the upload of a file. | 439 // This class performs the operation for resuming the upload of a file. |
430 class ResumeUploadOperation : public UrlFetchOperationBase { | 440 class ResumeUploadOperation : public UrlFetchOperationBase { |
431 public: | 441 public: |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 | 551 |
542 // Callback to which the photo data is passed. | 552 // Callback to which the photo data is passed. |
543 GetContentCallback callback_; | 553 GetContentCallback callback_; |
544 | 554 |
545 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); | 555 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); |
546 }; | 556 }; |
547 | 557 |
548 } // namespace gdata | 558 } // namespace gdata |
549 | 559 |
550 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_OPERATIONS_H_ | 560 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_OPERATIONS_H_ |
OLD | NEW |