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

Side by Side Diff: chrome/browser/drive/drive_uploader.h

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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.cc ('k') | chrome/browser/drive/drive_uploader.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 CHROME_BROWSER_DRIVE_DRIVE_UPLOADER_H_ 5 #ifndef CHROME_BROWSER_DRIVE_DRIVE_UPLOADER_H_
6 #define CHROME_BROWSER_DRIVE_DRIVE_UPLOADER_H_ 6 #define CHROME_BROWSER_DRIVE_DRIVE_UPLOADER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 25 matching lines...) Expand all
36 typedef base::Callback<void( 36 typedef base::Callback<void(
37 google_apis::DriveApiErrorCode error, 37 google_apis::DriveApiErrorCode error,
38 const GURL& upload_location, 38 const GURL& upload_location,
39 scoped_ptr<google_apis::FileResource> resource_entry)> 39 scoped_ptr<google_apis::FileResource> resource_entry)>
40 UploadCompletionCallback; 40 UploadCompletionCallback;
41 41
42 class DriveUploaderInterface { 42 class DriveUploaderInterface {
43 public: 43 public:
44 virtual ~DriveUploaderInterface() {} 44 virtual ~DriveUploaderInterface() {}
45 45
46 // Starts batch processing for upload requests. All requests which upload
47 // small files (less than kMaxMultipartUploadSize) between
48 // |StartBatchProcessing| and |StopBatchProcessing| are sent as a single batch
49 // request.
50 virtual void StartBatchProcessing() = 0;
51
52 // Stops batch processing. Must be called after calling |StartBatchProcessing|
53 // to commit requests.
54 virtual void StopBatchProcessing() = 0;
55
56 // Uploads a new file to a directory specified by |upload_location|. 46 // Uploads a new file to a directory specified by |upload_location|.
57 // Returns a callback for cancelling the uploading job. 47 // Returns a callback for cancelling the uploading job.
58 // 48 //
59 // parent_resource_id: 49 // parent_resource_id:
60 // resource id of the destination directory. 50 // resource id of the destination directory.
61 // 51 //
62 // local_file_path: 52 // local_file_path:
63 // The path to the local file to be uploaded. 53 // The path to the local file to be uploaded.
64 // 54 //
65 // title: 55 // title:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const google_apis::ProgressCallback& progress_callback) = 0; 107 const google_apis::ProgressCallback& progress_callback) = 0;
118 }; 108 };
119 109
120 class DriveUploader : public DriveUploaderInterface { 110 class DriveUploader : public DriveUploaderInterface {
121 public: 111 public:
122 DriveUploader(DriveServiceInterface* drive_service, 112 DriveUploader(DriveServiceInterface* drive_service,
123 const scoped_refptr<base::TaskRunner>& blocking_task_runner); 113 const scoped_refptr<base::TaskRunner>& blocking_task_runner);
124 ~DriveUploader() override; 114 ~DriveUploader() override;
125 115
126 // DriveUploaderInterface overrides. 116 // DriveUploaderInterface overrides.
127 void StartBatchProcessing() override;
128 void StopBatchProcessing() override;
129 google_apis::CancelCallback UploadNewFile( 117 google_apis::CancelCallback UploadNewFile(
130 const std::string& parent_resource_id, 118 const std::string& parent_resource_id,
131 const base::FilePath& local_file_path, 119 const base::FilePath& local_file_path,
132 const std::string& title, 120 const std::string& title,
133 const std::string& content_type, 121 const std::string& content_type,
134 const UploadNewFileOptions& options, 122 const UploadNewFileOptions& options,
135 const UploadCompletionCallback& callback, 123 const UploadCompletionCallback& callback,
136 const google_apis::ProgressCallback& progress_callback) override; 124 const google_apis::ProgressCallback& progress_callback) override;
137 google_apis::CancelCallback UploadExistingFile( 125 google_apis::CancelCallback UploadExistingFile(
138 const std::string& resource_id, 126 const std::string& resource_id,
139 const base::FilePath& local_file_path, 127 const base::FilePath& local_file_path,
140 const std::string& content_type, 128 const std::string& content_type,
141 const UploadExistingFileOptions& options, 129 const UploadExistingFileOptions& options,
142 const UploadCompletionCallback& callback, 130 const UploadCompletionCallback& callback,
143 const google_apis::ProgressCallback& progress_callback) override; 131 const google_apis::ProgressCallback& progress_callback) override;
144 google_apis::CancelCallback ResumeUploadFile( 132 google_apis::CancelCallback ResumeUploadFile(
145 const GURL& upload_location, 133 const GURL& upload_location,
146 const base::FilePath& local_file_path, 134 const base::FilePath& local_file_path,
147 const std::string& content_type, 135 const std::string& content_type,
148 const UploadCompletionCallback& callback, 136 const UploadCompletionCallback& callback,
149 const google_apis::ProgressCallback& progress_callback) override; 137 const google_apis::ProgressCallback& progress_callback) override;
150 138
151 private: 139 private:
152 class RefCountedBatchRequest;
153 struct UploadFileInfo; 140 struct UploadFileInfo;
154 typedef base::Callback<void(scoped_ptr<UploadFileInfo> upload_file_info)> 141 typedef base::Callback<void(scoped_ptr<UploadFileInfo> upload_file_info)>
155 StartInitiateUploadCallback; 142 StartInitiateUploadCallback;
156 143
157 // Starts uploading a file with |upload_file_info|. 144 // Starts uploading a file with |upload_file_info|.
158 google_apis::CancelCallback StartUploadFile( 145 google_apis::CancelCallback StartUploadFile(
159 scoped_ptr<UploadFileInfo> upload_file_info, 146 scoped_ptr<UploadFileInfo> upload_file_info,
160 const StartInitiateUploadCallback& start_initiate_upload_callback); 147 const StartInitiateUploadCallback& start_initiate_upload_callback);
161 void StartUploadFileAfterGetFileSize( 148 void StartUploadFileAfterGetFileSize(
162 scoped_ptr<UploadFileInfo> upload_file_info, 149 scoped_ptr<UploadFileInfo> upload_file_info,
163 const StartInitiateUploadCallback& start_initiate_upload_callback, 150 const StartInitiateUploadCallback& start_initiate_upload_callback,
164 bool get_file_size_result); 151 bool get_file_size_result);
165 152
166 // Checks file size and call InitiateUploadNewFile or MultipartUploadNewFile 153 // Checks file size and call InitiateUploadNewFile or MultipartUploadNewFile
167 // API. Upon completion, OnUploadLocationReceived (for InitiateUploadNewFile) 154 // API. Upon completion, OnUploadLocationReceived (for InitiateUploadNewFile)
168 // or OnMultipartUploadComplete (for MultipartUploadNewFile) should be called. 155 // or OnMultipartUploadComplete (for MultipartUploadNewFile) should be called.
169 // If |batch_request| is non-null, it calls the API function on the batch 156 void CallUploadServiceAPINewFile(const std::string& parent_resource_id,
170 // request. 157 const std::string& title,
171 void CallUploadServiceAPINewFile( 158 const UploadNewFileOptions& options,
172 const std::string& parent_resource_id, 159 scoped_ptr<UploadFileInfo> upload_file_info);
173 const std::string& title,
174 const UploadNewFileOptions& options,
175 const scoped_refptr<RefCountedBatchRequest>& batch_request,
176 scoped_ptr<UploadFileInfo> upload_file_info);
177 160
178 // Checks file size and call InitiateUploadExistingFile or 161 // Checks file size and call InitiateUploadExistingFile or
179 // MultipartUploadExistingFile API. Upon completion, OnUploadLocationReceived 162 // MultipartUploadExistingFile API. Upon completion, OnUploadLocationReceived
180 // (for InitiateUploadExistingFile) or OnMultipartUploadComplete (for 163 // (for InitiateUploadExistingFile) or OnMultipartUploadComplete (for
181 // MultipartUploadExistingFile) should be called. 164 // MultipartUploadExistingFile) should be called.
182 // If |batch_request| is non-null, it calls the API function on the batch
183 // request.
184 void CallUploadServiceAPIExistingFile( 165 void CallUploadServiceAPIExistingFile(
185 const std::string& resource_id, 166 const std::string& resource_id,
186 const UploadExistingFileOptions& options, 167 const UploadExistingFileOptions& options,
187 const scoped_refptr<RefCountedBatchRequest>& batch_request,
188 scoped_ptr<UploadFileInfo> upload_file_info); 168 scoped_ptr<UploadFileInfo> upload_file_info);
189 169
190 // DriveService callback for InitiateUpload. 170 // DriveService callback for InitiateUpload.
191 void OnUploadLocationReceived(scoped_ptr<UploadFileInfo> upload_file_info, 171 void OnUploadLocationReceived(scoped_ptr<UploadFileInfo> upload_file_info,
192 google_apis::DriveApiErrorCode code, 172 google_apis::DriveApiErrorCode code,
193 const GURL& upload_location); 173 const GURL& upload_location);
194 174
195 // Starts to get the current upload status for the file uploading. 175 // Starts to get the current upload status for the file uploading.
196 // Upon completion, OnUploadRangeResponseReceived should be called. 176 // Upon completion, OnUploadRangeResponseReceived should be called.
197 void StartGetUploadStatus(scoped_ptr<UploadFileInfo> upload_file_info); 177 void StartGetUploadStatus(scoped_ptr<UploadFileInfo> upload_file_info);
(...skipping 22 matching lines...) Expand all
220 scoped_ptr<google_apis::FileResource> entry); 200 scoped_ptr<google_apis::FileResource> entry);
221 201
222 // The class is expected to run on UI thread. 202 // The class is expected to run on UI thread.
223 base::ThreadChecker thread_checker_; 203 base::ThreadChecker thread_checker_;
224 204
225 // The lifetime of this object should be guaranteed to exceed that of the 205 // The lifetime of this object should be guaranteed to exceed that of the
226 // DriveUploader instance. 206 // DriveUploader instance.
227 DriveServiceInterface* drive_service_; // Not owned by this class. 207 DriveServiceInterface* drive_service_; // Not owned by this class.
228 208
229 scoped_refptr<base::TaskRunner> blocking_task_runner_; 209 scoped_refptr<base::TaskRunner> blocking_task_runner_;
230 scoped_refptr<RefCountedBatchRequest> current_batch_request_;
231 210
232 // Note: This should remain the last member so it'll be destroyed and 211 // Note: This should remain the last member so it'll be destroyed and
233 // invalidate its weak pointers before any other members are destroyed. 212 // invalidate its weak pointers before any other members are destroyed.
234 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_; 213 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_;
235 DISALLOW_COPY_AND_ASSIGN(DriveUploader); 214 DISALLOW_COPY_AND_ASSIGN(DriveUploader);
236 }; 215 };
237 216
238 } // namespace drive 217 } // namespace drive
239 218
240 #endif // CHROME_BROWSER_DRIVE_DRIVE_UPLOADER_H_ 219 #endif // CHROME_BROWSER_DRIVE_DRIVE_UPLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.cc ('k') | chrome/browser/drive/drive_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698