summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 17:39:29 +0000
committerhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 17:39:29 +0000
commitd307243f5bcb08e2c7d1380f5553e30cc373c75b (patch)
treebd9a5789041e8517ab57ea9fdb2dca77a4656971 /webkit
parentb8f2f42c6204dabea53c05e42c9907cbccc39604 (diff)
downloadchromium_src-d307243f5bcb08e2c7d1380f5553e30cc373c75b.zip
chromium_src-d307243f5bcb08e2c7d1380f5553e30cc373c75b.tar.gz
chromium_src-d307243f5bcb08e2c7d1380f5553e30cc373c75b.tar.bz2
Use OperationHandle for CopyProgressCallback.
To align the callback invocation manner in FileSystemOperationRunner, this CL introduces a thin wrapper for CopyProgressCallback. By this CL, it is ensured that progress_callback is called at least next message loop so that the caller can use OperationID inside the callback. BUG=278038 TEST=Ran content_unittests Review URL: https://chromiumcodereview.appspot.com/23622025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/file_system_operation_runner.cc21
-rw-r--r--webkit/browser/fileapi/file_system_operation_runner.h7
2 files changed, 27 insertions, 1 deletions
diff --git a/webkit/browser/fileapi/file_system_operation_runner.cc b/webkit/browser/fileapi/file_system_operation_runner.cc
index 3a82c8f6..435db31 100644
--- a/webkit/browser/fileapi/file_system_operation_runner.cc
+++ b/webkit/browser/fileapi/file_system_operation_runner.cc
@@ -100,7 +100,11 @@ OperationID FileSystemOperationRunner::Copy(
PrepareForWrite(handle.id, dest_url);
PrepareForRead(handle.id, src_url);
operation->Copy(
- src_url, dest_url, progress_callback,
+ src_url, dest_url,
+ progress_callback.is_null() ?
+ CopyProgressCallback() :
+ base::Bind(&FileSystemOperationRunner::OnCopyProgress, AsWeakPtr(),
+ handle, progress_callback),
base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
handle, callback));
return handle.id;
@@ -599,6 +603,21 @@ void FileSystemOperationRunner::DidCreateSnapshot(
FinishOperation(handle.id);
}
+void FileSystemOperationRunner::OnCopyProgress(
+ const OperationHandle& handle,
+ const CopyProgressCallback& callback,
+ FileSystemOperation::CopyProgressType type,
+ const FileSystemURL& url,
+ int64 size) {
+ if (handle.scope) {
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE, base::Bind(&FileSystemOperationRunner::OnCopyProgress,
+ AsWeakPtr(), handle, callback, type, url, size));
+ return;
+ }
+ callback.Run(type, url, size);
+}
+
void FileSystemOperationRunner::PrepareForWrite(OperationID id,
const FileSystemURL& url) {
if (file_system_context_->GetUpdateObservers(url.type())) {
diff --git a/webkit/browser/fileapi/file_system_operation_runner.h b/webkit/browser/fileapi/file_system_operation_runner.h
index 8822487..f4c4ba9 100644
--- a/webkit/browser/fileapi/file_system_operation_runner.h
+++ b/webkit/browser/fileapi/file_system_operation_runner.h
@@ -273,6 +273,13 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
+ void OnCopyProgress(
+ const OperationHandle& handle,
+ const CopyProgressCallback& callback,
+ FileSystemOperation::CopyProgressType type,
+ const FileSystemURL& url,
+ int64 size);
+
void PrepareForWrite(OperationID id, const FileSystemURL& url);
void PrepareForRead(OperationID id, const FileSystemURL& url);