diff options
author | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 09:05:31 +0000 |
---|---|---|
committer | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 09:05:31 +0000 |
commit | 7c1f07494234440b5adf2d77d83821c158a981d3 (patch) | |
tree | 3d39bbbaa31892cc58a3bfe4993f210c0826a297 /google_apis | |
parent | 0897da30429e117156f6c35a44c2d9f70a72efaa (diff) | |
download | chromium_src-7c1f07494234440b5adf2d77d83821c158a981d3.zip chromium_src-7c1f07494234440b5adf2d77d83821c158a981d3.tar.gz chromium_src-7c1f07494234440b5adf2d77d83821c158a981d3.tar.bz2 |
[Drive] Use ETag on Drive API file deletion.
BUG=240165
Review URL: https://codereview.chromium.org/102613005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/drive/drive_api_requests.cc | 7 | ||||
-rw-r--r-- | google_apis/drive/drive_api_requests.h | 3 | ||||
-rw-r--r-- | google_apis/drive/drive_api_requests_unittest.cc | 3 |
3 files changed, 12 insertions, 1 deletions
diff --git a/google_apis/drive/drive_api_requests.cc b/google_apis/drive/drive_api_requests.cc index b524e6e..f0960e6 100644 --- a/google_apis/drive/drive_api_requests.cc +++ b/google_apis/drive/drive_api_requests.cc @@ -392,6 +392,13 @@ GURL FilesDeleteRequest::GetURL() const { return url_generator_.GetFilesDeleteUrl(file_id_); } +std::vector<std::string> FilesDeleteRequest::GetExtraRequestHeaders() const { + std::vector<std::string> headers( + EntryActionRequest::GetExtraRequestHeaders()); + headers.push_back(util::GenerateIfMatchHeader(etag_)); + return headers; +} + //============================ FilesTrashRequest ============================= FilesTrashRequest::FilesTrashRequest( diff --git a/google_apis/drive/drive_api_requests.h b/google_apis/drive/drive_api_requests.h index 0e3e793..6f10aa6 100644 --- a/google_apis/drive/drive_api_requests.h +++ b/google_apis/drive/drive_api_requests.h @@ -341,15 +341,18 @@ class FilesDeleteRequest : public EntryActionRequest { // Required parameter. const std::string& file_id() const { return file_id_; } void set_file_id(const std::string& file_id) { file_id_ = file_id; } + void set_etag(const std::string& etag) { etag_ = etag; } protected: // Overridden from UrlFetchRequestBase. virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; virtual GURL GetURL() const OVERRIDE; + virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; private: const DriveApiUrlGenerator url_generator_; std::string file_id_; + std::string etag_; DISALLOW_COPY_AND_ASSIGN(FilesDeleteRequest); }; diff --git a/google_apis/drive/drive_api_requests_unittest.cc b/google_apis/drive/drive_api_requests_unittest.cc index ecdefb5..466240c 100644 --- a/google_apis/drive/drive_api_requests_unittest.cc +++ b/google_apis/drive/drive_api_requests_unittest.cc @@ -199,7 +199,6 @@ class DriveApiRequestsTest : public testing::Test { return response.PassAs<net::test_server::HttpResponse>(); } - // Returns PRECONDITION_FAILED response for ETag mismatching with error JSON // content specified by |expected_precondition_failed_file_path_|. // To use this method, it is necessary to set the variable to the appropriate @@ -797,12 +796,14 @@ TEST_F(DriveApiRequestsTest, FilesDeleteRequest) { test_util::CreateQuitCallback( &run_loop, test_util::CreateCopyResultCallback(&error))); request->set_file_id("resource_id"); + request->set_etag(kTestETag); request_sender_->StartRequestWithRetry(request); run_loop.Run(); } EXPECT_EQ(HTTP_NO_CONTENT, error); EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); + EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); EXPECT_FALSE(http_request_.has_content); } |