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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Overridden from GetDataRequest. | 56 // Overridden from GetDataRequest. |
57 virtual GURL GetURL() const OVERRIDE; | 57 virtual GURL GetURL() const OVERRIDE; |
58 | 58 |
59 private: | 59 private: |
60 const DriveApiUrlGenerator url_generator_; | 60 const DriveApiUrlGenerator url_generator_; |
61 std::string file_id_; | 61 std::string file_id_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest); | 63 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest); |
64 }; | 64 }; |
65 | 65 |
| 66 //============================ FilesInsertRequest ============================= |
| 67 |
| 68 // This class performs the request for creating a resource. |
| 69 // This request is mapped to |
| 70 // https://developers.google.com/drive/v2/reference/files/insert |
| 71 // See also https://developers.google.com/drive/manage-uploads and |
| 72 // https://developers.google.com/drive/folder |
| 73 class FilesInsertRequest : public GetDataRequest { |
| 74 public: |
| 75 FilesInsertRequest(RequestSender* sender, |
| 76 const DriveApiUrlGenerator& url_generator, |
| 77 const FileResourceCallback& callback); |
| 78 virtual ~FilesInsertRequest(); |
| 79 |
| 80 // Optional request body. |
| 81 const std::string& mime_type() const { return mime_type_; } |
| 82 void set_mime_type(const std::string& mime_type) { |
| 83 mime_type_ = mime_type; |
| 84 } |
| 85 |
| 86 const std::vector<std::string>& parents() const { return parents_; } |
| 87 void add_parent(const std::string& parent) { parents_.push_back(parent); } |
| 88 |
| 89 const std::string& title() const { return title_; } |
| 90 void set_title(const std::string& title) { title_ = title; } |
| 91 |
| 92 protected: |
| 93 // Overridden from GetDataRequest. |
| 94 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 95 virtual GURL GetURL() const OVERRIDE; |
| 96 virtual bool GetContentData(std::string* upload_content_type, |
| 97 std::string* upload_content) OVERRIDE; |
| 98 |
| 99 private: |
| 100 const DriveApiUrlGenerator url_generator_; |
| 101 |
| 102 std::string mime_type_; |
| 103 std::vector<std::string> parents_; |
| 104 std::string title_; |
| 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest); |
| 107 }; |
| 108 |
66 //============================== FilesPatchRequest ============================ | 109 //============================== FilesPatchRequest ============================ |
67 | 110 |
68 // This class performs the request for patching file metadata. | 111 // This class performs the request for patching file metadata. |
69 // This request is mapped to | 112 // This request is mapped to |
70 // https://developers.google.com/drive/v2/reference/files/patch | 113 // https://developers.google.com/drive/v2/reference/files/patch |
71 class FilesPatchRequest : public GetDataRequest { | 114 class FilesPatchRequest : public GetDataRequest { |
72 public: | 115 public: |
73 FilesPatchRequest(RequestSender* sender, | 116 FilesPatchRequest(RequestSender* sender, |
74 const DriveApiUrlGenerator& url_generator, | 117 const DriveApiUrlGenerator& url_generator, |
75 const FileResourceCallback& callback); | 118 const FileResourceCallback& callback); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 362 |
320 protected: | 363 protected: |
321 virtual GURL GetURL() const OVERRIDE; | 364 virtual GURL GetURL() const OVERRIDE; |
322 | 365 |
323 private: | 366 private: |
324 const GURL url_; | 367 const GURL url_; |
325 | 368 |
326 DISALLOW_COPY_AND_ASSIGN(ContinueGetFileListRequest); | 369 DISALLOW_COPY_AND_ASSIGN(ContinueGetFileListRequest); |
327 }; | 370 }; |
328 | 371 |
329 //========================== CreateDirectoryRequest ========================== | |
330 | |
331 // This class performs the request for creating a directory. | |
332 class CreateDirectoryRequest : public GetDataRequest { | |
333 public: | |
334 CreateDirectoryRequest(RequestSender* sender, | |
335 const DriveApiUrlGenerator& url_generator, | |
336 const std::string& parent_resource_id, | |
337 const std::string& directory_title, | |
338 const FileResourceCallback& callback); | |
339 virtual ~CreateDirectoryRequest(); | |
340 | |
341 protected: | |
342 // Overridden from GetDataRequest. | |
343 virtual GURL GetURL() const OVERRIDE; | |
344 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | |
345 virtual bool GetContentData(std::string* upload_content_type, | |
346 std::string* upload_content) OVERRIDE; | |
347 | |
348 private: | |
349 const DriveApiUrlGenerator url_generator_; | |
350 const std::string parent_resource_id_; | |
351 const std::string directory_title_; | |
352 | |
353 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryRequest); | |
354 }; | |
355 | |
356 //=========================== TouchResourceRequest =========================== | 372 //=========================== TouchResourceRequest =========================== |
357 | 373 |
358 // This class performs the request to touch a document/file/directory. | 374 // This class performs the request to touch a document/file/directory. |
359 // This uses "files.patch" of Drive API v2 rather than "files.touch". See also: | 375 // This uses "files.patch" of Drive API v2 rather than "files.touch". See also: |
360 // https://developers.google.com/drive/v2/reference/files/patch, and | 376 // https://developers.google.com/drive/v2/reference/files/patch, and |
361 // https://developers.google.com/drive/v2/reference/files/touch | 377 // https://developers.google.com/drive/v2/reference/files/touch |
362 class TouchResourceRequest : public GetDataRequest { | 378 class TouchResourceRequest : public GetDataRequest { |
363 public: | 379 public: |
364 // |callback| must not be null. | 380 // |callback| must not be null. |
365 TouchResourceRequest(RequestSender* sender, | 381 TouchResourceRequest(RequestSender* sender, |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 const ProgressCallback& progress_callback); | 683 const ProgressCallback& progress_callback); |
668 virtual ~DownloadFileRequest(); | 684 virtual ~DownloadFileRequest(); |
669 | 685 |
670 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); | 686 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); |
671 }; | 687 }; |
672 | 688 |
673 } // namespace drive | 689 } // namespace drive |
674 } // namespace google_apis | 690 } // namespace google_apis |
675 | 691 |
676 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ | 692 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ |
OLD | NEW |