summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-13 04:38:45 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-13 04:38:45 +0000
commitd0b03ce9d146df58a308818805f2f2d51837d52b (patch)
treed016d59ee403710bfbc38339b2dc2ca733756180
parent4bf2619fe9a26abeac4a89fc4272c42efaaa506a (diff)
downloadchromium_src-d0b03ce9d146df58a308818805f2f2d51837d52b.zip
chromium_src-d0b03ce9d146df58a308818805f2f2d51837d52b.tar.gz
chromium_src-d0b03ce9d146df58a308818805f2f2d51837d52b.tar.bz2
Remove partial file handling from DriveUploader.
Somewhile the class had dealt with the cases where the file to be uploaded is not fully filled with the final contents (i.e. still being downloaded from somewhere else). Since we have simplified the usecase and split the download phase and upload phase, now we can safely assume the whole content of the file is present at the time of UploadXXXfile(). Along the way, the patch removes some legacies (ununsed DEPS exception, and IO thread in the test). BUG=165110 Review URL: https://chromiumcodereview.appspot.com/11416362 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172820 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/drive_file_system_unittest.cc3
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation.cc57
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation.h8
-rw-r--r--chrome/browser/chromeos/drive/file_system/update_operation.cc37
-rw-r--r--chrome/browser/chromeos/drive/file_system/update_operation.h11
-rw-r--r--chrome/browser/google_apis/DEPS1
-rw-r--r--chrome/browser/google_apis/drive_uploader.cc59
-rw-r--r--chrome/browser/google_apis/drive_uploader.h26
-rw-r--r--chrome/browser/google_apis/drive_uploader_unittest.cc13
-rw-r--r--chrome/browser/sync_file_system/drive_file_sync_client.cc12
-rw-r--r--chrome/browser/sync_file_system/drive_file_sync_client.h4
-rw-r--r--chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc9
-rw-r--r--chrome/browser/sync_file_system/drive_file_sync_service.cc2
13 files changed, 38 insertions, 204 deletions
diff --git a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc
index 102597b..0375f8c 100644
--- a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc
@@ -131,8 +131,6 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const FilePath& local_file_path,
const std::string& title,
const std::string& content_type,
- int64 content_length,
- int64 file_size,
const google_apis::UploadCompletionCallback& callback) OVERRIDE {
DCHECK(!callback.is_null());
@@ -161,7 +159,6 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const FilePath& drive_file_path,
const FilePath& local_file_path,
const std::string& content_type,
- int64 file_size,
const google_apis::UploadCompletionCallback& callback) OVERRIDE {
DCHECK(!callback.is_null());
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
index 5389114..3e20e53 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
@@ -39,25 +39,6 @@ DriveFileError CopyLocalFileOnBlockingPool(const FilePath& src_file_path,
DRIVE_FILE_OK : DRIVE_FILE_ERROR_FAILED;
}
-// Gets the file size of |local_file|, and the content type for |extension|.
-// Since |local_file| can be "/dev/null" for a new file upload case, we pass
-// the (destination) extension separately from the source file name.
-DriveFileError GetLocalFileInfoOnBlockingPool(
- const FilePath& local_file,
- const FilePath::StringType& extension,
- int64* file_size,
- std::string* content_type) {
- DCHECK(file_size);
- DCHECK(content_type);
-
- if (!net::GetMimeTypeFromExtension(extension, content_type))
- *content_type = kMimeTypeOctetStream;
-
- *file_size = 0;
- return file_util::GetFileSize(local_file, file_size) ?
- DRIVE_FILE_OK : DRIVE_FILE_ERROR_NOT_FOUND;
-}
-
// Checks if a local file at |local_file_path| is a JSON file referencing a
// hosted document on blocking pool, and if so, gets the resource ID of the
// document.
@@ -193,22 +174,18 @@ void CopyOperation::TransferRegularFile(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- int64* file_size = new int64;
std::string* content_type = new std::string;
base::PostTaskAndReplyWithResult(
blocking_task_runner_,
FROM_HERE,
- base::Bind(&GetLocalFileInfoOnBlockingPool,
- local_file_path,
+ base::Bind(&net::GetMimeTypeFromExtension,
remote_dest_file_path.Extension(),
- file_size,
- content_type),
+ base::Unretained(content_type)),
base::Bind(&CopyOperation::StartFileUpload,
weak_ptr_factory_.GetWeakPtr(),
StartFileUploadParams(local_file_path,
remote_dest_file_path,
callback),
- base::Owned(file_size),
base::Owned(content_type)));
}
@@ -421,37 +398,23 @@ void CopyOperation::OnGetFileCompleteForCopy(
TransferRegularFile(local_file_path, remote_dest_file_path, callback);
}
-void CopyOperation::StartFileUpload(
- const StartFileUploadParams& params,
- int64* file_size,
- std::string* content_type,
- DriveFileError error) {
- // This method needs to run on the UI thread as required by
- // DriveUploader::UploadNewFile().
+void CopyOperation::StartFileUpload(const StartFileUploadParams& params,
+ const std::string* content_type,
+ bool got_content_type) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(file_size);
- DCHECK(content_type);
DCHECK(!params.callback.is_null());
- if (error != DRIVE_FILE_OK) {
- params.callback.Run(error);
- return;
- }
-
// Make sure the destination directory exists.
metadata_->GetEntryInfoByPath(
params.remote_file_path.DirName(),
- base::Bind(
- &CopyOperation::StartFileUploadAfterGetEntryInfo,
- weak_ptr_factory_.GetWeakPtr(),
- params,
- *file_size,
- *content_type));
+ base::Bind(&CopyOperation::StartFileUploadAfterGetEntryInfo,
+ weak_ptr_factory_.GetWeakPtr(),
+ params,
+ got_content_type ? *content_type : kMimeTypeOctetStream));
}
void CopyOperation::StartFileUploadAfterGetEntryInfo(
const StartFileUploadParams& params,
- int64 file_size,
const std::string& content_type,
DriveFileError error,
scoped_ptr<DriveEntryProto> entry_proto) {
@@ -472,8 +435,6 @@ void CopyOperation::StartFileUploadAfterGetEntryInfo(
params.local_file_path,
params.remote_file_path.BaseName().value(),
content_type,
- file_size,
- file_size,
base::Bind(&CopyOperation::OnTransferCompleted,
weak_ptr_factory_.GetWeakPtr(),
params.callback));
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.h b/chrome/browser/chromeos/drive/file_system/copy_operation.h
index 2f1756f..e16751b 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.h
@@ -173,17 +173,15 @@ class CopyOperation {
const std::string& unused_mime_type,
DriveFileType file_type);
- // Kicks off file upload once it receives |file_size| and |content_type|.
+ // Kicks off file upload once it receives |content_type|.
void StartFileUpload(const StartFileUploadParams& params,
- int64* file_size,
- std::string* content_type,
- DriveFileError error);
+ const std::string* content_type,
+ bool got_content_type);
// Part of StartFileUpload(). Called after GetEntryInfoByPath()
// is complete.
void StartFileUploadAfterGetEntryInfo(
const StartFileUploadParams& params,
- int64 file_size,
const std::string& content_type,
DriveFileError error,
scoped_ptr<DriveEntryProto> entry_proto);
diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.cc b/chrome/browser/chromeos/drive/file_system/update_operation.cc
index d0741bf..81bd1f4 100644
--- a/chrome/browser/chromeos/drive/file_system/update_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/update_operation.cc
@@ -93,48 +93,11 @@ void UpdateOperation::OnGetFileCompleteForUpdateFile(
return;
}
- // Gets the size of the cache file. Since the file is locally modified, the
- // file size information stored in DriveEntry is not correct.
- int64* file_size = new int64(0);
- base::PostTaskAndReplyWithResult(
- blocking_task_runner_,
- FROM_HERE,
- base::Bind(&file_util::GetFileSize,
- cache_file_path,
- file_size),
- base::Bind(&UpdateOperation::OnGetFileSizeCompleteForUpdateFile,
- weak_ptr_factory_.GetWeakPtr(),
- callback,
- drive_file_path,
- base::Passed(&entry_proto),
- cache_file_path,
- base::Owned(file_size)));
-}
-
-void UpdateOperation::OnGetFileSizeCompleteForUpdateFile(
- const FileOperationCallback& callback,
- const FilePath& drive_file_path,
- scoped_ptr<DriveEntryProto> entry_proto,
- const FilePath& cache_file_path,
- int64* file_size,
- bool get_file_size_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
- // |entry_proto| has been checked in UpdateFileByEntryInfo().
- DCHECK(entry_proto.get());
- DCHECK(!entry_proto->file_info().is_directory());
-
- if (!get_file_size_result) {
- callback.Run(DRIVE_FILE_ERROR_NOT_FOUND);
- return;
- }
-
uploader_->UploadExistingFile(
GURL(entry_proto->upload_url()),
drive_file_path,
cache_file_path,
entry_proto->file_specific_info().content_mime_type(),
- *file_size,
base::Bind(&UpdateOperation::OnUpdatedFileUploaded,
weak_ptr_factory_.GetWeakPtr(),
callback));
diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.h b/chrome/browser/chromeos/drive/file_system/update_operation.h
index 135d474..fce786db 100644
--- a/chrome/browser/chromeos/drive/file_system/update_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/update_operation.h
@@ -72,17 +72,6 @@ class UpdateOperation {
const FilePath& cache_file_path);
// Part of UpdateFileByResourceId().
- // Callback for getting the size of the cache file in the blocking pool.
- // |callback| must not be null.
- void OnGetFileSizeCompleteForUpdateFile(
- const FileOperationCallback& callback,
- const FilePath& drive_file_path,
- scoped_ptr<DriveEntryProto> entry_proto,
- const FilePath& cache_file_path,
- int64* file_size,
- bool get_file_size_result);
-
- // Part of UpdateFileByResourceId().
// Called when DriveUploader::UploadUpdatedFile() is completed for
// UpdateFileByResourceId().
// |callback| must not be null.
diff --git a/chrome/browser/google_apis/DEPS b/chrome/browser/google_apis/DEPS
index 79bddfc..b4f656e 100644
--- a/chrome/browser/google_apis/DEPS
+++ b/chrome/browser/google_apis/DEPS
@@ -13,7 +13,6 @@ include_rules = [
"!chrome/common/net/url_util.h",
"!chrome/common/pref_names.h",
"!content/public/browser/browser_thread.h",
- "!content/public/browser/download_item.h",
"!content/public/browser/notification_details.h",
"!content/public/browser/notification_observer.h",
"!content/public/browser/notification_registrar.h",
diff --git a/chrome/browser/google_apis/drive_uploader.cc b/chrome/browser/google_apis/drive_uploader.cc
index 6529b35..830b9a42 100644
--- a/chrome/browser/google_apis/drive_uploader.cc
+++ b/chrome/browser/google_apis/drive_uploader.cc
@@ -29,6 +29,17 @@ int ReadFileStreamOnBlockingPool(net::FileStream* file_stream,
return file_stream->ReadSync(buf->data(), bytes_to_read);
}
+// Opens |path| with |file_stream| and returns the file size.
+// If failed, returns an error code in a negative value.
+int64 OpenFileStreamAndGetSizeOnBlockingPool(net::FileStream* file_stream,
+ const FilePath& path) {
+ int result = file_stream->OpenSync(
+ path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ);
+ if (result != net::OK)
+ return result;
+ return file_stream->Available();
+}
+
} // namespace
namespace google_apis {
@@ -58,8 +69,6 @@ int DriveUploader::UploadNewFile(const GURL& upload_location,
const FilePath& local_file_path,
const std::string& title,
const std::string& content_type,
- int64 content_length,
- int64 file_size,
const UploadCompletionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!upload_location.is_empty());
@@ -76,9 +85,6 @@ int DriveUploader::UploadNewFile(const GURL& upload_location,
upload_file_info->file_path = local_file_path;
upload_file_info->title = title;
upload_file_info->content_type = content_type;
- upload_file_info->content_length = content_length;
- upload_file_info->file_size = file_size;
- upload_file_info->all_bytes_present = content_length == file_size;
upload_file_info->completion_callback = callback;
return StartUploadFile(upload_file_info.Pass());
}
@@ -115,7 +121,6 @@ int DriveUploader::UploadExistingFile(
const FilePath& drive_file_path,
const FilePath& local_file_path,
const std::string& content_type,
- int64 file_size,
const UploadCompletionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!upload_location.is_empty());
@@ -130,9 +135,6 @@ int DriveUploader::UploadExistingFile(
upload_file_info->drive_path = drive_file_path;
upload_file_info->file_path = local_file_path;
upload_file_info->content_type = content_type;
- upload_file_info->content_length = file_size;
- upload_file_info->file_size = file_size;
- upload_file_info->all_bytes_present = true;
upload_file_info->completion_callback = callback;
return StartUploadFile(upload_file_info.Pass());
}
@@ -158,10 +160,9 @@ void DriveUploader::OpenFile(UploadFileInfo* upload_file_info,
base::PostTaskAndReplyWithResult(
blocking_task_runner_.get(),
FROM_HERE,
- base::Bind(&net::FileStream::OpenSync,
+ base::Bind(&OpenFileStreamAndGetSizeOnBlockingPool,
base::Unretained(upload_file_info->file_stream.get()),
- upload_file_info->file_path,
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ),
+ upload_file_info->file_path),
base::Bind(&DriveUploader::OpenCompletionCallback,
weak_ptr_factory_.GetWeakPtr(),
open_type,
@@ -170,15 +171,14 @@ void DriveUploader::OpenFile(UploadFileInfo* upload_file_info,
void DriveUploader::OpenCompletionCallback(FileOpenType open_type,
int upload_id,
- int result) {
+ int64 file_size) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id);
if (!upload_file_info)
return;
- if (result != net::OK) {
- DCHECK_EQ(result, net::ERR_FILE_NOT_FOUND);
+ if (file_size < 0) {
UploadFailed(upload_file_info, DRIVE_UPLOAD_ERROR_NOT_FOUND);
return;
}
@@ -189,6 +189,7 @@ void DriveUploader::OpenCompletionCallback(FileOpenType open_type,
}
// Open succeeded, initiate the upload.
+ upload_file_info->content_length = file_size;
drive_service_->InitiateUpload(
InitiateUploadParams(upload_file_info->upload_mode,
upload_file_info->title,
@@ -233,28 +234,12 @@ void DriveUploader::UploadNextChunk(UploadFileInfo* upload_file_info) {
// Determine number of bytes to read for this upload iteration, which cannot
// exceed size of buf i.e. buf_len.
- const int64 bytes_remaining = upload_file_info->SizeRemaining();
const int bytes_to_read = std::min(upload_file_info->SizeRemaining(),
upload_file_info->buf_len);
- // Update the content length if the file_size is known.
- if (upload_file_info->all_bytes_present)
- upload_file_info->content_length = upload_file_info->file_size;
- else if (bytes_remaining == bytes_to_read) {
- // Wait for more data if this is the last chunk we have and we don't know
- // whether we've reached the end of the file. We won't know how much data to
- // expect until the transfer is complete (the Content-Length might be
- // incorrect or absent). If we've sent the last chunk out already when we
- // find out there's no more data, we won't be able to complete the upload.
- DVLOG(1) << "Paused upload " << upload_file_info->title;
- upload_file_info->upload_paused = true;
- return;
- }
-
if (bytes_to_read == 0) {
// This should only happen when the actual file size is 0.
- DCHECK(upload_file_info->all_bytes_present &&
- upload_file_info->content_length == 0);
+ DCHECK(upload_file_info->content_length == 0);
upload_file_info->start_position = 0;
upload_file_info->end_position = 0;
@@ -418,22 +403,19 @@ void DriveUploader::RemoveUpload(scoped_ptr<UploadFileInfo> upload_file_info) {
DriveUploader::UploadFileInfo::UploadFileInfo()
: upload_id(-1),
- file_size(0),
content_length(0),
upload_mode(UPLOAD_INVALID),
file_stream(NULL),
buf_len(0),
start_position(0),
- end_position(0),
- all_bytes_present(false),
- upload_paused(false) {
+ end_position(0) {
}
DriveUploader::UploadFileInfo::~UploadFileInfo() { }
int64 DriveUploader::UploadFileInfo::SizeRemaining() const {
- DCHECK(file_size >= end_position);
- return file_size - end_position;
+ DCHECK(content_length >= end_position);
+ return content_length - end_position;
}
std::string DriveUploader::UploadFileInfo::DebugString() const {
@@ -441,7 +423,6 @@ std::string DriveUploader::UploadFileInfo::DebugString() const {
"], file_path=[" + file_path.AsUTF8Unsafe() +
"], content_type=[" + content_type +
"], content_length=[" + base::UintToString(content_length) +
- "], file_size=[" + base::UintToString(file_size) +
"], drive_path=[" + drive_path.AsUTF8Unsafe() +
"]";
}
diff --git a/chrome/browser/google_apis/drive_uploader.h b/chrome/browser/google_apis/drive_uploader.h
index 49ca9fc..a08195f 100644
--- a/chrome/browser/google_apis/drive_uploader.h
+++ b/chrome/browser/google_apis/drive_uploader.h
@@ -54,16 +54,6 @@ class DriveUploaderInterface {
// content_type:
// The content type of the file to be uploaded.
//
- // content_length:
- // The content length of the file to be uploaded.
- // If the length is unknown beforehand, -1 should be passed.
- //
- // file_size:
- // The current size of the file to be uploaded. This can be smaller than
- // |content_length|, if the source file is still being written (i.e. being
- // downloaded from some web site). The client should keep providing the
- // current status with the UpdateUpload() function.
- //
// callback:
// Called when an upload is done regardless of it was successful or not.
// Must not be null.
@@ -72,8 +62,6 @@ class DriveUploaderInterface {
const FilePath& local_file_path,
const std::string& title,
const std::string& content_type,
- int64 content_length,
- int64 file_size,
const UploadCompletionCallback& callback) = 0;
// Uploads an existing file (a file that already exists on Drive).
@@ -83,7 +71,6 @@ class DriveUploaderInterface {
const FilePath& drive_file_path,
const FilePath& local_file_path,
const std::string& content_type,
- int64 file_size,
const UploadCompletionCallback& callback) = 0;
};
@@ -98,15 +85,12 @@ class DriveUploader : public DriveUploaderInterface {
const FilePath& local_file_path,
const std::string& title,
const std::string& content_type,
- int64 content_length,
- int64 file_size,
const UploadCompletionCallback& callback) OVERRIDE;
virtual int UploadExistingFile(
const GURL& upload_location,
const FilePath& drive_file_path,
const FilePath& local_file_path,
const std::string& content_type,
- int64 file_size,
const UploadCompletionCallback& callback) OVERRIDE;
private:
@@ -125,7 +109,6 @@ class DriveUploader : public DriveUploaderInterface {
int upload_id; // id of this upload.
FilePath file_path; // The path of the file to be uploaded.
- int64 file_size; // Last known size of the file.
// TODO(zelirag, achuith): Make this string16.
std::string title; // Title to be used for file to be uploaded.
@@ -167,9 +150,6 @@ class DriveUploader : public DriveUploaderInterface {
int64 start_position;
int64 end_position;
- bool all_bytes_present; // Whether all bytes of this file are present.
- bool upload_paused; // Whether this file's upload has been paused.
-
// Will be set once the upload is complete.
scoped_ptr<ResourceEntry> entry;
@@ -190,11 +170,11 @@ class DriveUploader : public DriveUploaderInterface {
// Open the file.
void OpenFile(UploadFileInfo* upload_file_info, FileOpenType open_type);
- // net::FileStream::Open completion callback. The result of the file
- // open operation is passed as |result|.
+ // net::FileStream::Open completion callback. The result of the file open
+ // operation is passed as |result|, and the size is stored in |file_size|.
void OpenCompletionCallback(FileOpenType open_type,
int upload_id,
- int result);
+ int64 file_size);
// DriveService callback for InitiateUpload.
void OnUploadLocationReceived(int upload_id,
diff --git a/chrome/browser/google_apis/drive_uploader_unittest.cc b/chrome/browser/google_apis/drive_uploader_unittest.cc
index 36bc4b7..bbd3ca2 100644
--- a/chrome/browser/google_apis/drive_uploader_unittest.cc
+++ b/chrome/browser/google_apis/drive_uploader_unittest.cc
@@ -292,12 +292,10 @@ class MockDriveServiceNoConnectionAtResume : public MockDriveServiceBase {
class DriveUploaderTest : public testing::Test {
public:
DriveUploaderTest()
- : ui_thread_(content::BrowserThread::UI, &message_loop_),
- io_thread_(content::BrowserThread::IO) {
+ : ui_thread_(content::BrowserThread::UI, &message_loop_) {
}
virtual void SetUp() OVERRIDE {
- io_thread_.StartIOThread();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
@@ -308,7 +306,6 @@ class DriveUploaderTest : public testing::Test {
protected:
MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread io_thread_;
base::ScopedTempDir temp_dir_;
};
@@ -352,7 +349,6 @@ TEST_F(DriveUploaderTest, UploadExisting0KB) {
FilePath::FromUTF8Unsafe(kTestDrivePath),
local_path,
kTestMimeType,
- 0, // content length
base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out));
message_loop_.Run();
@@ -380,7 +376,6 @@ TEST_F(DriveUploaderTest, UploadExisting512KB) {
FilePath::FromUTF8Unsafe(kTestDrivePath),
local_path,
kTestMimeType,
- 512 * 1024, // content length
base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out));
message_loop_.Run();
@@ -409,7 +404,6 @@ TEST_F(DriveUploaderTest, UploadExisting1234KB) {
FilePath::FromUTF8Unsafe(kTestDrivePath),
local_path,
kTestMimeType,
- 1234 * 1024, // content length
base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out));
message_loop_.Run();
@@ -439,8 +433,6 @@ TEST_F(DriveUploaderTest, UploadNew1234KB) {
local_path,
kTestDocumentTitle,
kTestMimeType,
- 1234 * 1024, // content length
- 1234 * 1024, // current file size
base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out)
);
message_loop_.Run();
@@ -470,7 +462,6 @@ TEST_F(DriveUploaderTest, InitiateUploadFail) {
FilePath::FromUTF8Unsafe(kTestDrivePath),
local_path,
kTestMimeType,
- 512 * 1024, // content length
base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out));
message_loop_.Run();
@@ -492,7 +483,6 @@ TEST_F(DriveUploaderTest, ResumeUploadFail) {
FilePath::FromUTF8Unsafe(kTestDrivePath),
local_path,
kTestMimeType,
- 512 * 1024, // content length
base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out));
message_loop_.Run();
@@ -508,7 +498,6 @@ TEST_F(DriveUploaderTest, NonExistingSourceFile) {
FilePath::FromUTF8Unsafe(kTestDrivePath),
temp_dir_.path().AppendASCII("_this_path_should_not_exist_"),
kTestMimeType,
- 0, // content length
base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out));
message_loop_.Run();
diff --git a/chrome/browser/sync_file_system/drive_file_sync_client.cc b/chrome/browser/sync_file_system/drive_file_sync_client.cc
index 31481e3..26f5cef 100644
--- a/chrome/browser/sync_file_system/drive_file_sync_client.cc
+++ b/chrome/browser/sync_file_system/drive_file_sync_client.cc
@@ -334,7 +334,6 @@ void DriveFileSyncClient::UploadNewFile(
const std::string& directory_resource_id,
const FilePath& local_file_path,
const std::string& title,
- int64 file_size,
const UploadFileCallback& callback) {
DCHECK(CalledOnValidThread());
drive_service_->GetResourceEntry(
@@ -342,15 +341,13 @@ void DriveFileSyncClient::UploadNewFile(
base::Bind(&DriveFileSyncClient::DidGetResourceEntry,
AsWeakPtr(),
base::Bind(&DriveFileSyncClient::UploadNewFileInternal,
- AsWeakPtr(), local_file_path, title, file_size,
- callback)));
+ AsWeakPtr(), local_file_path, title, callback)));
}
void DriveFileSyncClient::UploadExistingFile(
const std::string& resource_id,
const std::string& remote_file_md5,
const FilePath& local_file_path,
- int64 file_size,
const UploadFileCallback& callback) {
DCHECK(CalledOnValidThread());
drive_service_->GetResourceEntry(
@@ -359,7 +356,7 @@ void DriveFileSyncClient::UploadExistingFile(
AsWeakPtr(),
base::Bind(&DriveFileSyncClient::UploadExistingFileInternal,
AsWeakPtr(), remote_file_md5, local_file_path,
- file_size, callback)));
+ callback)));
}
void DriveFileSyncClient::DeleteFile(
@@ -504,7 +501,6 @@ void DriveFileSyncClient::DidDownloadFile(
void DriveFileSyncClient::UploadNewFileInternal(
const FilePath& local_file_path,
const std::string& title,
- int64 file_size,
const UploadFileCallback& callback,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceEntry> parent_directory_entry) {
@@ -528,15 +524,12 @@ void DriveFileSyncClient::UploadNewFileInternal(
local_file_path,
title,
mime_type,
- file_size, // content_length.
- file_size,
base::Bind(&DriveFileSyncClient::DidUploadFile, AsWeakPtr(), callback));
}
void DriveFileSyncClient::UploadExistingFileInternal(
const std::string& remote_file_md5,
const FilePath& local_file_path,
- int64 file_size,
const UploadFileCallback& callback,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceEntry> entry) {
@@ -568,7 +561,6 @@ void DriveFileSyncClient::UploadExistingFileInternal(
FilePath(kDummyDrivePath),
local_file_path,
mime_type,
- file_size,
base::Bind(&DriveFileSyncClient::DidUploadFile,
AsWeakPtr(), callback));
}
diff --git a/chrome/browser/sync_file_system/drive_file_sync_client.h b/chrome/browser/sync_file_system/drive_file_sync_client.h
index 0080873..c3feaeb 100644
--- a/chrome/browser/sync_file_system/drive_file_sync_client.h
+++ b/chrome/browser/sync_file_system/drive_file_sync_client.h
@@ -143,7 +143,6 @@ class DriveFileSyncClient
void UploadNewFile(const std::string& directory_resource_id,
const FilePath& local_file_path,
const std::string& title,
- int64 file_size,
const UploadFileCallback& callback);
// Uploads the existing file identified by |local_file_path|.
@@ -154,7 +153,6 @@ class DriveFileSyncClient
void UploadExistingFile(const std::string& resource_id,
const std::string& remote_file_md5,
const FilePath& local_file_path,
- int64 file_size,
const UploadFileCallback& callback);
// Returns true if the user is authenticated.
@@ -243,7 +241,6 @@ class DriveFileSyncClient
void UploadNewFileInternal(
const FilePath& local_file_path,
const std::string& title,
- int64 file_size,
const UploadFileCallback& callback,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceEntry> parent_directory_entry);
@@ -251,7 +248,6 @@ class DriveFileSyncClient
void UploadExistingFileInternal(
const std::string& remote_file_md5,
const FilePath& local_file_path,
- int64 file_size,
const UploadFileCallback& callback,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::ResourceEntry> entry);
diff --git a/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc b/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc
index b00c803..0b68f05 100644
--- a/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc
@@ -51,8 +51,6 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const FilePath& local_file_path,
const std::string& title,
const std::string& content_type,
- int64 content_length,
- int64 file_size,
const google_apis::UploadCompletionCallback& callback) OVERRIDE {
DCHECK(!callback.is_null());
@@ -80,7 +78,6 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const FilePath& drive_file_path,
const FilePath& local_file_path,
const std::string& content_type,
- int64 file_size,
const google_apis::UploadCompletionCallback& callback) OVERRIDE {
DCHECK(!callback.is_null());
@@ -704,7 +701,6 @@ TEST_F(DriveFileSyncClientTest, UploadNewFile) {
const std::string kDirectoryResourceId = "folder:directory_resource_id";
const FilePath kLocalFilePath(FPL("/tmp/dir/file"));
const std::string kTitle("testfile");
- int64 kFileSize = 1024;
scoped_ptr<base::Value> dir_entry_data(google_apis::test_util::LoadJSONFile(
"gdata/directory_entry.json").Pass());
@@ -729,7 +725,6 @@ TEST_F(DriveFileSyncClientTest, UploadNewFile) {
sync_client()->UploadNewFile(kDirectoryResourceId,
kLocalFilePath,
kTitle,
- kFileSize,
base::Bind(&DidUploadFile,
&done, &error, &resource_id));
message_loop()->RunUntilIdle();
@@ -741,7 +736,6 @@ TEST_F(DriveFileSyncClientTest, UploadNewFile) {
TEST_F(DriveFileSyncClientTest, UploadExistingFile) {
const std::string kResourceId = "file:resource_id";
const FilePath kLocalFilePath(FPL("/tmp/dir/file"));
- int64 kFileSize = 1024;
scoped_ptr<base::Value> file_entry_data(
google_apis::test_util::LoadJSONFile("gdata/file_entry.json").Pass());
@@ -768,7 +762,6 @@ TEST_F(DriveFileSyncClientTest, UploadExistingFile) {
sync_client()->UploadExistingFile(kResourceId,
expected_remote_file_md5,
kLocalFilePath,
- kFileSize,
base::Bind(&DidUploadFile,
&done, &error, &resource_id));
message_loop()->RunUntilIdle();
@@ -780,7 +773,6 @@ TEST_F(DriveFileSyncClientTest, UploadExistingFile) {
TEST_F(DriveFileSyncClientTest, UploadExistingFileInConflict) {
const std::string kResourceId = "file:resource_id";
const FilePath kLocalFilePath(FPL("/tmp/dir/file"));
- int64 kFileSize = 1024;
// Since remote file's hash value is different from the expected one, it is
// expected to cancel upload the file and to return CONFLICT status code.
@@ -808,7 +800,6 @@ TEST_F(DriveFileSyncClientTest, UploadExistingFileInConflict) {
sync_client()->UploadExistingFile(kResourceId,
kExpectedRemoteFileMD5,
kLocalFilePath,
- kFileSize,
base::Bind(&DidUploadFile,
&done, &error, &resource_id));
message_loop()->RunUntilIdle();
diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_file_sync_service.cc
index 1af14f4..16fc0aa 100644
--- a/chrome/browser/sync_file_system/drive_file_sync_service.cc
+++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc
@@ -470,7 +470,6 @@ void DriveFileSyncService::ApplyLocalChange(
metadata_store_->GetResourceIdForOrigin(url.origin()),
local_file_path,
url.path().AsUTF8Unsafe(),
- local_file_metadata.size,
base::Bind(&DriveFileSyncService::DidUploadNewFileForLocalSync,
AsWeakPtr(), base::Passed(&token), url, callback));
return;
@@ -484,7 +483,6 @@ void DriveFileSyncService::ApplyLocalChange(
metadata.resource_id(),
metadata.md5_checksum(),
local_file_path,
- local_file_metadata.size,
base::Bind(&DriveFileSyncService::DidUploadExistingFileForLocalSync,
AsWeakPtr(), base::Passed(&token), url, callback));
return;