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