Chromium Code Reviews| Index: chrome/browser/google_apis/gdata_operations.h |
| diff --git a/chrome/browser/google_apis/gdata_operations.h b/chrome/browser/google_apis/gdata_operations.h |
| index af3262ee442560926c827b1a180ecb3673e8a3db..46eacacb6cef3bd698d76258a64ef24a25cd0ed6 100644 |
| --- a/chrome/browser/google_apis/gdata_operations.h |
| +++ b/chrome/browser/google_apis/gdata_operations.h |
| @@ -97,13 +97,22 @@ typedef base::Callback<void(GDataErrorCode error, |
| // This class performs the operation for downloading of a given document/file. |
| class DownloadFileOperation : public UrlFetchOperationBase { |
| public: |
| + // Downloads a file identified by its |document_url|. |
| + // If |etag| is set, checks if it matches the file before downloading. |
|
satorux1
2012/10/17 03:14:27
If etag does not match, what happens? Please docum
|
| + // The downloaded file will be stored at |output_file_path| location. |
| + // On partial data is received, invokes |get_content_callbac| if not empty. |
| + // Upon completion, invokes |download_action_callback|. |
|
satorux1
2012/10/17 03:14:27
Thank you for improving the comment here!
|
| + // |
| + // Registers the download task to |registry| with OperationProgressStatus |
| + // associated with |virtual_path|. |
| DownloadFileOperation( |
| OperationRegistry* registry, |
| const DownloadActionCallback& download_action_callback, |
| const GetContentCallback& get_content_callback, |
| const GURL& document_url, |
| const FilePath& virtual_path, |
| - const FilePath& output_file_path); |
| + const FilePath& output_file_path, |
| + const std::string& etag); |
| virtual ~DownloadFileOperation(); |
| protected: |
| @@ -111,6 +120,7 @@ class DownloadFileOperation : public UrlFetchOperationBase { |
| virtual GURL GetURL() const OVERRIDE; |
| virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; |
| + virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| // Overridden from net::URLFetcherDelegate. |
| virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, |
| @@ -124,6 +134,7 @@ class DownloadFileOperation : public UrlFetchOperationBase { |
| DownloadActionCallback download_action_callback_; |
| GetContentCallback get_content_callback_; |
| GURL document_url_; |
| + std::string etag_; |
| DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); |
| }; |
| @@ -133,9 +144,15 @@ class DownloadFileOperation : public UrlFetchOperationBase { |
| // This class performs the operation for deleting a document. |
| class DeleteDocumentOperation : public EntryActionOperation { |
| public: |
| + // Deletes a file identified by its |document_url|. |
| + // If |etag| is set, checks if it matches the file before deletion. |
|
satorux1
2012/10/17 03:14:27
If etag does not match, what happens? Please docum
|
| + // Upon completion, invokes |callback|. |
| + // |
| + // Registers the download task to |registry|. |
| DeleteDocumentOperation(OperationRegistry* registry, |
| const EntryActionCallback& callback, |
| - const GURL& document_url); |
| + const GURL& document_url, |
| + const std::string& etag); |
| virtual ~DeleteDocumentOperation(); |
| protected: |
| @@ -147,6 +164,8 @@ class DeleteDocumentOperation : public EntryActionOperation { |
| virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| private: |
| + std::string etag_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(DeleteDocumentOperation); |
| }; |
| @@ -327,17 +346,20 @@ class RemoveResourceFromDirectoryOperation : public EntryActionOperation { |
| // When uploading a new file (UPLOAD_NEW_FILE): |
| // - |title| should be set. |
| // - |upload_location| should be the upload_url() of the parent directory. |
| +// - |etag| should be empty. |
| // |
| // When updating an existing file (UPLOAD_EXISTING_FILE): |
| -// - |title| should be empty |
| +// - |title| should be empty. |
| // - |upload_location| should be the upload_url() of the existing file. |
| +// - |etag| should match the existing file. If it's empty, matching is skipped. |
|
satorux1
2012/10/17 03:14:27
If etag does not match, what happens? Please docum
|
| struct InitiateUploadParams { |
| InitiateUploadParams(UploadMode upload_mode, |
| const std::string& title, |
| const std::string& content_type, |
| int64 content_length, |
| const GURL& upload_location, |
| - const FilePath& virtual_path); |
| + const FilePath& virtual_path, |
| + const std::string& etag); |
| ~InitiateUploadParams(); |
| UploadMode upload_mode; |
| @@ -346,6 +368,7 @@ struct InitiateUploadParams { |
| int64 content_length; |
| GURL upload_location; |
| FilePath virtual_path; |
| + std::string etag; |
| }; |
| // Callback type for DocumentServiceInterface::InitiateUpload. |
| @@ -406,7 +429,8 @@ struct ResumeUploadParams { |
| const std::string& content_type, |
| scoped_refptr<net::IOBuffer> buf, |
| const GURL& upload_location, |
| - const FilePath& virtual_path); |
| + const FilePath& virtual_path, |
| + const std::string& etag); |
| ~ResumeUploadParams(); |
| UploadMode upload_mode; // Mode of the upload. |
| @@ -419,6 +443,8 @@ struct ResumeUploadParams { |
| // Virtual GData path of the file seen in the UI. Not necessary for |
| // resuming an upload, but used for adding an entry to OperationRegistry. |
| FilePath virtual_path; |
| + // ETag matches the file to be overwritten. Matching is skipped if it's empty. |
| + std::string etag; |
| }; |
| // Callback type for DocumentServiceInterface::ResumeUpload. |