Index: chrome/browser/google_apis/gdata_operations.cc |
diff --git a/chrome/browser/google_apis/gdata_operations.cc b/chrome/browser/google_apis/gdata_operations.cc |
index 046671d9f4d0ca177101c14a72eb53ea4398c60b..e21055875d6b319ae9f59adf061ffbb703b32e27 100644 |
--- a/chrome/browser/google_apis/gdata_operations.cc |
+++ b/chrome/browser/google_apis/gdata_operations.cc |
@@ -178,13 +178,15 @@ InitiateUploadParams::InitiateUploadParams( |
const std::string& content_type, |
int64 content_length, |
const GURL& upload_location, |
- const FilePath& virtual_path) |
+ const FilePath& virtual_path, |
+ const std::string& etag) |
: upload_mode(upload_mode), |
title(title), |
content_type(content_type), |
content_length(content_length), |
upload_location(upload_location), |
- virtual_path(virtual_path) { |
+ virtual_path(virtual_path), |
+ etag(etag) { |
} |
InitiateUploadParams::~InitiateUploadParams() { |
@@ -292,13 +294,15 @@ DownloadFileOperation::DownloadFileOperation( |
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) |
: UrlFetchOperationBase(registry, |
OPERATION_DOWNLOAD, |
virtual_path), |
download_action_callback_(download_action_callback), |
get_content_callback_(get_content_callback), |
- document_url_(document_url) { |
+ document_url_(document_url), |
+ etag_(etag) { |
// Make sure we download the content into a temp file. |
if (output_file_path.empty()) |
save_temp_file_ = true; |
@@ -351,13 +355,22 @@ void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { |
download_action_callback_.Run(code, document_url_, FilePath()); |
} |
+std::vector<std::string> DownloadFileOperation::GetExtraRequestHeaders() const { |
+ std::vector<std::string> headers; |
+ if (!etag_.empty()) |
+ headers.push_back(base::StringPrintf(kIfMatchHeaderFormat, etag_.c_str())); |
+ return headers; |
+} |
+ |
//=========================== DeleteDocumentOperation ========================== |
DeleteDocumentOperation::DeleteDocumentOperation( |
OperationRegistry* registry, |
const EntryActionCallback& callback, |
- const GURL& document_url) |
- : EntryActionOperation(registry, callback, document_url) { |
+ const GURL& document_url, |
+ const std::string& etag) |
+ : EntryActionOperation(registry, callback, document_url), |
+ etag_(etag) { |
} |
DeleteDocumentOperation::~DeleteDocumentOperation() {} |
@@ -373,7 +386,10 @@ URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { |
std::vector<std::string> |
DeleteDocumentOperation::GetExtraRequestHeaders() const { |
std::vector<std::string> headers; |
- headers.push_back(kIfMatchAllHeader); |
+ if (etag_.empty()) |
+ headers.push_back(kIfMatchAllHeader); |
+ else |
+ headers.push_back(base::StringPrintf(kIfMatchHeaderFormat, etag_.c_str())); |
return headers; |
} |
@@ -753,8 +769,14 @@ InitiateUploadOperation::GetExtraRequestHeaders() const { |
headers.push_back( |
kUploadContentLength + base::Int64ToString(params_.content_length)); |
- if (params_.upload_mode == UPLOAD_EXISTING_FILE) |
- headers.push_back("If-Match: *"); |
+ if (params_.upload_mode == UPLOAD_EXISTING_FILE) { |
+ if (params_.etag.empty()) { |
+ headers.push_back(kIfMatchAllHeader); |
kochi
2012/10/16 05:04:58
Even when uploading existing file, is there a poss
tzik
2012/10/16 05:48:05
I think we can, since existing code do so.
Maybe,
|
+ } else { |
+ headers.push_back( |
+ base::StringPrintf(kIfMatchHeaderFormat, params_.etag.c_str())); |
+ } |
+ } |
return headers; |
} |
@@ -895,11 +917,20 @@ URLFetcher::RequestType ResumeUploadOperation::GetRequestType() const { |
} |
std::vector<std::string> ResumeUploadOperation::GetExtraRequestHeaders() const { |
+ std::vector<std::string> headers; |
+ |
+ if (params_.etag.empty()) { |
+ headers.push_back(kIfMatchAllHeader); |
+ } else { |
+ headers.push_back( |
+ base::StringPrintf(kIfMatchHeaderFormat, params_.etag.c_str())); |
+ } |
+ |
if (params_.content_length == 0) { |
// For uploading an empty document, just PUT an empty content. |
DCHECK_EQ(params_.start_range, 0); |
DCHECK_EQ(params_.end_range, -1); |
- return std::vector<std::string>(); |
+ return headers; |
} |
// The header looks like |
@@ -911,7 +942,6 @@ std::vector<std::string> ResumeUploadOperation::GetExtraRequestHeaders() const { |
DCHECK_GE(params_.end_range, 0); |
DCHECK_GE(params_.content_length, -1); |
- std::vector<std::string> headers; |
headers.push_back( |
std::string(kUploadContentRange) + |
base::Int64ToString(params_.start_range) + "-" + |