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

Unified Diff: chrome/browser/drive/drive_uploader.cc

Issue 1135353004: Revert of Drive: Let DriveUploader use batch request API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/drive/drive_uploader.h ('k') | chrome/browser/drive/drive_uploader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/drive_uploader.cc
diff --git a/chrome/browser/drive/drive_uploader.cc b/chrome/browser/drive/drive_uploader.cc
index f15d9c27fba2c7f853fdb7ec1a2f791c0b31857a..76709fdb6608632181e40f53271f5cbd35f5ce43 100644
--- a/chrome/browser/drive/drive_uploader.cc
+++ b/chrome/browser/drive/drive_uploader.cc
@@ -43,30 +43,6 @@
// larger than the size is processed by resumable upload.
const int64 kMaxMultipartUploadSize = (1LL << 20); // 1MB
} // namespace
-
-// Refcounted helper class to manage batch request. DriveUploader uses the class
-// for keeping the BatchRequestConfigurator instance while it prepares upload
-// file information asynchronously. DriveUploader discard the reference after
-// getting file information and the instance will be destroyed after all
-// preparations complete. At that time, the helper instance commits owned batch
-// request at the destrutor.
-class DriveUploader::RefCountedBatchRequest
- : public base::RefCounted<RefCountedBatchRequest> {
- public:
- RefCountedBatchRequest(
- scoped_ptr<BatchRequestConfiguratorInterface> configurator)
- : configurator_(configurator.Pass()) {}
-
- // Gets pointer of BatchRequestConfiguratorInterface owned by the instance.
- BatchRequestConfiguratorInterface* configurator() const {
- return configurator_.get();
- }
-
- private:
- friend class base::RefCounted<RefCountedBatchRequest>;
- ~RefCountedBatchRequest() { configurator_->Commit(); }
- scoped_ptr<BatchRequestConfiguratorInterface> configurator_;
-};
// Structure containing current upload information of file, passed between
// DriveServiceInterface methods and callbacks.
@@ -179,17 +155,7 @@
local_file_path, content_type, callback, progress_callback)),
base::Bind(&DriveUploader::CallUploadServiceAPINewFile,
weak_ptr_factory_.GetWeakPtr(), parent_resource_id, title,
- options, current_batch_request_));
-}
-
-void DriveUploader::StartBatchProcessing() {
- DCHECK(current_batch_request_ == nullptr);
- current_batch_request_ =
- new RefCountedBatchRequest(drive_service_->StartBatchRequest().Pass());
-}
-
-void DriveUploader::StopBatchProcessing() {
- current_batch_request_ = nullptr;
+ options));
}
CancelCallback DriveUploader::UploadExistingFile(
@@ -209,8 +175,7 @@
scoped_ptr<UploadFileInfo>(new UploadFileInfo(
local_file_path, content_type, callback, progress_callback)),
base::Bind(&DriveUploader::CallUploadServiceAPIExistingFile,
- weak_ptr_factory_.GetWeakPtr(), resource_id, options,
- current_batch_request_));
+ weak_ptr_factory_.GetWeakPtr(), resource_id, options));
}
CancelCallback DriveUploader::ResumeUploadFile(
@@ -225,7 +190,8 @@
DCHECK(!callback.is_null());
scoped_ptr<UploadFileInfo> upload_file_info(new UploadFileInfo(
- local_file_path, content_type, callback, progress_callback));
+ local_file_path, content_type,
+ callback, progress_callback));
upload_file_info->upload_location = upload_location;
return StartUploadFile(
@@ -277,17 +243,12 @@
const std::string& parent_resource_id,
const std::string& title,
const UploadNewFileOptions& options,
- const scoped_refptr<RefCountedBatchRequest>& batch_request,
scoped_ptr<UploadFileInfo> upload_file_info) {
DCHECK(thread_checker_.CalledOnValidThread());
UploadFileInfo* const info_ptr = upload_file_info.get();
if (info_ptr->content_length <= kMaxMultipartUploadSize) {
- DriveServiceBatchOperationsInterface* service = drive_service_;
- // If this is a batched request, calls the API on the request instead.
- if (batch_request.get())
- service = batch_request->configurator();
- info_ptr->cancel_callback = service->MultipartUploadNewFile(
+ info_ptr->cancel_callback = drive_service_->MultipartUploadNewFile(
info_ptr->content_type, info_ptr->content_length, parent_resource_id,
title, info_ptr->file_path, options,
base::Bind(&DriveUploader::OnMultipartUploadComplete,
@@ -306,17 +267,12 @@
void DriveUploader::CallUploadServiceAPIExistingFile(
const std::string& resource_id,
const UploadExistingFileOptions& options,
- const scoped_refptr<RefCountedBatchRequest>& batch_request,
scoped_ptr<UploadFileInfo> upload_file_info) {
DCHECK(thread_checker_.CalledOnValidThread());
UploadFileInfo* const info_ptr = upload_file_info.get();
if (info_ptr->content_length <= kMaxMultipartUploadSize) {
- DriveServiceBatchOperationsInterface* service = drive_service_;
- // If this is a batched request, calls the API on the request instead.
- if (batch_request.get())
- service = batch_request->configurator();
- info_ptr->cancel_callback = service->MultipartUploadExistingFile(
+ info_ptr->cancel_callback = drive_service_->MultipartUploadExistingFile(
info_ptr->content_type, info_ptr->content_length, resource_id,
info_ptr->file_path, options,
base::Bind(&DriveUploader::OnMultipartUploadComplete,
« no previous file with comments | « chrome/browser/drive/drive_uploader.h ('k') | chrome/browser/drive/drive_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698