Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: google_apis/drive/drive_api_requests.h

Issue 442193002: Parse Drive API responses all at once in the blocking pool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the cause of the regression. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « google_apis/drive/base_requests_unittest.cc ('k') | google_apis/drive/drive_api_requests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
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 if (!value)
125 error = GDATA_PARSE_ERROR;
126 callback_.Run(error, value.Pass());
127 OnProcessURLFetchResultsComplete();
128 }
129
130 const Callback callback_;
131
132 // Note: This should remain the last member so it'll be destroyed and
133 // invalidate its weak pointers before any other members are destroyed.
134 base::WeakPtrFactory<DriveApiDataRequest> weak_ptr_factory_;
135
66 DISALLOW_COPY_AND_ASSIGN(DriveApiDataRequest); 136 DISALLOW_COPY_AND_ASSIGN(DriveApiDataRequest);
67 }; 137 };
68 138
69 //=============================== FilesGetRequest ============================= 139 //=============================== FilesGetRequest =============================
70 140
71 // This class performs the request for fetching a file. 141 // This class performs the request for fetching a file.
72 // This request is mapped to 142 // This request is mapped to
73 // https://developers.google.com/drive/v2/reference/files/get 143 // https://developers.google.com/drive/v2/reference/files/get
74 class FilesGetRequest : public DriveApiDataRequest { 144 class FilesGetRequest : public DriveApiDataRequest<FileResource> {
75 public: 145 public:
76 FilesGetRequest(RequestSender* sender, 146 FilesGetRequest(RequestSender* sender,
77 const DriveApiUrlGenerator& url_generator, 147 const DriveApiUrlGenerator& url_generator,
78 const FileResourceCallback& callback); 148 const FileResourceCallback& callback);
79 virtual ~FilesGetRequest(); 149 virtual ~FilesGetRequest();
80 150
81 // Required parameter. 151 // Required parameter.
82 const std::string& file_id() const { return file_id_; } 152 const std::string& file_id() const { return file_id_; }
83 void set_file_id(const std::string& file_id) { file_id_ = file_id; } 153 void set_file_id(const std::string& file_id) { file_id_ = file_id; }
84 154
85 protected: 155 protected:
86 // Overridden from DriveApiDataRequest. 156 // Overridden from DriveApiDataRequest.
87 virtual GURL GetURLInternal() const OVERRIDE; 157 virtual GURL GetURLInternal() const OVERRIDE;
88 158
89 private: 159 private:
90 const DriveApiUrlGenerator url_generator_; 160 const DriveApiUrlGenerator url_generator_;
91 std::string file_id_; 161 std::string file_id_;
92 162
93 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest); 163 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest);
94 }; 164 };
95 165
96 //============================ FilesAuthorizeRequest =========================== 166 //============================ FilesAuthorizeRequest ===========================
97 167
98 // This class performs request for authorizing an app to access a file. 168 // This class performs request for authorizing an app to access a file.
99 // This request is mapped to /drive/v2internal/file/authorize internal endpoint. 169 // This request is mapped to /drive/v2internal/file/authorize internal endpoint.
100 class FilesAuthorizeRequest : public DriveApiDataRequest { 170 class FilesAuthorizeRequest : public DriveApiDataRequest<FileResource> {
101 public: 171 public:
102 FilesAuthorizeRequest(RequestSender* sender, 172 FilesAuthorizeRequest(RequestSender* sender,
103 const DriveApiUrlGenerator& url_generator, 173 const DriveApiUrlGenerator& url_generator,
104 const FileResourceCallback& callback); 174 const FileResourceCallback& callback);
105 virtual ~FilesAuthorizeRequest(); 175 virtual ~FilesAuthorizeRequest();
106 176
107 // Required parameter. 177 // Required parameter.
108 const std::string& file_id() const { return file_id_; } 178 const std::string& file_id() const { return file_id_; }
109 void set_file_id(const std::string& file_id) { file_id_ = file_id; } 179 void set_file_id(const std::string& file_id) { file_id_ = file_id; }
110 const std::string& app_id() const { return app_id_; } 180 const std::string& app_id() const { return app_id_; }
(...skipping 14 matching lines...) Expand all
125 DISALLOW_COPY_AND_ASSIGN(FilesAuthorizeRequest); 195 DISALLOW_COPY_AND_ASSIGN(FilesAuthorizeRequest);
126 }; 196 };
127 197
128 //============================ FilesInsertRequest ============================= 198 //============================ FilesInsertRequest =============================
129 199
130 // This class performs the request for creating a resource. 200 // This class performs the request for creating a resource.
131 // This request is mapped to 201 // This request is mapped to
132 // https://developers.google.com/drive/v2/reference/files/insert 202 // https://developers.google.com/drive/v2/reference/files/insert
133 // See also https://developers.google.com/drive/manage-uploads and 203 // See also https://developers.google.com/drive/manage-uploads and
134 // https://developers.google.com/drive/folder 204 // https://developers.google.com/drive/folder
135 class FilesInsertRequest : public DriveApiDataRequest { 205 class FilesInsertRequest : public DriveApiDataRequest<FileResource> {
136 public: 206 public:
137 FilesInsertRequest(RequestSender* sender, 207 FilesInsertRequest(RequestSender* sender,
138 const DriveApiUrlGenerator& url_generator, 208 const DriveApiUrlGenerator& url_generator,
139 const FileResourceCallback& callback); 209 const FileResourceCallback& callback);
140 virtual ~FilesInsertRequest(); 210 virtual ~FilesInsertRequest();
141 211
142 // Optional request body. 212 // Optional request body.
143 const base::Time& last_viewed_by_me_date() const { 213 const base::Time& last_viewed_by_me_date() const {
144 return last_viewed_by_me_date_; 214 return last_viewed_by_me_date_;
145 } 215 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 std::string title_; 252 std::string title_;
183 253
184 DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest); 254 DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest);
185 }; 255 };
186 256
187 //============================== FilesPatchRequest ============================ 257 //============================== FilesPatchRequest ============================
188 258
189 // This class performs the request for patching file metadata. 259 // This class performs the request for patching file metadata.
190 // This request is mapped to 260 // This request is mapped to
191 // https://developers.google.com/drive/v2/reference/files/patch 261 // https://developers.google.com/drive/v2/reference/files/patch
192 class FilesPatchRequest : public DriveApiDataRequest { 262 class FilesPatchRequest : public DriveApiDataRequest<FileResource> {
193 public: 263 public:
194 FilesPatchRequest(RequestSender* sender, 264 FilesPatchRequest(RequestSender* sender,
195 const DriveApiUrlGenerator& url_generator, 265 const DriveApiUrlGenerator& url_generator,
196 const FileResourceCallback& callback); 266 const FileResourceCallback& callback);
197 virtual ~FilesPatchRequest(); 267 virtual ~FilesPatchRequest();
198 268
199 // Required parameter. 269 // Required parameter.
200 const std::string& file_id() const { return file_id_; } 270 const std::string& file_id() const { return file_id_; }
201 void set_file_id(const std::string& file_id) { file_id_ = file_id; } 271 void set_file_id(const std::string& file_id) { file_id_ = file_id; }
202 272
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 std::vector<std::string> parents_; 326 std::vector<std::string> parents_;
257 327
258 DISALLOW_COPY_AND_ASSIGN(FilesPatchRequest); 328 DISALLOW_COPY_AND_ASSIGN(FilesPatchRequest);
259 }; 329 };
260 330
261 //============================= FilesCopyRequest ============================== 331 //============================= FilesCopyRequest ==============================
262 332
263 // This class performs the request for copying a resource. 333 // This class performs the request for copying a resource.
264 // This request is mapped to 334 // This request is mapped to
265 // https://developers.google.com/drive/v2/reference/files/copy 335 // https://developers.google.com/drive/v2/reference/files/copy
266 class FilesCopyRequest : public DriveApiDataRequest { 336 class FilesCopyRequest : public DriveApiDataRequest<FileResource> {
267 public: 337 public:
268 // Upon completion, |callback| will be called. |callback| must not be null. 338 // Upon completion, |callback| will be called. |callback| must not be null.
269 FilesCopyRequest(RequestSender* sender, 339 FilesCopyRequest(RequestSender* sender,
270 const DriveApiUrlGenerator& url_generator, 340 const DriveApiUrlGenerator& url_generator,
271 const FileResourceCallback& callback); 341 const FileResourceCallback& callback);
272 virtual ~FilesCopyRequest(); 342 virtual ~FilesCopyRequest();
273 343
274 // Required parameter. 344 // Required parameter.
275 const std::string& file_id() const { return file_id_; } 345 const std::string& file_id() const { return file_id_; }
276 void set_file_id(const std::string& file_id) { file_id_ = file_id; } 346 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
308 }; 378 };
309 379
310 //============================= FilesListRequest ============================= 380 //============================= FilesListRequest =============================
311 381
312 // This class performs the request for fetching FileList. 382 // This class performs the request for fetching FileList.
313 // The result may contain only first part of the result. The remaining result 383 // The result may contain only first part of the result. The remaining result
314 // should be able to be fetched by ContinueGetFileListRequest defined below, 384 // should be able to be fetched by ContinueGetFileListRequest defined below,
315 // or by FilesListRequest with setting page token. 385 // or by FilesListRequest with setting page token.
316 // This request is mapped to 386 // This request is mapped to
317 // https://developers.google.com/drive/v2/reference/files/list 387 // https://developers.google.com/drive/v2/reference/files/list
318 class FilesListRequest : public DriveApiDataRequest { 388 class FilesListRequest : public DriveApiDataRequest<FileList> {
319 public: 389 public:
320 FilesListRequest(RequestSender* sender, 390 FilesListRequest(RequestSender* sender,
321 const DriveApiUrlGenerator& url_generator, 391 const DriveApiUrlGenerator& url_generator,
322 const FileListCallback& callback); 392 const FileListCallback& callback);
323 virtual ~FilesListRequest(); 393 virtual ~FilesListRequest();
324 394
325 // Optional parameter 395 // Optional parameter
326 int max_results() const { return max_results_; } 396 int max_results() const { return max_results_; }
327 void set_max_results(int max_results) { max_results_ = max_results; } 397 void set_max_results(int max_results) { max_results_ = max_results; }
328 398
(...skipping 17 matching lines...) Expand all
346 416
347 DISALLOW_COPY_AND_ASSIGN(FilesListRequest); 417 DISALLOW_COPY_AND_ASSIGN(FilesListRequest);
348 }; 418 };
349 419
350 //========================= FilesListNextPageRequest ========================== 420 //========================= FilesListNextPageRequest ==========================
351 421
352 // There are two ways to obtain next pages of "Files: list" result (if paged). 422 // 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. 423 // 1) Set pageToken and all params used for the initial request.
354 // 2) Use URL in the nextLink field in the previous response. 424 // 2) Use URL in the nextLink field in the previous response.
355 // This class implements 2)'s request. 425 // This class implements 2)'s request.
356 class FilesListNextPageRequest : public DriveApiDataRequest { 426 class FilesListNextPageRequest : public DriveApiDataRequest<FileList> {
357 public: 427 public:
358 FilesListNextPageRequest(RequestSender* sender, 428 FilesListNextPageRequest(RequestSender* sender,
359 const FileListCallback& callback); 429 const FileListCallback& callback);
360 virtual ~FilesListNextPageRequest(); 430 virtual ~FilesListNextPageRequest();
361 431
362 const GURL& next_link() const { return next_link_; } 432 const GURL& next_link() const { return next_link_; }
363 void set_next_link(const GURL& next_link) { next_link_ = next_link; } 433 void set_next_link(const GURL& next_link) { next_link_ = next_link; }
364 434
365 protected: 435 protected:
366 // Overridden from DriveApiDataRequest. 436 // Overridden from DriveApiDataRequest.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 std::string etag_; 471 std::string etag_;
402 472
403 DISALLOW_COPY_AND_ASSIGN(FilesDeleteRequest); 473 DISALLOW_COPY_AND_ASSIGN(FilesDeleteRequest);
404 }; 474 };
405 475
406 //============================= FilesTrashRequest ============================== 476 //============================= FilesTrashRequest ==============================
407 477
408 // This class performs the request for trashing a resource. 478 // This class performs the request for trashing a resource.
409 // This request is mapped to 479 // This request is mapped to
410 // https://developers.google.com/drive/v2/reference/files/trash 480 // https://developers.google.com/drive/v2/reference/files/trash
411 class FilesTrashRequest : public DriveApiDataRequest { 481 class FilesTrashRequest : public DriveApiDataRequest<FileResource> {
412 public: 482 public:
413 FilesTrashRequest(RequestSender* sender, 483 FilesTrashRequest(RequestSender* sender,
414 const DriveApiUrlGenerator& url_generator, 484 const DriveApiUrlGenerator& url_generator,
415 const FileResourceCallback& callback); 485 const FileResourceCallback& callback);
416 virtual ~FilesTrashRequest(); 486 virtual ~FilesTrashRequest();
417 487
418 // Required parameter. 488 // Required parameter.
419 const std::string& file_id() const { return file_id_; } 489 const std::string& file_id() const { return file_id_; }
420 void set_file_id(const std::string& file_id) { file_id_ = file_id; } 490 void set_file_id(const std::string& file_id) { file_id_ = file_id; }
421 491
422 protected: 492 protected:
423 // Overridden from UrlFetchRequestBase. 493 // Overridden from UrlFetchRequestBase.
424 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; 494 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE;
425 495
426 // Overridden from DriveApiDataRequest. 496 // Overridden from DriveApiDataRequest.
427 virtual GURL GetURLInternal() const OVERRIDE; 497 virtual GURL GetURLInternal() const OVERRIDE;
428 498
429 private: 499 private:
430 const DriveApiUrlGenerator url_generator_; 500 const DriveApiUrlGenerator url_generator_;
431 std::string file_id_; 501 std::string file_id_;
432 502
433 DISALLOW_COPY_AND_ASSIGN(FilesTrashRequest); 503 DISALLOW_COPY_AND_ASSIGN(FilesTrashRequest);
434 }; 504 };
435 505
436 //============================== AboutGetRequest ============================= 506 //============================== AboutGetRequest =============================
437 507
438 // This class performs the request for fetching About data. 508 // This class performs the request for fetching About data.
439 // This request is mapped to 509 // This request is mapped to
440 // https://developers.google.com/drive/v2/reference/about/get 510 // https://developers.google.com/drive/v2/reference/about/get
441 class AboutGetRequest : public DriveApiDataRequest { 511 class AboutGetRequest : public DriveApiDataRequest<AboutResource> {
442 public: 512 public:
443 AboutGetRequest(RequestSender* sender, 513 AboutGetRequest(RequestSender* sender,
444 const DriveApiUrlGenerator& url_generator, 514 const DriveApiUrlGenerator& url_generator,
445 const AboutResourceCallback& callback); 515 const AboutResourceCallback& callback);
446 virtual ~AboutGetRequest(); 516 virtual ~AboutGetRequest();
447 517
448 protected: 518 protected:
449 // Overridden from DriveApiDataRequest. 519 // Overridden from DriveApiDataRequest.
450 virtual GURL GetURLInternal() const OVERRIDE; 520 virtual GURL GetURLInternal() const OVERRIDE;
451 521
452 private: 522 private:
453 const DriveApiUrlGenerator url_generator_; 523 const DriveApiUrlGenerator url_generator_;
454 524
455 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest); 525 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest);
456 }; 526 };
457 527
458 //============================ ChangesListRequest ============================ 528 //============================ ChangesListRequest ============================
459 529
460 // This class performs the request for fetching ChangeList. 530 // This class performs the request for fetching ChangeList.
461 // The result may contain only first part of the result. The remaining result 531 // The result may contain only first part of the result. The remaining result
462 // should be able to be fetched by ContinueGetFileListRequest defined below. 532 // should be able to be fetched by ContinueGetFileListRequest defined below.
463 // or by ChangesListRequest with setting page token. 533 // or by ChangesListRequest with setting page token.
464 // This request is mapped to 534 // This request is mapped to
465 // https://developers.google.com/drive/v2/reference/changes/list 535 // https://developers.google.com/drive/v2/reference/changes/list
466 class ChangesListRequest : public DriveApiDataRequest { 536 class ChangesListRequest : public DriveApiDataRequest<ChangeList> {
467 public: 537 public:
468 ChangesListRequest(RequestSender* sender, 538 ChangesListRequest(RequestSender* sender,
469 const DriveApiUrlGenerator& url_generator, 539 const DriveApiUrlGenerator& url_generator,
470 const ChangeListCallback& callback); 540 const ChangeListCallback& callback);
471 virtual ~ChangesListRequest(); 541 virtual ~ChangesListRequest();
472 542
473 // Optional parameter 543 // Optional parameter
474 bool include_deleted() const { return include_deleted_; } 544 bool include_deleted() const { return include_deleted_; }
475 void set_include_deleted(bool include_deleted) { 545 void set_include_deleted(bool include_deleted) {
476 include_deleted_ = include_deleted; 546 include_deleted_ = include_deleted;
(...skipping 25 matching lines...) Expand all
502 572
503 DISALLOW_COPY_AND_ASSIGN(ChangesListRequest); 573 DISALLOW_COPY_AND_ASSIGN(ChangesListRequest);
504 }; 574 };
505 575
506 //======================== ChangesListNextPageRequest ========================= 576 //======================== ChangesListNextPageRequest =========================
507 577
508 // There are two ways to obtain next pages of "Changes: list" result (if paged). 578 // 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. 579 // 1) Set pageToken and all params used for the initial request.
510 // 2) Use URL in the nextLink field in the previous response. 580 // 2) Use URL in the nextLink field in the previous response.
511 // This class implements 2)'s request. 581 // This class implements 2)'s request.
512 class ChangesListNextPageRequest : public DriveApiDataRequest { 582 class ChangesListNextPageRequest : public DriveApiDataRequest<ChangeList> {
513 public: 583 public:
514 ChangesListNextPageRequest(RequestSender* sender, 584 ChangesListNextPageRequest(RequestSender* sender,
515 const ChangeListCallback& callback); 585 const ChangeListCallback& callback);
516 virtual ~ChangesListNextPageRequest(); 586 virtual ~ChangesListNextPageRequest();
517 587
518 const GURL& next_link() const { return next_link_; } 588 const GURL& next_link() const { return next_link_; }
519 void set_next_link(const GURL& next_link) { next_link_ = next_link; } 589 void set_next_link(const GURL& next_link) { next_link_ = next_link; }
520 590
521 protected: 591 protected:
522 // Overridden from DriveApiDataRequest. 592 // Overridden from DriveApiDataRequest.
523 virtual GURL GetURLInternal() const OVERRIDE; 593 virtual GURL GetURLInternal() const OVERRIDE;
524 594
525 private: 595 private:
526 GURL next_link_; 596 GURL next_link_;
527 597
528 DISALLOW_COPY_AND_ASSIGN(ChangesListNextPageRequest); 598 DISALLOW_COPY_AND_ASSIGN(ChangesListNextPageRequest);
529 }; 599 };
530 600
531 //============================= AppsListRequest ============================ 601 //============================= AppsListRequest ============================
532 602
533 // This class performs the request for fetching AppList. 603 // This class performs the request for fetching AppList.
534 // This request is mapped to 604 // This request is mapped to
535 // https://developers.google.com/drive/v2/reference/apps/list 605 // https://developers.google.com/drive/v2/reference/apps/list
536 class AppsListRequest : public DriveApiDataRequest { 606 class AppsListRequest : public DriveApiDataRequest<AppList> {
537 public: 607 public:
538 AppsListRequest(RequestSender* sender, 608 AppsListRequest(RequestSender* sender,
539 const DriveApiUrlGenerator& url_generator, 609 const DriveApiUrlGenerator& url_generator,
540 bool use_internal_endpoint, 610 bool use_internal_endpoint,
541 const AppListCallback& callback); 611 const AppListCallback& callback);
542 virtual ~AppsListRequest(); 612 virtual ~AppsListRequest();
543 613
544 protected: 614 protected:
545 // Overridden from DriveApiDataRequest. 615 // Overridden from DriveApiDataRequest.
546 virtual GURL GetURLInternal() const OVERRIDE; 616 virtual GURL GetURLInternal() const OVERRIDE;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 PermissionRole role_; 959 PermissionRole role_;
890 std::string value_; 960 std::string value_;
891 961
892 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest); 962 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest);
893 }; 963 };
894 964
895 } // namespace drive 965 } // namespace drive
896 } // namespace google_apis 966 } // namespace google_apis
897 967
898 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ 968 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_
OLDNEW
« no previous file with comments | « google_apis/drive/base_requests_unittest.cc ('k') | google_apis/drive/drive_api_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698