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

Side by Side Diff: chrome/browser/google_apis/drive_api_requests.h

Issue 23757004: Refactor InsertResourceRequest and DeleteResourceRequest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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
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 CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_
6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 std::string* upload_content) OVERRIDE; 463 std::string* upload_content) OVERRIDE;
464 private: 464 private:
465 const DriveApiUrlGenerator url_generator_; 465 const DriveApiUrlGenerator url_generator_;
466 const std::string resource_id_; 466 const std::string resource_id_;
467 const std::string parent_resource_id_; 467 const std::string parent_resource_id_;
468 const std::string new_title_; 468 const std::string new_title_;
469 469
470 DISALLOW_COPY_AND_ASSIGN(MoveResourceRequest); 470 DISALLOW_COPY_AND_ASSIGN(MoveResourceRequest);
471 }; 471 };
472 472
473 //========================== InsertResourceRequest =========================== 473 //========================== ChildrenInsertRequest ============================
474 474
475 // This class performs the request for inserting a resource to a directory. 475 // This class performs the request for inserting a resource to a directory.
476 // Note that this is the request of "Children: insert" of the Drive API v2. 476 // This request is mapped to
477 // https://developers.google.com/drive/v2/reference/children/insert. 477 // https://developers.google.com/drive/v2/reference/children/insert
478 class InsertResourceRequest : public EntryActionRequest { 478 class ChildrenInsertRequest : public EntryActionRequest {
479 public: 479 public:
480 // |callback| must not be null. 480 ChildrenInsertRequest(RequestSender* sender,
481 InsertResourceRequest(RequestSender* sender,
482 const DriveApiUrlGenerator& url_generator, 481 const DriveApiUrlGenerator& url_generator,
483 const std::string& parent_resource_id,
484 const std::string& resource_id,
485 const EntryActionCallback& callback); 482 const EntryActionCallback& callback);
486 virtual ~InsertResourceRequest(); 483 virtual ~ChildrenInsertRequest();
484
485 // Required parameter.
486 const std::string& folder_id() const { return folder_id_; }
487 void set_folder_id(const std::string& folder_id) {
488 folder_id_ = folder_id;
489 }
490
491 // Required body.
492 const std::string& id() const { return id_; }
493 void set_id(const std::string& id) { id_ = id; }
487 494
488 protected: 495 protected:
489 // UrlFetchRequestBase overrides. 496 // UrlFetchRequestBase overrides.
497 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE;
490 virtual GURL GetURL() const OVERRIDE; 498 virtual GURL GetURL() const OVERRIDE;
491 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE;
492 virtual bool GetContentData(std::string* upload_content_type, 499 virtual bool GetContentData(std::string* upload_content_type,
493 std::string* upload_content) OVERRIDE; 500 std::string* upload_content) OVERRIDE;
494 501
495 private: 502 private:
496 const DriveApiUrlGenerator url_generator_; 503 const DriveApiUrlGenerator url_generator_;
497 const std::string parent_resource_id_; 504 std::string folder_id_;
498 const std::string resource_id_; 505 std::string id_;
499 506
500 DISALLOW_COPY_AND_ASSIGN(InsertResourceRequest); 507 DISALLOW_COPY_AND_ASSIGN(ChildrenInsertRequest);
501 }; 508 };
502 509
503 //========================== DeleteResourceRequest =========================== 510 //========================== ChildrenDeleteRequest ============================
504 511
505 // This class performs the request for removing a resource from a directory. 512 // This class performs the request for removing a resource from a directory.
506 // Note that we use "delete" for the name of this class, which comes from the 513 // This request is mapped to
507 // request name of the Drive API v2, although we prefer "remove" for that 514 // https://developers.google.com/drive/v2/reference/children/delete
508 // sense in "drive/google_api" 515 class ChildrenDeleteRequest : public EntryActionRequest {
509 // Also note that this is the request of "Children: delete" of the Drive API
510 // v2. https://developers.google.com/drive/v2/reference/children/delete
511 class DeleteResourceRequest : public EntryActionRequest {
512 public: 516 public:
513 // |callback| must not be null. 517 // |callback| must not be null.
514 DeleteResourceRequest(RequestSender* sender, 518 ChildrenDeleteRequest(RequestSender* sender,
515 const DriveApiUrlGenerator& url_generator, 519 const DriveApiUrlGenerator& url_generator,
516 const std::string& parent_resource_id,
517 const std::string& resource_id,
518 const EntryActionCallback& callback); 520 const EntryActionCallback& callback);
519 virtual ~DeleteResourceRequest(); 521 virtual ~ChildrenDeleteRequest();
522
523 // Required parameter.
524 const std::string& child_id() const { return child_id_; }
525 void set_child_id(const std::string& child_id) {
526 child_id_ = child_id;
527 }
528
529 const std::string& folder_id() const { return folder_id_; }
530 void set_folder_id(const std::string& folder_id) {
531 folder_id_ = folder_id;
532 }
520 533
521 protected: 534 protected:
522 // UrlFetchRequestBase overrides. 535 // UrlFetchRequestBase overrides.
536 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE;
523 virtual GURL GetURL() const OVERRIDE; 537 virtual GURL GetURL() const OVERRIDE;
524 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE;
525 538
526 private: 539 private:
527 const DriveApiUrlGenerator url_generator_; 540 const DriveApiUrlGenerator url_generator_;
528 const std::string parent_resource_id_; 541 std::string child_id_;
529 const std::string resource_id_; 542 std::string folder_id_;
530 543
531 DISALLOW_COPY_AND_ASSIGN(DeleteResourceRequest); 544 DISALLOW_COPY_AND_ASSIGN(ChildrenDeleteRequest);
532 }; 545 };
533 546
534 //======================= InitiateUploadNewFileRequest ======================= 547 //======================= InitiateUploadNewFileRequest =======================
535 548
536 // This class performs the request for initiating the upload of a new file. 549 // This class performs the request for initiating the upload of a new file.
537 class InitiateUploadNewFileRequest : public InitiateUploadRequestBase { 550 class InitiateUploadNewFileRequest : public InitiateUploadRequestBase {
538 public: 551 public:
539 // |parent_resource_id| should be the resource id of the parent directory. 552 // |parent_resource_id| should be the resource id of the parent directory.
540 // |title| should be set. 553 // |title| should be set.
541 // See also the comments of InitiateUploadRequestBase for more details 554 // See also the comments of InitiateUploadRequestBase for more details
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 const ProgressCallback& progress_callback); 691 const ProgressCallback& progress_callback);
679 virtual ~DownloadFileRequest(); 692 virtual ~DownloadFileRequest();
680 693
681 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); 694 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest);
682 }; 695 };
683 696
684 } // namespace drive 697 } // namespace drive
685 } // namespace google_apis 698 } // namespace google_apis
686 699
687 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ 700 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_
OLDNEW
« no previous file with comments | « chrome/browser/drive/drive_api_service.cc ('k') | chrome/browser/google_apis/drive_api_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698