Chromium Code Reviews| 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 GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 5 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
| 6 #define GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 6 #define GOOGLE_APIS_DRIVE_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" |
| 11 #include "base/location.h" | |
| 12 #include "base/sequenced_task_runner.h" | |
| 13 #include "base/task_runner_util.h" | |
| 11 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "base/values.h" | |
| 12 #include "google_apis/drive/base_requests.h" | 16 #include "google_apis/drive/base_requests.h" |
| 17 #include "google_apis/drive/drive_api_parser.h" | |
| 13 #include "google_apis/drive/drive_api_url_generator.h" | 18 #include "google_apis/drive/drive_api_url_generator.h" |
| 14 #include "google_apis/drive/drive_common_callbacks.h" | 19 #include "google_apis/drive/drive_common_callbacks.h" |
| 15 | 20 |
| 16 namespace google_apis { | 21 namespace google_apis { |
| 17 | 22 |
| 18 class ChangeList; | |
| 19 class FileResource; | |
| 20 class FileList; | |
| 21 | |
| 22 // Callback used for requests that the server returns FileResource data | 23 // Callback used for requests that the server returns FileResource data |
| 23 // formatted into JSON value. | 24 // formatted into JSON value. |
| 24 typedef base::Callback<void(GDataErrorCode error, | 25 typedef base::Callback<void(GDataErrorCode error, |
| 25 scoped_ptr<FileResource> entry)> | 26 scoped_ptr<FileResource> entry)> |
| 26 FileResourceCallback; | 27 FileResourceCallback; |
| 27 | 28 |
| 28 // Callback used for requests that the server returns FileList data | 29 // Callback used for requests that the server returns FileList data |
| 29 // formatted into JSON value. | 30 // formatted into JSON value. |
| 30 typedef base::Callback<void(GDataErrorCode error, | 31 typedef base::Callback<void(GDataErrorCode error, |
| 31 scoped_ptr<FileList> entry)> FileListCallback; | 32 scoped_ptr<FileList> entry)> FileListCallback; |
| 32 | 33 |
| 33 // Callback used for requests that the server returns ChangeList data | 34 // Callback used for requests that the server returns ChangeList data |
| 34 // formatted into JSON value. | 35 // formatted into JSON value. |
| 35 typedef base::Callback<void(GDataErrorCode error, | 36 typedef base::Callback<void(GDataErrorCode error, |
| 36 scoped_ptr<ChangeList> entry)> ChangeListCallback; | 37 scoped_ptr<ChangeList> entry)> ChangeListCallback; |
| 37 | 38 |
| 38 namespace drive { | 39 namespace drive { |
| 39 | 40 |
| 40 //============================ DriveApiDataRequest =========================== | 41 //============================ DriveApiPartialFieldRequest ==================== |
| 41 | 42 |
| 42 // This is base class of the Drive API related requests. All Drive API requests | 43 // This is base class of the Drive API related requests. All Drive API requests |
| 43 // support partial request (to improve the performance). The function can be | 44 // support partial request (to improve the performance). The function can be |
| 44 // shared among the Drive API requests. | 45 // shared among the Drive API requests. |
| 45 // See also https://developers.google.com/drive/performance | 46 // See also https://developers.google.com/drive/performance |
| 46 class DriveApiDataRequest : public GetDataRequest { | 47 class DriveApiPartialFieldRequest : public UrlFetchRequestBase { |
| 47 public: | 48 public: |
| 48 DriveApiDataRequest(RequestSender* sender, const GetDataCallback& callback); | 49 explicit DriveApiPartialFieldRequest(RequestSender* sender); |
| 49 virtual ~DriveApiDataRequest(); | 50 virtual ~DriveApiPartialFieldRequest(); |
| 50 | 51 |
| 51 // Optional parameter. | 52 // Optional parameter. |
| 52 const std::string& fields() const { return fields_; } | 53 const std::string& fields() const { return fields_; } |
| 53 void set_fields(const std::string& fields) { fields_ = fields; } | 54 void set_fields(const std::string& fields) { fields_ = fields; } |
| 54 | 55 |
| 55 protected: | 56 protected: |
| 56 // Overridden from GetDataRequest. | 57 // UrlFetchRequestBase overrides. |
| 57 virtual GURL GetURL() const OVERRIDE; | 58 virtual GURL GetURL() const OVERRIDE; |
| 58 | 59 |
| 59 // Derived classes should override GetURLInternal instead of GetURL() | 60 // Derived classes should override GetURLInternal instead of GetURL() |
| 60 // directly. | 61 // directly. |
| 61 virtual GURL GetURLInternal() const = 0; | 62 virtual GURL GetURLInternal() const = 0; |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 std::string fields_; | 65 std::string fields_; |
| 65 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(DriveApiPartialFieldRequest); | |
| 68 }; | |
| 69 | |
| 70 //============================ DriveApiDataRequest =========================== | |
| 71 | |
| 72 // The base class of Drive API related requests that receive a JSON response | |
| 73 // representing |DataType|. | |
| 74 template<class DataType> | |
| 75 class DriveApiDataRequest : public DriveApiPartialFieldRequest { | |
|
hashimoto
2014/08/06 09:23:02
This class is replicating GetDataRequest and, afte
kinaba
2014/08/07 00:59:34
sg. done.
| |
| 76 public: | |
| 77 typedef base::Callback<void(GDataErrorCode error, | |
| 78 scoped_ptr<DataType> data)> Callback; | |
| 79 | |
| 80 // |callback| is called when the request finishes either by success or by | |
| 81 // failure. On success, a JSON Value object is passed. It must not be null. | |
| 82 DriveApiDataRequest(RequestSender* sender, const Callback& callback) | |
| 83 : DriveApiPartialFieldRequest(sender), | |
| 84 callback_(callback), | |
| 85 weak_ptr_factory_(this) { | |
| 86 DCHECK(!callback_.is_null()); | |
| 87 } | |
| 88 virtual ~DriveApiDataRequest() {} | |
| 89 | |
| 90 protected: | |
| 91 // UrlFetchRequestBase overrides. | |
| 92 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE { | |
| 93 GDataErrorCode error = GetErrorCode(); | |
| 94 switch (error) { | |
| 95 case HTTP_SUCCESS: | |
| 96 case HTTP_CREATED: | |
| 97 base::PostTaskAndReplyWithResult( | |
| 98 blocking_task_runner(), | |
| 99 FROM_HERE, | |
| 100 base::Bind(&DriveApiDataRequest::Parse, response_writer()->data()), | |
| 101 base::Bind(&DriveApiDataRequest::OnDataParsed, | |
| 102 weak_ptr_factory_.GetWeakPtr(), error)); | |
| 103 break; | |
| 104 default: | |
| 105 RunCallbackOnPrematureFailure(error); | |
| 106 OnProcessURLFetchResultsComplete(); | |
| 107 break; | |
| 108 } | |
| 109 } | |
| 110 | |
| 111 virtual void RunCallbackOnPrematureFailure(GDataErrorCode error) OVERRIDE { | |
| 112 callback_.Run(error, scoped_ptr<DataType>()); | |
| 113 } | |
| 114 | |
| 115 private: | |
| 116 // Parses the |json| string by using DataType::CreateFrom. | |
| 117 static scoped_ptr<DataType> Parse(const std::string& json) { | |
| 118 scoped_ptr<base::Value> value = ParseJson(json); | |
| 119 return value ? DataType::CreateFrom(*value) : scoped_ptr<DataType>(); | |
| 120 } | |
| 121 | |
| 122 // Receives the parsed result and invokes the callback. | |
| 123 void OnDataParsed(GDataErrorCode error, scoped_ptr<DataType> value) { | |
| 124 callback_.Run(value ? error : GDATA_PARSE_ERROR, value.Pass()); | |
| 125 OnProcessURLFetchResultsComplete(); | |
| 126 } | |
| 127 | |
| 128 const Callback callback_; | |
| 129 | |
| 130 // Note: This should remain the last member so it'll be destroyed and | |
| 131 // invalidate its weak pointers before any other members are destroyed. | |
| 132 base::WeakPtrFactory<DriveApiDataRequest> weak_ptr_factory_; | |
| 133 | |
| 66 DISALLOW_COPY_AND_ASSIGN(DriveApiDataRequest); | 134 DISALLOW_COPY_AND_ASSIGN(DriveApiDataRequest); |
| 67 }; | 135 }; |
| 68 | 136 |
| 69 //=============================== FilesGetRequest ============================= | 137 //=============================== FilesGetRequest ============================= |
| 70 | 138 |
| 71 // This class performs the request for fetching a file. | 139 // This class performs the request for fetching a file. |
| 72 // This request is mapped to | 140 // This request is mapped to |
| 73 // https://developers.google.com/drive/v2/reference/files/get | 141 // https://developers.google.com/drive/v2/reference/files/get |
| 74 class FilesGetRequest : public DriveApiDataRequest { | 142 class FilesGetRequest : public DriveApiDataRequest<FileResource> { |
| 75 public: | 143 public: |
| 76 FilesGetRequest(RequestSender* sender, | 144 FilesGetRequest(RequestSender* sender, |
| 77 const DriveApiUrlGenerator& url_generator, | 145 const DriveApiUrlGenerator& url_generator, |
| 78 const FileResourceCallback& callback); | 146 const FileResourceCallback& callback); |
| 79 virtual ~FilesGetRequest(); | 147 virtual ~FilesGetRequest(); |
| 80 | 148 |
| 81 // Required parameter. | 149 // Required parameter. |
| 82 const std::string& file_id() const { return file_id_; } | 150 const std::string& file_id() const { return file_id_; } |
| 83 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 151 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
| 84 | 152 |
| 85 protected: | 153 protected: |
| 86 // Overridden from DriveApiDataRequest. | 154 // Overridden from DriveApiDataRequest. |
| 87 virtual GURL GetURLInternal() const OVERRIDE; | 155 virtual GURL GetURLInternal() const OVERRIDE; |
| 88 | 156 |
| 89 private: | 157 private: |
| 90 const DriveApiUrlGenerator url_generator_; | 158 const DriveApiUrlGenerator url_generator_; |
| 91 std::string file_id_; | 159 std::string file_id_; |
| 92 | 160 |
| 93 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest); | 161 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest); |
| 94 }; | 162 }; |
| 95 | 163 |
| 96 //============================ FilesAuthorizeRequest =========================== | 164 //============================ FilesAuthorizeRequest =========================== |
| 97 | 165 |
| 98 // This class performs request for authorizing an app to access a file. | 166 // This class performs request for authorizing an app to access a file. |
| 99 // This request is mapped to /drive/v2internal/file/authorize internal endpoint. | 167 // This request is mapped to /drive/v2internal/file/authorize internal endpoint. |
| 100 class FilesAuthorizeRequest : public DriveApiDataRequest { | 168 class FilesAuthorizeRequest : public DriveApiDataRequest<FileResource> { |
| 101 public: | 169 public: |
| 102 FilesAuthorizeRequest(RequestSender* sender, | 170 FilesAuthorizeRequest(RequestSender* sender, |
| 103 const DriveApiUrlGenerator& url_generator, | 171 const DriveApiUrlGenerator& url_generator, |
| 104 const FileResourceCallback& callback); | 172 const FileResourceCallback& callback); |
| 105 virtual ~FilesAuthorizeRequest(); | 173 virtual ~FilesAuthorizeRequest(); |
| 106 | 174 |
| 107 // Required parameter. | 175 // Required parameter. |
| 108 const std::string& file_id() const { return file_id_; } | 176 const std::string& file_id() const { return file_id_; } |
| 109 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 177 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
| 110 const std::string& app_id() const { return app_id_; } | 178 const std::string& app_id() const { return app_id_; } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 125 DISALLOW_COPY_AND_ASSIGN(FilesAuthorizeRequest); | 193 DISALLOW_COPY_AND_ASSIGN(FilesAuthorizeRequest); |
| 126 }; | 194 }; |
| 127 | 195 |
| 128 //============================ FilesInsertRequest ============================= | 196 //============================ FilesInsertRequest ============================= |
| 129 | 197 |
| 130 // This class performs the request for creating a resource. | 198 // This class performs the request for creating a resource. |
| 131 // This request is mapped to | 199 // This request is mapped to |
| 132 // https://developers.google.com/drive/v2/reference/files/insert | 200 // https://developers.google.com/drive/v2/reference/files/insert |
| 133 // See also https://developers.google.com/drive/manage-uploads and | 201 // See also https://developers.google.com/drive/manage-uploads and |
| 134 // https://developers.google.com/drive/folder | 202 // https://developers.google.com/drive/folder |
| 135 class FilesInsertRequest : public DriveApiDataRequest { | 203 class FilesInsertRequest : public DriveApiDataRequest<FileResource> { |
| 136 public: | 204 public: |
| 137 FilesInsertRequest(RequestSender* sender, | 205 FilesInsertRequest(RequestSender* sender, |
| 138 const DriveApiUrlGenerator& url_generator, | 206 const DriveApiUrlGenerator& url_generator, |
| 139 const FileResourceCallback& callback); | 207 const FileResourceCallback& callback); |
| 140 virtual ~FilesInsertRequest(); | 208 virtual ~FilesInsertRequest(); |
| 141 | 209 |
| 142 // Optional request body. | 210 // Optional request body. |
| 143 const base::Time& last_viewed_by_me_date() const { | 211 const base::Time& last_viewed_by_me_date() const { |
| 144 return last_viewed_by_me_date_; | 212 return last_viewed_by_me_date_; |
| 145 } | 213 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 std::string title_; | 250 std::string title_; |
| 183 | 251 |
| 184 DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest); | 252 DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest); |
| 185 }; | 253 }; |
| 186 | 254 |
| 187 //============================== FilesPatchRequest ============================ | 255 //============================== FilesPatchRequest ============================ |
| 188 | 256 |
| 189 // This class performs the request for patching file metadata. | 257 // This class performs the request for patching file metadata. |
| 190 // This request is mapped to | 258 // This request is mapped to |
| 191 // https://developers.google.com/drive/v2/reference/files/patch | 259 // https://developers.google.com/drive/v2/reference/files/patch |
| 192 class FilesPatchRequest : public DriveApiDataRequest { | 260 class FilesPatchRequest : public DriveApiDataRequest<FileResource> { |
| 193 public: | 261 public: |
| 194 FilesPatchRequest(RequestSender* sender, | 262 FilesPatchRequest(RequestSender* sender, |
| 195 const DriveApiUrlGenerator& url_generator, | 263 const DriveApiUrlGenerator& url_generator, |
| 196 const FileResourceCallback& callback); | 264 const FileResourceCallback& callback); |
| 197 virtual ~FilesPatchRequest(); | 265 virtual ~FilesPatchRequest(); |
| 198 | 266 |
| 199 // Required parameter. | 267 // Required parameter. |
| 200 const std::string& file_id() const { return file_id_; } | 268 const std::string& file_id() const { return file_id_; } |
| 201 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 269 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
| 202 | 270 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 std::vector<std::string> parents_; | 324 std::vector<std::string> parents_; |
| 257 | 325 |
| 258 DISALLOW_COPY_AND_ASSIGN(FilesPatchRequest); | 326 DISALLOW_COPY_AND_ASSIGN(FilesPatchRequest); |
| 259 }; | 327 }; |
| 260 | 328 |
| 261 //============================= FilesCopyRequest ============================== | 329 //============================= FilesCopyRequest ============================== |
| 262 | 330 |
| 263 // This class performs the request for copying a resource. | 331 // This class performs the request for copying a resource. |
| 264 // This request is mapped to | 332 // This request is mapped to |
| 265 // https://developers.google.com/drive/v2/reference/files/copy | 333 // https://developers.google.com/drive/v2/reference/files/copy |
| 266 class FilesCopyRequest : public DriveApiDataRequest { | 334 class FilesCopyRequest : public DriveApiDataRequest<FileResource> { |
| 267 public: | 335 public: |
| 268 // Upon completion, |callback| will be called. |callback| must not be null. | 336 // Upon completion, |callback| will be called. |callback| must not be null. |
| 269 FilesCopyRequest(RequestSender* sender, | 337 FilesCopyRequest(RequestSender* sender, |
| 270 const DriveApiUrlGenerator& url_generator, | 338 const DriveApiUrlGenerator& url_generator, |
| 271 const FileResourceCallback& callback); | 339 const FileResourceCallback& callback); |
| 272 virtual ~FilesCopyRequest(); | 340 virtual ~FilesCopyRequest(); |
| 273 | 341 |
| 274 // Required parameter. | 342 // Required parameter. |
| 275 const std::string& file_id() const { return file_id_; } | 343 const std::string& file_id() const { return file_id_; } |
| 276 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 344 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 }; | 376 }; |
| 309 | 377 |
| 310 //============================= FilesListRequest ============================= | 378 //============================= FilesListRequest ============================= |
| 311 | 379 |
| 312 // This class performs the request for fetching FileList. | 380 // This class performs the request for fetching FileList. |
| 313 // The result may contain only first part of the result. The remaining result | 381 // The result may contain only first part of the result. The remaining result |
| 314 // should be able to be fetched by ContinueGetFileListRequest defined below, | 382 // should be able to be fetched by ContinueGetFileListRequest defined below, |
| 315 // or by FilesListRequest with setting page token. | 383 // or by FilesListRequest with setting page token. |
| 316 // This request is mapped to | 384 // This request is mapped to |
| 317 // https://developers.google.com/drive/v2/reference/files/list | 385 // https://developers.google.com/drive/v2/reference/files/list |
| 318 class FilesListRequest : public DriveApiDataRequest { | 386 class FilesListRequest : public DriveApiDataRequest<FileList> { |
| 319 public: | 387 public: |
| 320 FilesListRequest(RequestSender* sender, | 388 FilesListRequest(RequestSender* sender, |
| 321 const DriveApiUrlGenerator& url_generator, | 389 const DriveApiUrlGenerator& url_generator, |
| 322 const FileListCallback& callback); | 390 const FileListCallback& callback); |
| 323 virtual ~FilesListRequest(); | 391 virtual ~FilesListRequest(); |
| 324 | 392 |
| 325 // Optional parameter | 393 // Optional parameter |
| 326 int max_results() const { return max_results_; } | 394 int max_results() const { return max_results_; } |
| 327 void set_max_results(int max_results) { max_results_ = max_results; } | 395 void set_max_results(int max_results) { max_results_ = max_results; } |
| 328 | 396 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 346 | 414 |
| 347 DISALLOW_COPY_AND_ASSIGN(FilesListRequest); | 415 DISALLOW_COPY_AND_ASSIGN(FilesListRequest); |
| 348 }; | 416 }; |
| 349 | 417 |
| 350 //========================= FilesListNextPageRequest ========================== | 418 //========================= FilesListNextPageRequest ========================== |
| 351 | 419 |
| 352 // There are two ways to obtain next pages of "Files: list" result (if paged). | 420 // There are two ways to obtain next pages of "Files: list" result (if paged). |
| 353 // 1) Set pageToken and all params used for the initial request. | 421 // 1) Set pageToken and all params used for the initial request. |
| 354 // 2) Use URL in the nextLink field in the previous response. | 422 // 2) Use URL in the nextLink field in the previous response. |
| 355 // This class implements 2)'s request. | 423 // This class implements 2)'s request. |
| 356 class FilesListNextPageRequest : public DriveApiDataRequest { | 424 class FilesListNextPageRequest : public DriveApiDataRequest<FileList> { |
| 357 public: | 425 public: |
| 358 FilesListNextPageRequest(RequestSender* sender, | 426 FilesListNextPageRequest(RequestSender* sender, |
| 359 const FileListCallback& callback); | 427 const FileListCallback& callback); |
| 360 virtual ~FilesListNextPageRequest(); | 428 virtual ~FilesListNextPageRequest(); |
| 361 | 429 |
| 362 const GURL& next_link() const { return next_link_; } | 430 const GURL& next_link() const { return next_link_; } |
| 363 void set_next_link(const GURL& next_link) { next_link_ = next_link; } | 431 void set_next_link(const GURL& next_link) { next_link_ = next_link; } |
| 364 | 432 |
| 365 protected: | 433 protected: |
| 366 // Overridden from DriveApiDataRequest. | 434 // Overridden from DriveApiDataRequest. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 std::string etag_; | 469 std::string etag_; |
| 402 | 470 |
| 403 DISALLOW_COPY_AND_ASSIGN(FilesDeleteRequest); | 471 DISALLOW_COPY_AND_ASSIGN(FilesDeleteRequest); |
| 404 }; | 472 }; |
| 405 | 473 |
| 406 //============================= FilesTrashRequest ============================== | 474 //============================= FilesTrashRequest ============================== |
| 407 | 475 |
| 408 // This class performs the request for trashing a resource. | 476 // This class performs the request for trashing a resource. |
| 409 // This request is mapped to | 477 // This request is mapped to |
| 410 // https://developers.google.com/drive/v2/reference/files/trash | 478 // https://developers.google.com/drive/v2/reference/files/trash |
| 411 class FilesTrashRequest : public DriveApiDataRequest { | 479 class FilesTrashRequest : public DriveApiDataRequest<FileResource> { |
| 412 public: | 480 public: |
| 413 FilesTrashRequest(RequestSender* sender, | 481 FilesTrashRequest(RequestSender* sender, |
| 414 const DriveApiUrlGenerator& url_generator, | 482 const DriveApiUrlGenerator& url_generator, |
| 415 const FileResourceCallback& callback); | 483 const FileResourceCallback& callback); |
| 416 virtual ~FilesTrashRequest(); | 484 virtual ~FilesTrashRequest(); |
| 417 | 485 |
| 418 // Required parameter. | 486 // Required parameter. |
| 419 const std::string& file_id() const { return file_id_; } | 487 const std::string& file_id() const { return file_id_; } |
| 420 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 488 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
| 421 | 489 |
| 422 protected: | 490 protected: |
| 423 // Overridden from UrlFetchRequestBase. | 491 // Overridden from UrlFetchRequestBase. |
| 424 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 492 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 425 | 493 |
| 426 // Overridden from DriveApiDataRequest. | 494 // Overridden from DriveApiDataRequest. |
| 427 virtual GURL GetURLInternal() const OVERRIDE; | 495 virtual GURL GetURLInternal() const OVERRIDE; |
| 428 | 496 |
| 429 private: | 497 private: |
| 430 const DriveApiUrlGenerator url_generator_; | 498 const DriveApiUrlGenerator url_generator_; |
| 431 std::string file_id_; | 499 std::string file_id_; |
| 432 | 500 |
| 433 DISALLOW_COPY_AND_ASSIGN(FilesTrashRequest); | 501 DISALLOW_COPY_AND_ASSIGN(FilesTrashRequest); |
| 434 }; | 502 }; |
| 435 | 503 |
| 436 //============================== AboutGetRequest ============================= | 504 //============================== AboutGetRequest ============================= |
| 437 | 505 |
| 438 // This class performs the request for fetching About data. | 506 // This class performs the request for fetching About data. |
| 439 // This request is mapped to | 507 // This request is mapped to |
| 440 // https://developers.google.com/drive/v2/reference/about/get | 508 // https://developers.google.com/drive/v2/reference/about/get |
| 441 class AboutGetRequest : public DriveApiDataRequest { | 509 class AboutGetRequest : public DriveApiDataRequest<AboutResource> { |
| 442 public: | 510 public: |
| 443 AboutGetRequest(RequestSender* sender, | 511 AboutGetRequest(RequestSender* sender, |
| 444 const DriveApiUrlGenerator& url_generator, | 512 const DriveApiUrlGenerator& url_generator, |
| 445 const AboutResourceCallback& callback); | 513 const AboutResourceCallback& callback); |
| 446 virtual ~AboutGetRequest(); | 514 virtual ~AboutGetRequest(); |
| 447 | 515 |
| 448 protected: | 516 protected: |
| 449 // Overridden from DriveApiDataRequest. | 517 // Overridden from DriveApiDataRequest. |
| 450 virtual GURL GetURLInternal() const OVERRIDE; | 518 virtual GURL GetURLInternal() const OVERRIDE; |
| 451 | 519 |
| 452 private: | 520 private: |
| 453 const DriveApiUrlGenerator url_generator_; | 521 const DriveApiUrlGenerator url_generator_; |
| 454 | 522 |
| 455 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest); | 523 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest); |
| 456 }; | 524 }; |
| 457 | 525 |
| 458 //============================ ChangesListRequest ============================ | 526 //============================ ChangesListRequest ============================ |
| 459 | 527 |
| 460 // This class performs the request for fetching ChangeList. | 528 // This class performs the request for fetching ChangeList. |
| 461 // The result may contain only first part of the result. The remaining result | 529 // The result may contain only first part of the result. The remaining result |
| 462 // should be able to be fetched by ContinueGetFileListRequest defined below. | 530 // should be able to be fetched by ContinueGetFileListRequest defined below. |
| 463 // or by ChangesListRequest with setting page token. | 531 // or by ChangesListRequest with setting page token. |
| 464 // This request is mapped to | 532 // This request is mapped to |
| 465 // https://developers.google.com/drive/v2/reference/changes/list | 533 // https://developers.google.com/drive/v2/reference/changes/list |
| 466 class ChangesListRequest : public DriveApiDataRequest { | 534 class ChangesListRequest : public DriveApiDataRequest<ChangeList> { |
| 467 public: | 535 public: |
| 468 ChangesListRequest(RequestSender* sender, | 536 ChangesListRequest(RequestSender* sender, |
| 469 const DriveApiUrlGenerator& url_generator, | 537 const DriveApiUrlGenerator& url_generator, |
| 470 const ChangeListCallback& callback); | 538 const ChangeListCallback& callback); |
| 471 virtual ~ChangesListRequest(); | 539 virtual ~ChangesListRequest(); |
| 472 | 540 |
| 473 // Optional parameter | 541 // Optional parameter |
| 474 bool include_deleted() const { return include_deleted_; } | 542 bool include_deleted() const { return include_deleted_; } |
| 475 void set_include_deleted(bool include_deleted) { | 543 void set_include_deleted(bool include_deleted) { |
| 476 include_deleted_ = include_deleted; | 544 include_deleted_ = include_deleted; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 502 | 570 |
| 503 DISALLOW_COPY_AND_ASSIGN(ChangesListRequest); | 571 DISALLOW_COPY_AND_ASSIGN(ChangesListRequest); |
| 504 }; | 572 }; |
| 505 | 573 |
| 506 //======================== ChangesListNextPageRequest ========================= | 574 //======================== ChangesListNextPageRequest ========================= |
| 507 | 575 |
| 508 // There are two ways to obtain next pages of "Changes: list" result (if paged). | 576 // There are two ways to obtain next pages of "Changes: list" result (if paged). |
| 509 // 1) Set pageToken and all params used for the initial request. | 577 // 1) Set pageToken and all params used for the initial request. |
| 510 // 2) Use URL in the nextLink field in the previous response. | 578 // 2) Use URL in the nextLink field in the previous response. |
| 511 // This class implements 2)'s request. | 579 // This class implements 2)'s request. |
| 512 class ChangesListNextPageRequest : public DriveApiDataRequest { | 580 class ChangesListNextPageRequest : public DriveApiDataRequest<ChangeList> { |
| 513 public: | 581 public: |
| 514 ChangesListNextPageRequest(RequestSender* sender, | 582 ChangesListNextPageRequest(RequestSender* sender, |
| 515 const ChangeListCallback& callback); | 583 const ChangeListCallback& callback); |
| 516 virtual ~ChangesListNextPageRequest(); | 584 virtual ~ChangesListNextPageRequest(); |
| 517 | 585 |
| 518 const GURL& next_link() const { return next_link_; } | 586 const GURL& next_link() const { return next_link_; } |
| 519 void set_next_link(const GURL& next_link) { next_link_ = next_link; } | 587 void set_next_link(const GURL& next_link) { next_link_ = next_link; } |
| 520 | 588 |
| 521 protected: | 589 protected: |
| 522 // Overridden from DriveApiDataRequest. | 590 // Overridden from DriveApiDataRequest. |
| 523 virtual GURL GetURLInternal() const OVERRIDE; | 591 virtual GURL GetURLInternal() const OVERRIDE; |
| 524 | 592 |
| 525 private: | 593 private: |
| 526 GURL next_link_; | 594 GURL next_link_; |
| 527 | 595 |
| 528 DISALLOW_COPY_AND_ASSIGN(ChangesListNextPageRequest); | 596 DISALLOW_COPY_AND_ASSIGN(ChangesListNextPageRequest); |
| 529 }; | 597 }; |
| 530 | 598 |
| 531 //============================= AppsListRequest ============================ | 599 //============================= AppsListRequest ============================ |
| 532 | 600 |
| 533 // This class performs the request for fetching AppList. | 601 // This class performs the request for fetching AppList. |
| 534 // This request is mapped to | 602 // This request is mapped to |
| 535 // https://developers.google.com/drive/v2/reference/apps/list | 603 // https://developers.google.com/drive/v2/reference/apps/list |
| 536 class AppsListRequest : public DriveApiDataRequest { | 604 class AppsListRequest : public DriveApiDataRequest<AppList> { |
| 537 public: | 605 public: |
| 538 AppsListRequest(RequestSender* sender, | 606 AppsListRequest(RequestSender* sender, |
| 539 const DriveApiUrlGenerator& url_generator, | 607 const DriveApiUrlGenerator& url_generator, |
| 540 bool use_internal_endpoint, | 608 bool use_internal_endpoint, |
| 541 const AppListCallback& callback); | 609 const AppListCallback& callback); |
| 542 virtual ~AppsListRequest(); | 610 virtual ~AppsListRequest(); |
| 543 | 611 |
| 544 protected: | 612 protected: |
| 545 // Overridden from DriveApiDataRequest. | 613 // Overridden from DriveApiDataRequest. |
| 546 virtual GURL GetURLInternal() const OVERRIDE; | 614 virtual GURL GetURLInternal() const OVERRIDE; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 PermissionRole role_; | 957 PermissionRole role_; |
| 890 std::string value_; | 958 std::string value_; |
| 891 | 959 |
| 892 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest); | 960 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest); |
| 893 }; | 961 }; |
| 894 | 962 |
| 895 } // namespace drive | 963 } // namespace drive |
| 896 } // namespace google_apis | 964 } // namespace google_apis |
| 897 | 965 |
| 898 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 966 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
| OLD | NEW |