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

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

Issue 1132693006: Drive API: Simplify lifetime management of child requests in BatchUploadRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve comment. Created 5 years, 7 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
« no previous file with comments | « no previous file | google_apis/drive/base_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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 const base::FilePath& local_file_path, 179 const base::FilePath& local_file_path,
180 const UploadNewFileOptions& options, 180 const UploadNewFileOptions& options,
181 const google_apis::FileResourceCallback& callback, 181 const google_apis::FileResourceCallback& callback,
182 const google_apis::ProgressCallback& progress_callback) { 182 const google_apis::ProgressCallback& progress_callback) {
183 DCHECK(CalledOnValidThread()); 183 DCHECK(CalledOnValidThread());
184 DCHECK(!callback.is_null()); 184 DCHECK(!callback.is_null());
185 185
186 DCHECK(batch_request_); 186 DCHECK(batch_request_);
187 187
188 batch_request_->AddRequest( 188 batch_request_->AddRequest(
189 new google_apis::drive::MultipartUploadNewFileRequest( 189 new google_apis::drive::MultipartUploadNewFileDelegate(
190 batch_request_->sender(), title, parent_resource_id, content_type, 190 batch_request_->sender(), title, parent_resource_id, content_type,
191 content_length, options.modified_date, options.last_viewed_by_me_date, 191 content_length, options.modified_date, options.last_viewed_by_me_date,
192 local_file_path, options.properties, batch_request_->url_generator(), 192 local_file_path, options.properties, batch_request_->url_generator(),
193 callback, progress_callback)); 193 callback, progress_callback));
194 return cancel_callback_; 194 return cancel_callback_;
195 } 195 }
196 196
197 google_apis::CancelCallback 197 google_apis::CancelCallback
198 BatchRequestConfigurator::MultipartUploadExistingFile( 198 BatchRequestConfigurator::MultipartUploadExistingFile(
199 const std::string& content_type, 199 const std::string& content_type,
200 int64 content_length, 200 int64 content_length,
201 const std::string& resource_id, 201 const std::string& resource_id,
202 const base::FilePath& local_file_path, 202 const base::FilePath& local_file_path,
203 const UploadExistingFileOptions& options, 203 const UploadExistingFileOptions& options,
204 const google_apis::FileResourceCallback& callback, 204 const google_apis::FileResourceCallback& callback,
205 const google_apis::ProgressCallback& progress_callback) { 205 const google_apis::ProgressCallback& progress_callback) {
206 DCHECK(CalledOnValidThread()); 206 DCHECK(CalledOnValidThread());
207 DCHECK(!callback.is_null()); 207 DCHECK(!callback.is_null());
208 DCHECK(batch_request_); 208 DCHECK(batch_request_);
209 209
210 batch_request_->AddRequest( 210 batch_request_->AddRequest(
211 new google_apis::drive::MultipartUploadExistingFileRequest( 211 new google_apis::drive::MultipartUploadExistingFileDelegate(
212 batch_request_->sender(), options.title, resource_id, 212 batch_request_->sender(), options.title, resource_id,
213 options.parent_resource_id, content_type, content_length, 213 options.parent_resource_id, content_type, content_length,
214 options.modified_date, options.last_viewed_by_me_date, 214 options.modified_date, options.last_viewed_by_me_date,
215 local_file_path, options.etag, options.properties, 215 local_file_path, options.etag, options.properties,
216 batch_request_->url_generator(), callback, progress_callback)); 216 batch_request_->url_generator(), callback, progress_callback));
217 return cancel_callback_; 217 return cancel_callback_;
218 } 218 }
219 219
220 void BatchRequestConfigurator::Commit() { 220 void BatchRequestConfigurator::Commit() {
221 DCHECK(CalledOnValidThread()); 221 DCHECK(CalledOnValidThread());
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 const std::string& parent_resource_id, 705 const std::string& parent_resource_id,
706 const std::string& title, 706 const std::string& title,
707 const base::FilePath& local_file_path, 707 const base::FilePath& local_file_path,
708 const drive::UploadNewFileOptions& options, 708 const drive::UploadNewFileOptions& options,
709 const FileResourceCallback& callback, 709 const FileResourceCallback& callback,
710 const google_apis::ProgressCallback& progress_callback) { 710 const google_apis::ProgressCallback& progress_callback) {
711 DCHECK(thread_checker_.CalledOnValidThread()); 711 DCHECK(thread_checker_.CalledOnValidThread());
712 DCHECK(!callback.is_null()); 712 DCHECK(!callback.is_null());
713 713
714 return sender_->StartRequestWithRetry( 714 return sender_->StartRequestWithRetry(
715 new google_apis::drive::MultipartUploadNewFileRequest( 715 new google_apis::drive::SingleBatchableDelegateRequest(
716 sender_.get(), title, parent_resource_id, content_type, 716 sender_.get(),
717 content_length, options.modified_date, options.last_viewed_by_me_date, 717 new google_apis::drive::MultipartUploadNewFileDelegate(
718 local_file_path, options.properties, url_generator_, callback, 718 sender_.get(), title, parent_resource_id, content_type,
719 progress_callback)); 719 content_length, options.modified_date,
720 options.last_viewed_by_me_date, local_file_path,
721 options.properties, url_generator_, callback,
722 progress_callback)));
720 } 723 }
721 724
722 CancelCallback DriveAPIService::MultipartUploadExistingFile( 725 CancelCallback DriveAPIService::MultipartUploadExistingFile(
723 const std::string& content_type, 726 const std::string& content_type,
724 int64 content_length, 727 int64 content_length,
725 const std::string& resource_id, 728 const std::string& resource_id,
726 const base::FilePath& local_file_path, 729 const base::FilePath& local_file_path,
727 const drive::UploadExistingFileOptions& options, 730 const drive::UploadExistingFileOptions& options,
728 const FileResourceCallback& callback, 731 const FileResourceCallback& callback,
729 const google_apis::ProgressCallback& progress_callback) { 732 const google_apis::ProgressCallback& progress_callback) {
730 DCHECK(thread_checker_.CalledOnValidThread()); 733 DCHECK(thread_checker_.CalledOnValidThread());
731 DCHECK(!callback.is_null()); 734 DCHECK(!callback.is_null());
732 735
733 return sender_->StartRequestWithRetry( 736 return sender_->StartRequestWithRetry(
734 new google_apis::drive::MultipartUploadExistingFileRequest( 737 new google_apis::drive::SingleBatchableDelegateRequest(
735 sender_.get(), options.title, resource_id, options.parent_resource_id, 738 sender_.get(),
736 content_type, content_length, options.modified_date, 739 new google_apis::drive::MultipartUploadExistingFileDelegate(
737 options.last_viewed_by_me_date, local_file_path, options.etag, 740 sender_.get(), options.title, resource_id,
738 options.properties, url_generator_, callback, progress_callback)); 741 options.parent_resource_id, content_type, content_length,
742 options.modified_date, options.last_viewed_by_me_date,
743 local_file_path, options.etag, options.properties, url_generator_,
744 callback, progress_callback)));
739 } 745 }
740 746
741 CancelCallback DriveAPIService::AuthorizeApp( 747 CancelCallback DriveAPIService::AuthorizeApp(
742 const std::string& resource_id, 748 const std::string& resource_id,
743 const std::string& app_id, 749 const std::string& app_id,
744 const AuthorizeAppCallback& callback) { 750 const AuthorizeAppCallback& callback) {
745 DCHECK(thread_checker_.CalledOnValidThread()); 751 DCHECK(thread_checker_.CalledOnValidThread());
746 DCHECK(!callback.is_null()); 752 DCHECK(!callback.is_null());
747 753
748 // Files.Authorize is only available for whitelisted clients like official 754 // Files.Authorize is only available for whitelisted clients like official
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 // RequestSender before the request is committed because the request has a 864 // RequestSender before the request is committed because the request has a
859 // reference to RequestSender and we should ensure to delete the request when 865 // reference to RequestSender and we should ensure to delete the request when
860 // the sender is deleted. Resolve the circulating dependency and fix it. 866 // the sender is deleted. Resolve the circulating dependency and fix it.
861 const google_apis::CancelCallback callback = 867 const google_apis::CancelCallback callback =
862 sender_->StartRequestWithRetry(request.release()); 868 sender_->StartRequestWithRetry(request.release());
863 return make_scoped_ptr<BatchRequestConfiguratorInterface>( 869 return make_scoped_ptr<BatchRequestConfiguratorInterface>(
864 new BatchRequestConfigurator(weak_ref, callback)); 870 new BatchRequestConfigurator(weak_ref, callback));
865 } 871 }
866 872
867 } // namespace drive 873 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | google_apis/drive/base_requests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698