| 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_DRIVE_API_REQUESTS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ |
| 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 std::string* upload_content) OVERRIDE; | 192 std::string* upload_content) OVERRIDE; |
| 193 | 193 |
| 194 private: | 194 private: |
| 195 const DriveApiUrlGenerator url_generator_; | 195 const DriveApiUrlGenerator url_generator_; |
| 196 const std::string parent_resource_id_; | 196 const std::string parent_resource_id_; |
| 197 const std::string directory_title_; | 197 const std::string directory_title_; |
| 198 | 198 |
| 199 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryRequest); | 199 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryRequest); |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 //=========================== RenameResourceRequest ========================== | |
| 203 | |
| 204 // This class performs the request for renaming a document/file/directory. | |
| 205 class RenameResourceRequest : public EntryActionRequest { | |
| 206 public: | |
| 207 // |callback| must not be null. | |
| 208 RenameResourceRequest(RequestSender* sender, | |
| 209 const DriveApiUrlGenerator& url_generator, | |
| 210 const std::string& resource_id, | |
| 211 const std::string& new_title, | |
| 212 const EntryActionCallback& callback); | |
| 213 virtual ~RenameResourceRequest(); | |
| 214 | |
| 215 protected: | |
| 216 // UrlFetchRequestBase overrides. | |
| 217 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | |
| 218 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | |
| 219 virtual GURL GetURL() const OVERRIDE; | |
| 220 virtual bool GetContentData(std::string* upload_content_type, | |
| 221 std::string* upload_content) OVERRIDE; | |
| 222 | |
| 223 private: | |
| 224 const DriveApiUrlGenerator url_generator_; | |
| 225 | |
| 226 const std::string resource_id_; | |
| 227 const std::string new_title_; | |
| 228 | |
| 229 DISALLOW_COPY_AND_ASSIGN(RenameResourceRequest); | |
| 230 }; | |
| 231 | |
| 232 //=========================== TouchResourceRequest =========================== | 202 //=========================== TouchResourceRequest =========================== |
| 233 | 203 |
| 234 // This class performs the request to touch a document/file/directory. | 204 // This class performs the request to touch a document/file/directory. |
| 235 // This uses "files.patch" of Drive API v2 rather than "files.touch". See also: | 205 // This uses "files.patch" of Drive API v2 rather than "files.touch". See also: |
| 236 // https://developers.google.com/drive/v2/reference/files/patch, and | 206 // https://developers.google.com/drive/v2/reference/files/patch, and |
| 237 // https://developers.google.com/drive/v2/reference/files/touch | 207 // https://developers.google.com/drive/v2/reference/files/touch |
| 238 class TouchResourceRequest : public GetDataRequest { | 208 class TouchResourceRequest : public GetDataRequest { |
| 239 public: | 209 public: |
| 240 // |callback| must not be null. | 210 // |callback| must not be null. |
| 241 TouchResourceRequest(RequestSender* sender, | 211 TouchResourceRequest(RequestSender* sender, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 std::string* upload_content) OVERRIDE; | 264 std::string* upload_content) OVERRIDE; |
| 295 private: | 265 private: |
| 296 const DriveApiUrlGenerator url_generator_; | 266 const DriveApiUrlGenerator url_generator_; |
| 297 const std::string resource_id_; | 267 const std::string resource_id_; |
| 298 const std::string parent_resource_id_; | 268 const std::string parent_resource_id_; |
| 299 const std::string new_title_; | 269 const std::string new_title_; |
| 300 | 270 |
| 301 DISALLOW_COPY_AND_ASSIGN(CopyResourceRequest); | 271 DISALLOW_COPY_AND_ASSIGN(CopyResourceRequest); |
| 302 }; | 272 }; |
| 303 | 273 |
| 274 //=========================== MoveResourceRequest ============================ |
| 275 |
| 276 // This class performs the request for moving a resource. |
| 277 // |
| 278 // Moves the resource with |resource_id| into a directory with |
| 279 // |parent_resource_id| and renames it as |new_title|. |
| 280 // |parent_resource_id| can be empty. In the case, the resource will still be |
| 281 // in the current directory. |
| 282 // |
| 283 // This request uses "Files: patch" request on Drive API v2. See also: |
| 284 // https://developers.google.com/drive/v2/reference/files/patch |
| 285 class MoveResourceRequest : public GetDataRequest { |
| 286 public: |
| 287 // Upon completion, |callback| will be called. |callback| must not be null. |
| 288 MoveResourceRequest(RequestSender* sender, |
| 289 const DriveApiUrlGenerator& url_generator, |
| 290 const std::string& resource_id, |
| 291 const std::string& parent_resource_id, |
| 292 const std::string& new_title, |
| 293 const FileResourceCallback& callback); |
| 294 virtual ~MoveResourceRequest(); |
| 295 |
| 296 protected: |
| 297 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 298 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 299 virtual GURL GetURL() const OVERRIDE; |
| 300 virtual bool GetContentData(std::string* upload_content_type, |
| 301 std::string* upload_content) OVERRIDE; |
| 302 private: |
| 303 const DriveApiUrlGenerator url_generator_; |
| 304 const std::string resource_id_; |
| 305 const std::string parent_resource_id_; |
| 306 const std::string new_title_; |
| 307 |
| 308 DISALLOW_COPY_AND_ASSIGN(MoveResourceRequest); |
| 309 }; |
| 310 |
| 304 //=========================== TrashResourceRequest =========================== | 311 //=========================== TrashResourceRequest =========================== |
| 305 | 312 |
| 306 // This class performs the request for trashing a resource. | 313 // This class performs the request for trashing a resource. |
| 307 // | 314 // |
| 308 // According to the document: | 315 // According to the document: |
| 309 // https://developers.google.com/drive/v2/reference/files/trash | 316 // https://developers.google.com/drive/v2/reference/files/trash |
| 310 // the file resource will be returned from the server, which is not in the | 317 // the file resource will be returned from the server, which is not in the |
| 311 // response from WAPI server. For the transition, we simply ignore the result, | 318 // response from WAPI server. For the transition, we simply ignore the result, |
| 312 // because now we do not handle resources in trash. | 319 // because now we do not handle resources in trash. |
| 313 // Note for the naming: the name "trash" comes from the server's request | 320 // Note for the naming: the name "trash" comes from the server's request |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 const ProgressCallback& progress_callback); | 550 const ProgressCallback& progress_callback); |
| 544 virtual ~DownloadFileRequest(); | 551 virtual ~DownloadFileRequest(); |
| 545 | 552 |
| 546 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); | 553 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); |
| 547 }; | 554 }; |
| 548 | 555 |
| 549 } // namespace drive | 556 } // namespace drive |
| 550 } // namespace google_apis | 557 } // namespace google_apis |
| 551 | 558 |
| 552 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ | 559 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ |
| OLD | NEW |