summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-11 10:26:36 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-11 10:26:36 +0000
commite2c00ede28ae5323b806a8fe1b108d020300e392 (patch)
tree7cb16bb2f6dd54dd99eccf30a9338335578c12aa
parentc3e3294e5cb161af53eaacf45472238ced95c51e (diff)
downloadchromium_src-e2c00ede28ae5323b806a8fe1b108d020300e392.zip
chromium_src-e2c00ede28ae5323b806a8fe1b108d020300e392.tar.gz
chromium_src-e2c00ede28ae5323b806a8fe1b108d020300e392.tar.bz2
Remove unused DriveUploaderInterface method and callback parameters.
Namely, - UpdateUpload - GetUploadedByte - ready_callback They had been used only for streaming upload. BUG=165110 Review URL: https://chromiumcodereview.appspot.com/11513012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172294 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/drive_file_system_unittest.cc24
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation.cc3
-rw-r--r--chrome/browser/google_apis/drive_uploader.cc108
-rw-r--r--chrome/browser/google_apis/drive_uploader.h89
-rw-r--r--chrome/browser/google_apis/drive_uploader_unittest.cc10
-rw-r--r--chrome/browser/sync_file_system/drive_file_sync_client.cc4
-rw-r--r--chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc24
7 files changed, 57 insertions, 205 deletions
diff --git a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc
index 78e6453..d585888 100644
--- a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc
@@ -133,10 +133,8 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const std::string& content_type,
int64 content_length,
int64 file_size,
- const google_apis::UploadCompletionCallback& completion_callback,
- const google_apis::UploaderReadyCallback& ready_callback) OVERRIDE {
- DCHECK(!completion_callback.is_null());
- // ready_callback may be null.
+ const google_apis::UploadCompletionCallback& callback) OVERRIDE {
+ DCHECK(!callback.is_null());
scoped_ptr<base::Value> value =
google_apis::test_util::LoadJSONFile("gdata/uploaded_file.json");
@@ -145,7 +143,7 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
- base::Bind(completion_callback,
+ base::Bind(callback,
google_apis::DRIVE_UPLOAD_OK,
drive_file_path,
local_file_path,
@@ -164,8 +162,8 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const FilePath& local_file_path,
const std::string& content_type,
int64 file_size,
- const google_apis::UploadCompletionCallback& completion_callback) {
- DCHECK(!completion_callback.is_null());
+ const google_apis::UploadCompletionCallback& callback) OVERRIDE {
+ DCHECK(!callback.is_null());
// This function can only handle "drive/File 1.txt" whose resource ID is
// "file:2_file_resource_id".
@@ -200,7 +198,7 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
- base::Bind(completion_callback,
+ base::Bind(callback,
google_apis::DRIVE_UPLOAD_OK,
drive_file_path,
local_file_path,
@@ -209,16 +207,6 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const int kUploadId = 123;
return kUploadId;
}
-
- virtual void UpdateUpload(int upload_id,
- content::DownloadItem* download) OVERRIDE {
- NOTREACHED();
- }
-
- virtual int64 GetUploadedBytes(int upload_id) const OVERRIDE {
- NOTREACHED();
- return 0;
- }
};
} // namespace
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
index 914f5aa2..2e650db 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
@@ -475,8 +475,7 @@ void CopyOperation::StartFileUploadAfterGetEntryInfo(
file_size,
base::Bind(&CopyOperation::OnTransferCompleted,
weak_ptr_factory_.GetWeakPtr(),
- params.callback),
- google_apis::UploaderReadyCallback());
+ params.callback));
}
void CopyOperation::OnTransferCompleted(
diff --git a/chrome/browser/google_apis/drive_uploader.cc b/chrome/browser/google_apis/drive_uploader.cc
index 7012cd9..39f8675 100644
--- a/chrome/browser/google_apis/drive_uploader.cc
+++ b/chrome/browser/google_apis/drive_uploader.cc
@@ -8,12 +8,10 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "chrome/browser/google_apis/drive_service_interface.h"
#include "chrome/browser/google_apis/gdata_wapi_parser.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/download_item.h"
#include "net/base/file_stream.h"
#include "net/base/net_errors.h"
@@ -58,24 +56,21 @@ DriveUploader::~DriveUploader() {
}
}
-int DriveUploader::UploadNewFile(
- const GURL& upload_location,
- const FilePath& drive_file_path,
- const FilePath& local_file_path,
- const std::string& title,
- const std::string& content_type,
- int64 content_length,
- int64 file_size,
- const UploadCompletionCallback& completion_callback,
- const UploaderReadyCallback& ready_callback) {
+int DriveUploader::UploadNewFile(const GURL& upload_location,
+ const FilePath& drive_file_path,
+ 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());
DCHECK(!drive_file_path.empty());
DCHECK(!local_file_path.empty());
DCHECK(!title.empty());
DCHECK(!content_type.empty());
- DCHECK(!completion_callback.is_null());
- // ready_callback may be null.
+ DCHECK(!callback.is_null());
scoped_ptr<UploadFileInfo> upload_file_info(new UploadFileInfo);
upload_file_info->upload_mode = UPLOAD_NEW_FILE;
@@ -87,8 +82,7 @@ int DriveUploader::UploadNewFile(
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 = completion_callback;
- upload_file_info->ready_callback = ready_callback;
+ upload_file_info->completion_callback = callback;
// When uploading a new file, we should retry file open as the file may
// not yet be ready. See comments in OpenCompletionCallback.
@@ -131,13 +125,13 @@ int DriveUploader::UploadExistingFile(
const FilePath& local_file_path,
const std::string& content_type,
int64 file_size,
- const UploadCompletionCallback& completion_callback) {
+ const UploadCompletionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!upload_location.is_empty());
DCHECK(!drive_file_path.empty());
DCHECK(!local_file_path.empty());
DCHECK(!content_type.empty());
- DCHECK(!completion_callback.is_null());
+ DCHECK(!callback.is_null());
scoped_ptr<UploadFileInfo> upload_file_info(new UploadFileInfo);
upload_file_info->upload_mode = UPLOAD_EXISTING_FILE;
@@ -148,7 +142,7 @@ int DriveUploader::UploadExistingFile(
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 = completion_callback;
+ upload_file_info->completion_callback = callback;
// When uploading an updated file, we should not retry file open as the
// file should already be present by definition.
@@ -156,66 +150,6 @@ int DriveUploader::UploadExistingFile(
return StartUploadFile(upload_file_info.Pass());
}
-void DriveUploader::UpdateUpload(int upload_id,
- content::DownloadItem* download) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id);
- if (!upload_file_info)
- return;
-
- const int64 file_size = download->GetReceivedBytes();
-
- // Update file_size and all_bytes_present.
- DVLOG(1) << "Updating file size from " << upload_file_info->file_size
- << " to " << file_size
- << (download->AllDataSaved() ? " (AllDataSaved)" : " (In-progress)");
- upload_file_info->file_size = file_size;
- upload_file_info->all_bytes_present = download->AllDataSaved();
- if (upload_file_info->file_path != download->GetFullPath()) {
- // We shouldn't see a rename if should_retry_file_open is true. The only
- // rename we expect (for now) is the final rename that happens after the
- // download transition from IN_PROGRESS -> COMPLETE. This, in turn, only
- // happens after the upload completes. However, since this isn't enforced by
- // the API contract, we reset the retry count so we can retry all over again
- // with the new path.
- // TODO(asanka): Introduce a synchronization point after the initial rename
- // of the download and get rid of the retry logic.
- upload_file_info->num_file_open_tries = 0;
- upload_file_info->file_path = download->GetFullPath();
- }
-
- // Resume upload if necessary and possible.
- if (upload_file_info->upload_paused &&
- (upload_file_info->all_bytes_present ||
- upload_file_info->SizeRemaining() > kUploadChunkSize)) {
- DVLOG(1) << "Resuming upload " << upload_file_info->title;
- upload_file_info->upload_paused = false;
- UploadNextChunk(upload_file_info);
- }
-
- // Retry opening this file if we failed before. File open can fail because
- // the downloads system sets the full path on the UI thread and schedules a
- // rename on the FILE thread. Thus the new path is visible on the UI thread
- // before the renamed file is available on the file system.
- if (upload_file_info->should_retry_file_open) {
- DCHECK(!download->IsComplete());
- // Disallow further retries.
- upload_file_info->should_retry_file_open = false;
- OpenFile(upload_file_info, FILE_OPEN_UPDATE_UPLOAD);
- }
-}
-
-int64 DriveUploader::GetUploadedBytes(int upload_id) const {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- UploadFileInfo* upload_info = GetUploadFileInfo(upload_id);
- // We return the start_range as the count of uploaded bytes since that is the
- // start of the next or currently uploading chunk.
- // TODO(asanka): Use a finer grained progress value than this. We end up
- // reporting progress in kUploadChunkSize increments.
- return upload_info ? upload_info->start_range : 0;
-}
-
DriveUploader::UploadFileInfo* DriveUploader::GetUploadFileInfo(
int upload_id) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -297,22 +231,6 @@ void DriveUploader::OpenCompletionCallback(FileOpenType open_type,
weak_ptr_factory_.GetWeakPtr(),
upload_file_info->upload_id));
}
- // The uploader gets ready after we complete opening the file, called
- // from the StartUploadFile method. We use PostTask on purpose, because
- // this callback is called by FileStream, and we may access FileStream
- // again from the |ready_callback| implementation. FileStream is not
- // reentrant.
- //
- // Note, that we call this callback if we opened the file, or if we
- // failed, but further retries are scheduled. The callback will not be
- // called if the upload has been aborted.
- if (open_type == FILE_OPEN_START_UPLOAD &&
- !upload_file_info->ready_callback.is_null()) {
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(upload_file_info->ready_callback, upload_id));
- }
}
void DriveUploader::OnUploadLocationReceived(int upload_id,
diff --git a/chrome/browser/google_apis/drive_uploader.h b/chrome/browser/google_apis/drive_uploader.h
index 65f6e62..5e210c4 100644
--- a/chrome/browser/google_apis/drive_uploader.h
+++ b/chrome/browser/google_apis/drive_uploader.h
@@ -21,25 +21,17 @@
class GURL;
-namespace content {
-class DownloadItem;
-}
-
namespace google_apis {
class DriveServiceInterface;
struct ResumeUploadResponse;
// Callback to be invoked once the upload has completed.
-typedef base::Callback<void(
- DriveUploadError error,
- const FilePath& drive_path,
- const FilePath& file_path,
- scoped_ptr<ResourceEntry> resource_entry)>
+typedef base::Callback<void(DriveUploadError error,
+ const FilePath& drive_path,
+ const FilePath& file_path,
+ scoped_ptr<ResourceEntry> resource_entry)>
UploadCompletionCallback;
-// Callback to be invoked once the uploader is ready to upload.
-typedef base::Callback<void(int32 upload_id)> UploaderReadyCallback;
-
class DriveUploaderInterface {
public:
virtual ~DriveUploaderInterface() {}
@@ -69,45 +61,30 @@ class DriveUploaderInterface {
// 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
- // downdloaded from some web site). The client should keep providing the
+ // downloaded from some web site). The client should keep providing the
// current status with the UpdateUpload() function.
//
- // completion_callback
+ // callback:
// Called when an upload is done regardless of it was successful or not.
// Must not be null.
- //
- // |ready_callback| is called when the uploader is ready to upload data
- // (i.e. when the file is opened). May be null.
- virtual int UploadNewFile(
- const GURL& upload_location,
- const FilePath& drive_file_path,
- const FilePath& local_file_path,
- const std::string& title,
- const std::string& content_type,
- int64 content_length,
- int64 file_size,
- const UploadCompletionCallback& completion_callback,
- const UploaderReadyCallback& ready_callback) = 0;
+ virtual int UploadNewFile(const GURL& upload_location,
+ const FilePath& drive_file_path,
+ 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).
//
// See comments at UploadNewFile() about common parameters.
- 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& completion_callback) = 0;
-
- // Updates attributes of streaming upload from |download|. This function
- // should be used when downloading from some web site and uploading to
- // Drive are done in parallel.
- virtual void UpdateUpload(int upload_id,
- content::DownloadItem* download) = 0;
-
- // Returns the count of bytes confirmed as uploaded so far.
- virtual int64 GetUploadedBytes(int upload_id) const = 0;
+ 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) = 0;
};
class DriveUploader : public DriveUploaderInterface {
@@ -116,26 +93,21 @@ class DriveUploader : public DriveUploaderInterface {
virtual ~DriveUploader();
// DriveUploaderInterface overrides.
- virtual int UploadNewFile(
- const GURL& upload_location,
- const FilePath& drive_file_path,
- const FilePath& local_file_path,
- const std::string& title,
- const std::string& content_type,
- int64 content_length,
- int64 file_size,
- const UploadCompletionCallback& completion_callback,
- const UploaderReadyCallback& ready_callback) OVERRIDE;
+ virtual int UploadNewFile(const GURL& upload_location,
+ const FilePath& drive_file_path,
+ 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& completion_callback) OVERRIDE;
- virtual void UpdateUpload(
- int upload_id, content::DownloadItem* download) OVERRIDE;
- virtual int64 GetUploadedBytes(int upload_id) const OVERRIDE;
+ const UploadCompletionCallback& callback) OVERRIDE;
private:
// Structure containing current upload information of file, passed between
@@ -206,9 +178,6 @@ class DriveUploader : public DriveUploaderInterface {
// Will be set once the upload is complete.
scoped_ptr<ResourceEntry> entry;
- // Callback to be invoked once the uploader is ready to upload.
- UploaderReadyCallback ready_callback;
-
// Callback to be invoked once the upload has finished.
UploadCompletionCallback completion_callback;
};
diff --git a/chrome/browser/google_apis/drive_uploader_unittest.cc b/chrome/browser/google_apis/drive_uploader_unittest.cc
index bbeb54f..baf65c3 100644
--- a/chrome/browser/google_apis/drive_uploader_unittest.cc
+++ b/chrome/browser/google_apis/drive_uploader_unittest.cc
@@ -309,11 +309,6 @@ class DriveUploaderTest : public testing::Test {
base::ScopedTempDir temp_dir_;
};
-// Records whether UploaderReadyCallback is called or not.
-void OnUploaderReady(bool* called, int32 /* upload_id */) {
- *called = true;
-}
-
// Struct for holding the results copied from UploadCompletionCallback.
struct UploadCompletionCallbackResult {
UploadCompletionCallbackResult() : error(DRIVE_UPLOAD_ERROR_ABORT) {}
@@ -432,7 +427,6 @@ TEST_F(DriveUploaderTest, UploadNew1234KB) {
&local_path, &data));
UploadCompletionCallbackResult out;
- bool uploader_ready_called = false;
MockDriveServiceWithUploadExpectation mock_service(data);
DriveUploader uploader(&mock_service);
@@ -444,12 +438,10 @@ TEST_F(DriveUploaderTest, UploadNew1234KB) {
kTestMimeType,
1234 * 1024, // content length
1234 * 1024, // current file size
- base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out),
- base::Bind(&OnUploaderReady, &uploader_ready_called)
+ base::Bind(&CopyResultsFromUploadCompletionCallbackAndQuit, &out)
);
message_loop_.Run();
- EXPECT_TRUE(uploader_ready_called);
// The file should be split into 3 chunks (1234 = 512 + 512 + 210).
EXPECT_EQ(3, mock_service.resume_upload_call_count());
EXPECT_EQ(1234 * 1024, mock_service.received_bytes());
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 b9e66c0..01764650 100644
--- a/chrome/browser/sync_file_system/drive_file_sync_client.cc
+++ b/chrome/browser/sync_file_system/drive_file_sync_client.cc
@@ -546,9 +546,7 @@ void DriveFileSyncClient::UploadNewFileInternal(
mime_type,
file_size, // content_length.
file_size,
- base::Bind(&DriveFileSyncClient::DidUploadFile,
- AsWeakPtr(), callback),
- google_apis::UploaderReadyCallback());
+ base::Bind(&DriveFileSyncClient::DidUploadFile, AsWeakPtr(), callback));
}
void DriveFileSyncClient::UploadExistingFileInternal(
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 f2fca63..c2d2cc5 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
@@ -53,10 +53,8 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const std::string& content_type,
int64 content_length,
int64 file_size,
- const google_apis::UploadCompletionCallback& completion_callback,
- const google_apis::UploaderReadyCallback& ready_callback) OVERRIDE {
- DCHECK(!completion_callback.is_null());
- // ready_callback may be null.
+ const google_apis::UploadCompletionCallback& callback) OVERRIDE {
+ DCHECK(!callback.is_null());
scoped_ptr<base::Value> file_entry_data(
google_apis::test_util::LoadJSONFile(
@@ -66,7 +64,7 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
- base::Bind(completion_callback,
+ base::Bind(callback,
google_apis::DRIVE_UPLOAD_OK,
drive_file_path,
local_file_path,
@@ -83,8 +81,8 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
const FilePath& local_file_path,
const std::string& content_type,
int64 file_size,
- const google_apis::UploadCompletionCallback& completion_callback) {
- DCHECK(!completion_callback.is_null());
+ const google_apis::UploadCompletionCallback& callback) OVERRIDE {
+ DCHECK(!callback.is_null());
scoped_ptr<base::Value> file_entry_data(
google_apis::test_util::LoadJSONFile(
@@ -94,23 +92,13 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
- base::Bind(completion_callback,
+ base::Bind(callback,
google_apis::DRIVE_UPLOAD_OK,
drive_file_path,
local_file_path,
base::Passed(&file_entry)));
return 1; // Return dummy upload ID.
}
-
- virtual void UpdateUpload(int upload_id,
- content::DownloadItem* download) OVERRIDE {
- NOTREACHED();
- }
-
- virtual int64 GetUploadedBytes(int upload_id) const OVERRIDE {
- NOTREACHED();
- return 0;
- }
};
} // namespace