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

Side by Side Diff: chrome/browser/drive/drive_api_service.cc

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
« no previous file with comments | « no previous file | chrome/browser/google_apis/drive_api_requests.h » ('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 #include "chrome/browser/drive/drive_api_service.h" 5 #include "chrome/browser/drive/drive_api_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 using google_apis::Link; 47 using google_apis::Link;
48 using google_apis::ProgressCallback; 48 using google_apis::ProgressCallback;
49 using google_apis::RequestSender; 49 using google_apis::RequestSender;
50 using google_apis::ResourceEntry; 50 using google_apis::ResourceEntry;
51 using google_apis::ResourceList; 51 using google_apis::ResourceList;
52 using google_apis::UploadRangeCallback; 52 using google_apis::UploadRangeCallback;
53 using google_apis::UploadRangeResponse; 53 using google_apis::UploadRangeResponse;
54 using google_apis::drive::AboutGetRequest; 54 using google_apis::drive::AboutGetRequest;
55 using google_apis::drive::AppsListRequest; 55 using google_apis::drive::AppsListRequest;
56 using google_apis::drive::ChangesListRequest; 56 using google_apis::drive::ChangesListRequest;
57 using google_apis::drive::ChildrenDeleteRequest;
58 using google_apis::drive::ChildrenInsertRequest;
57 using google_apis::drive::ContinueGetFileListRequest; 59 using google_apis::drive::ContinueGetFileListRequest;
58 using google_apis::drive::DeleteResourceRequest;
59 using google_apis::drive::DownloadFileRequest; 60 using google_apis::drive::DownloadFileRequest;
60 using google_apis::drive::FilesCopyRequest; 61 using google_apis::drive::FilesCopyRequest;
61 using google_apis::drive::FilesGetRequest; 62 using google_apis::drive::FilesGetRequest;
62 using google_apis::drive::FilesInsertRequest; 63 using google_apis::drive::FilesInsertRequest;
63 using google_apis::drive::FilesPatchRequest; 64 using google_apis::drive::FilesPatchRequest;
64 using google_apis::drive::FilesListRequest; 65 using google_apis::drive::FilesListRequest;
65 using google_apis::drive::FilesTrashRequest; 66 using google_apis::drive::FilesTrashRequest;
66 using google_apis::drive::GetUploadStatusRequest; 67 using google_apis::drive::GetUploadStatusRequest;
67 using google_apis::drive::InitiateUploadExistingFileRequest; 68 using google_apis::drive::InitiateUploadExistingFileRequest;
68 using google_apis::drive::InitiateUploadNewFileRequest; 69 using google_apis::drive::InitiateUploadNewFileRequest;
69 using google_apis::drive::InsertResourceRequest;
70 using google_apis::drive::ResumeUploadRequest; 70 using google_apis::drive::ResumeUploadRequest;
71 71
72 namespace drive { 72 namespace drive {
73 73
74 namespace { 74 namespace {
75 75
76 // OAuth2 scopes for Drive API. 76 // OAuth2 scopes for Drive API.
77 const char kDriveScope[] = "https://www.googleapis.com/auth/drive"; 77 const char kDriveScope[] = "https://www.googleapis.com/auth/drive";
78 const char kDriveAppsReadonlyScope[] = 78 const char kDriveAppsReadonlyScope[] =
79 "https://www.googleapis.com/auth/drive.apps.readonly"; 79 "https://www.googleapis.com/auth/drive.apps.readonly";
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 return sender_->StartRequestWithRetry(request); 705 return sender_->StartRequestWithRetry(request);
706 } 706 }
707 707
708 CancelCallback DriveAPIService::AddResourceToDirectory( 708 CancelCallback DriveAPIService::AddResourceToDirectory(
709 const std::string& parent_resource_id, 709 const std::string& parent_resource_id,
710 const std::string& resource_id, 710 const std::string& resource_id,
711 const EntryActionCallback& callback) { 711 const EntryActionCallback& callback) {
712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
713 DCHECK(!callback.is_null()); 713 DCHECK(!callback.is_null());
714 714
715 return sender_->StartRequestWithRetry( 715 ChildrenInsertRequest* request =
716 new InsertResourceRequest( 716 new ChildrenInsertRequest(sender_.get(), url_generator_, callback);
717 sender_.get(), 717 request->set_folder_id(parent_resource_id);
718 url_generator_, 718 request->set_id(resource_id);
719 parent_resource_id, 719 return sender_->StartRequestWithRetry(request);
720 resource_id,
721 callback));
722 } 720 }
723 721
724 CancelCallback DriveAPIService::RemoveResourceFromDirectory( 722 CancelCallback DriveAPIService::RemoveResourceFromDirectory(
725 const std::string& parent_resource_id, 723 const std::string& parent_resource_id,
726 const std::string& resource_id, 724 const std::string& resource_id,
727 const EntryActionCallback& callback) { 725 const EntryActionCallback& callback) {
728 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 726 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
729 DCHECK(!callback.is_null()); 727 DCHECK(!callback.is_null());
730 728
731 return sender_->StartRequestWithRetry( 729 ChildrenDeleteRequest* request =
732 new DeleteResourceRequest( 730 new ChildrenDeleteRequest(sender_.get(), url_generator_, callback);
733 sender_.get(), 731 request->set_child_id(resource_id);
734 url_generator_, 732 request->set_folder_id(parent_resource_id);
735 parent_resource_id, 733 return sender_->StartRequestWithRetry(request);
736 resource_id,
737 callback));
738 } 734 }
739 735
740 CancelCallback DriveAPIService::InitiateUploadNewFile( 736 CancelCallback DriveAPIService::InitiateUploadNewFile(
741 const std::string& content_type, 737 const std::string& content_type,
742 int64 content_length, 738 int64 content_length,
743 const std::string& parent_resource_id, 739 const std::string& parent_resource_id,
744 const std::string& title, 740 const std::string& title,
745 const InitiateUploadCallback& callback) { 741 const InitiateUploadCallback& callback) {
746 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 742 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
747 DCHECK(!callback.is_null()); 743 DCHECK(!callback.is_null());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 if (CanSendRequest()) { 865 if (CanSendRequest()) {
870 FOR_EACH_OBSERVER( 866 FOR_EACH_OBSERVER(
871 DriveServiceObserver, observers_, OnReadyToSendRequests()); 867 DriveServiceObserver, observers_, OnReadyToSendRequests());
872 } else if (!HasRefreshToken()) { 868 } else if (!HasRefreshToken()) {
873 FOR_EACH_OBSERVER( 869 FOR_EACH_OBSERVER(
874 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); 870 DriveServiceObserver, observers_, OnRefreshTokenInvalid());
875 } 871 }
876 } 872 }
877 873
878 } // namespace drive 874 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google_apis/drive_api_requests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698