Commit c0c6e172 authored by satorux@chromium.org's avatar satorux@chromium.org

gdata: Simplify InitiateUpload() and ResumeUpload()

These are called on UI thread, so no need to deal with
MesageLoopProxy::current() etc.

BUG=chromium-os:29036,chromium-os:29943
TEST=saving to gdata works as before and no error was emitted with --enable-dcheck with a Release build.

Review URL: https://chromiumcodereview.appspot.com/10207022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133817 0039d316-1c4b-4281-b951-d872f2087c98
parent 3d662c39
......@@ -1891,6 +1891,8 @@ void GDataFileSystem::InitiateUpload(
const FilePath& destination_directory,
const FilePath& virtual_path,
const InitiateUploadCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
GURL destination_directory_url =
GetUploadUrlForDirectory(destination_directory);
......@@ -1905,52 +1907,20 @@ void GDataFileSystem::InitiateUpload(
}
documents_service_->InitiateUpload(
InitiateUploadParams(file_name,
content_type,
content_length,
destination_directory_url,
virtual_path),
base::Bind(&GDataFileSystem::OnUploadLocationReceived,
GetWeakPtrForCurrentThread(),
callback,
// MessageLoopProxy is used to run |callback| on the
// thread where this function was called.
base::MessageLoopProxy::current()));
}
void GDataFileSystem::OnUploadLocationReceived(
const InitiateUploadCallback& callback,
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
GDataErrorCode code,
const GURL& upload_location) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!callback.is_null()) {
message_loop_proxy->PostTask(FROM_HERE, base::Bind(callback, code,
upload_location));
}
InitiateUploadParams(file_name,
content_type,
content_length,
destination_directory_url,
virtual_path),
callback);
}
void GDataFileSystem::ResumeUpload(
const ResumeUploadParams& params,
const ResumeFileUploadCallback& callback) {
documents_service_->ResumeUpload(
params,
base::Bind(&GDataFileSystem::OnResumeUpload,
GetWeakPtrForCurrentThread(),
base::MessageLoopProxy::current(),
callback));
}
void GDataFileSystem::OnResumeUpload(
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
const ResumeFileUploadCallback& callback,
const ResumeUploadResponse& response,
scoped_ptr<DocumentEntry> new_entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!callback.is_null())
message_loop_proxy->PostTask(FROM_HERE,
base::Bind(callback, response, base::Passed(&new_entry)));
documents_service_->ResumeUpload(params, callback);
}
void GDataFileSystem::UnsafeFindEntryByPath(
......
......@@ -586,7 +586,8 @@ class GDataFileSystem : public GDataFileSystemInterface,
// |content_type| and |content_length|. The operation will place the newly
// created file entity into |destination_directory|.
//
// Can be called from UI/IO thread. |callback| is run on the calling thread.
// Can be called from *UI* thread. |callback| is run on the calling thread.
// TODO(satorux,achuith): Remove this: crosbug.com/29943
void InitiateUpload(const std::string& file_name,
const std::string& content_type,
int64 content_length,
......@@ -596,7 +597,8 @@ class GDataFileSystem : public GDataFileSystemInterface,
// Resumes upload operation for chunk of file defined in |params..
//
// Can be called from UI/IO thread. |callback| is run on the calling thread.
// Can be called from *UI* thread. |callback| is run on the calling thread.
// TODO(satorux,achuith): Remove this: crosbug.com/29943
void ResumeUpload(const ResumeUploadParams& params,
const ResumeFileUploadCallback& callback);
......@@ -770,20 +772,6 @@ class GDataFileSystem : public GDataFileSystemInterface,
const std::string& resource_id,
const std::string& md5);
// Callback for handling file upload initialization requests.
void OnUploadLocationReceived(
const InitiateUploadCallback& callback,
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
GDataErrorCode code,
const GURL& upload_location);
// Callback for handling file upload resume requests.
void OnResumeUpload(
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
const ResumeFileUploadCallback& callback,
const ResumeUploadResponse& response,
scoped_ptr<DocumentEntry> new_entry);
// Renames a file or directory at |file_path| on in-memory snapshot
// of the file system. Returns PLATFORM_FILE_OK if successful.
base::PlatformFileError RenameFileOnFilesystem(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment