summaryrefslogtreecommitdiffstats
path: root/chrome/browser/drive
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 01:22:53 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 01:22:53 +0000
commitca84f5075f630fc803cf19ca2d3a422a5091a46e (patch)
treec9d9b2d6ae2999dd3bb85301693d7401c0cd3709 /chrome/browser/drive
parent0d2ab2595f8c26da2d293f52bd5ec4a148c317ac (diff)
downloadchromium_src-ca84f5075f630fc803cf19ca2d3a422a5091a46e.zip
chromium_src-ca84f5075f630fc803cf19ca2d3a422a5091a46e.tar.gz
chromium_src-ca84f5075f630fc803cf19ca2d3a422a5091a46e.tar.bz2
Avoid uploading >=2GB data to Drive in a single request.
BUG=264089 TEST=Manually tested that a 3GB file is succesfully uploaded. R=hidehiko@chromium.org Review URL: https://codereview.chromium.org/20150006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/drive')
-rw-r--r--chrome/browser/drive/drive_uploader.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/chrome/browser/drive/drive_uploader.cc b/chrome/browser/drive/drive_uploader.cc
index 0d4866a..493a763 100644
--- a/chrome/browser/drive/drive_uploader.cc
+++ b/chrome/browser/drive/drive_uploader.cc
@@ -34,6 +34,15 @@ using google_apis::UploadRangeResponse;
namespace drive {
+namespace {
+// Upload data is split to multiple HTTP request each conveying kUploadChunkSize
+// bytes (except the request for uploading the last chunk of data).
+// The value must be a multiple of 512KB according to the spec of GData WAPI and
+// Drive API v2. It is set to a smaller value than 2^31 for working around
+// server side error (crbug.com/264089).
+const int64 kUploadChunkSize = (1LL << 30); // 1GB
+} // namespace
+
// Structure containing current upload information of file, passed between
// DriveServiceInterface methods and callbacks.
struct DriveUploader::UploadFileInfo {
@@ -316,11 +325,15 @@ void DriveUploader::UploadNextChunk(
return;
}
+ // Limit the size of data uploaded per each request by kUploadChunkSize.
+ const int64 end_position = std::min(upload_file_info->content_length,
+ start_position + kUploadChunkSize);
+
UploadFileInfo* info_ptr = upload_file_info.get();
info_ptr->cancel_callback = drive_service_->ResumeUpload(
info_ptr->upload_location,
start_position,
- info_ptr->content_length,
+ end_position,
info_ptr->content_length,
info_ptr->content_type,
info_ptr->file_path,