summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-09 14:14:12 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-09 14:14:12 +0000
commit3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c (patch)
tree4e2a8e2967b61849ab1d7742bc87dc80734dd29d /webkit
parent770d6a89638d340c3bad7970614923dc17e54d8c (diff)
downloadchromium_src-3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c.zip
chromium_src-3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c.tar.gz
chromium_src-3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c.tar.bz2
Replace all CreateFileSystemOperation with FileSystemOperationRunner
FileSystemOperation consumers should no longer worry about Operation memory leak. BUG=176444 TEST=existing tests R=benjhayden@chromium.org, kinaba@chromium.org, thestig@chromium.org, tzik@chromium.org Review URL: https://codereview.chromium.org/16452002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205121 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/async_file_test_helper.cc65
-rw-r--r--webkit/browser/fileapi/file_system_context.cc51
-rw-r--r--webkit/browser/fileapi/file_system_context.h28
-rw-r--r--webkit/browser/fileapi/file_system_dir_url_request_job.cc27
-rw-r--r--webkit/browser/fileapi/file_system_dir_url_request_job.h2
-rw-r--r--webkit/browser/fileapi/file_system_file_stream_reader.cc9
-rw-r--r--webkit/browser/fileapi/file_system_operation_runner.cc13
-rw-r--r--webkit/browser/fileapi/file_system_operation_runner.h16
-rw-r--r--webkit/browser/fileapi/file_system_url_request_job.cc12
-rw-r--r--webkit/browser/fileapi/isolated_file_util_unittest.cc7
-rw-r--r--webkit/browser/fileapi/local_file_system_operation_unittest.cc205
-rw-r--r--webkit/browser/fileapi/local_file_system_operation_write_unittest.cc54
-rw-r--r--webkit/browser/fileapi/sandbox_file_stream_writer.cc11
-rw-r--r--webkit/browser/fileapi/sandbox_file_system_test_helper.cc11
-rw-r--r--webkit/browser/fileapi/sandbox_file_system_test_helper.h3
-rw-r--r--webkit/browser/fileapi/syncable/canned_syncable_file_system.cc48
-rw-r--r--webkit/browser/fileapi/syncable/canned_syncable_file_system.h5
-rw-r--r--webkit/browser/fileapi/syncable/local_file_sync_context.cc33
-rw-r--r--webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc4
-rw-r--r--webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc44
-rw-r--r--webkit/browser/fileapi/test_mount_point_provider.cc16
-rw-r--r--webkit/browser/fileapi/test_mount_point_provider.h4
-rw-r--r--webkit/support/simple_file_system.cc43
-rw-r--r--webkit/support/simple_file_system.h2
-rw-r--r--webkit/support/simple_file_writer.cc34
25 files changed, 342 insertions, 405 deletions
diff --git a/webkit/browser/fileapi/async_file_test_helper.cc b/webkit/browser/fileapi/async_file_test_helper.cc
index 7437293..72d0b4d 100644
--- a/webkit/browser/fileapi/async_file_test_helper.cc
+++ b/webkit/browser/fileapi/async_file_test_helper.cc
@@ -8,6 +8,7 @@
#include "webkit/browser/fileapi/async_file_test_helper.h"
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_mount_point_provider.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/common/fileapi/file_system_util.h"
@@ -80,13 +81,10 @@ base::PlatformFileError AsyncFileTestHelper::Copy(
FileSystemContext* context,
const FileSystemURL& src,
const FileSystemURL& dest) {
- DCHECK(context);
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(dest, NULL);
- EXPECT_TRUE(operation != NULL);
base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
base::RunLoop run_loop;
- operation->Copy(src, dest, AssignAndQuitCallback(&run_loop, &result));
+ context->operation_runner()->Copy(
+ src, dest, AssignAndQuitCallback(&run_loop, &result));
run_loop.Run();
return result;
}
@@ -95,12 +93,10 @@ base::PlatformFileError AsyncFileTestHelper::Move(
FileSystemContext* context,
const FileSystemURL& src,
const FileSystemURL& dest) {
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(dest, NULL);
- EXPECT_TRUE(operation != NULL);
base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
base::RunLoop run_loop;
- operation->Move(src, dest, AssignAndQuitCallback(&run_loop, &result));
+ context->operation_runner()->Move(
+ src, dest, AssignAndQuitCallback(&run_loop, &result));
run_loop.Run();
return result;
}
@@ -109,12 +105,10 @@ base::PlatformFileError AsyncFileTestHelper::Remove(
FileSystemContext* context,
const FileSystemURL& url,
bool recursive) {
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(url, NULL);
- EXPECT_TRUE(operation != NULL);
base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
base::RunLoop run_loop;
- operation->Remove(url, recursive, AssignAndQuitCallback(&run_loop, &result));
+ context->operation_runner()->Remove(
+ url, recursive, AssignAndQuitCallback(&run_loop, &result));
run_loop.Run();
return result;
}
@@ -123,14 +117,11 @@ base::PlatformFileError AsyncFileTestHelper::ReadDirectory(
FileSystemContext* context,
const FileSystemURL& url,
FileEntryList* entries) {
+ base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
DCHECK(entries);
entries->clear();
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(url, NULL);
- EXPECT_TRUE(operation != NULL);
base::RunLoop run_loop;
- operation->ReadDirectory(
+ context->operation_runner()->ReadDirectory(
url, base::Bind(&ReadDirectoryCallback, &run_loop, &result, entries));
run_loop.Run();
return result;
@@ -139,15 +130,13 @@ base::PlatformFileError AsyncFileTestHelper::ReadDirectory(
base::PlatformFileError AsyncFileTestHelper::CreateDirectory(
FileSystemContext* context,
const FileSystemURL& url) {
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(url, NULL);
- EXPECT_TRUE(operation != NULL);
base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
base::RunLoop run_loop;
- operation->CreateDirectory(url,
- false /* exclusive */,
- false /* recursive */,
- AssignAndQuitCallback(&run_loop, &result));
+ context->operation_runner()->CreateDirectory(
+ url,
+ false /* exclusive */,
+ false /* recursive */,
+ AssignAndQuitCallback(&run_loop, &result));
run_loop.Run();
return result;
}
@@ -155,13 +144,11 @@ base::PlatformFileError AsyncFileTestHelper::CreateDirectory(
base::PlatformFileError AsyncFileTestHelper::CreateFile(
FileSystemContext* context,
const FileSystemURL& url) {
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(url, NULL);
- EXPECT_TRUE(operation != NULL);
- base::RunLoop run_loop;
base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- operation->CreateFile(url, false /* exclusive */,
- AssignAndQuitCallback(&run_loop, &result));
+ base::RunLoop run_loop;
+ context->operation_runner()->CreateFile(
+ url, false /* exclusive */,
+ AssignAndQuitCallback(&run_loop, &result));
run_loop.Run();
return result;
}
@@ -170,13 +157,10 @@ base::PlatformFileError AsyncFileTestHelper::TruncateFile(
FileSystemContext* context,
const FileSystemURL& url,
size_t size) {
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(url, NULL);
- EXPECT_TRUE(operation != NULL);
base::RunLoop run_loop;
base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- operation->Truncate(url, size,
- AssignAndQuitCallback(&run_loop, &result));
+ context->operation_runner()->Truncate(
+ url, size, AssignAndQuitCallback(&run_loop, &result));
run_loop.Run();
return result;
}
@@ -188,12 +172,9 @@ base::PlatformFileError AsyncFileTestHelper::GetMetadata(
base::FilePath* platform_path) {
base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
base::RunLoop run_loop;
- FileSystemOperation* operation =
- context->CreateFileSystemOperation(url, NULL);
- EXPECT_TRUE(operation != NULL);
- operation->GetMetadata(url, base::Bind(&GetMetadataCallback,
- &run_loop, &result,
- file_info, platform_path));
+ context->operation_runner()->GetMetadata(
+ url, base::Bind(&GetMetadataCallback, &run_loop, &result,
+ file_info, platform_path));
run_loop.Run();
return result;
}
diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc
index 95d5dc5..4d0e89f 100644
--- a/webkit/browser/fileapi/file_system_context.cc
+++ b/webkit/browser/fileapi/file_system_context.cc
@@ -279,31 +279,6 @@ void FileSystemContext::DeleteFileSystem(
mount_point_provider->DeleteFileSystem(origin_url, type, this, callback);
}
-FileSystemOperation* FileSystemContext::CreateFileSystemOperation(
- const FileSystemURL& url, base::PlatformFileError* error_code) {
- if (!url.is_valid()) {
- if (error_code)
- *error_code = base::PLATFORM_FILE_ERROR_INVALID_URL;
- return NULL;
- }
-
- FileSystemMountPointProvider* mount_point_provider =
- GetMountPointProvider(url.type());
- if (!mount_point_provider) {
- if (error_code)
- *error_code = base::PLATFORM_FILE_ERROR_FAILED;
- return NULL;
- }
-
- base::PlatformFileError fs_error = base::PLATFORM_FILE_OK;
- FileSystemOperation* operation =
- mount_point_provider->CreateFileSystemOperation(url, this, &fs_error);
-
- if (error_code)
- *error_code = fs_error;
- return operation;
-}
-
scoped_ptr<webkit_blob::FileStreamReader>
FileSystemContext::CreateFileStreamReader(
const FileSystemURL& url,
@@ -375,6 +350,32 @@ void FileSystemContext::DeleteOnCorrectThread() const {
delete this;
}
+FileSystemOperation* FileSystemContext::CreateFileSystemOperation(
+ const FileSystemURL& url, base::PlatformFileError* error_code) {
+ if (!url.is_valid()) {
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_ERROR_INVALID_URL;
+ return NULL;
+ }
+
+ FileSystemMountPointProvider* mount_point_provider =
+ GetMountPointProvider(url.type());
+ if (!mount_point_provider) {
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_ERROR_FAILED;
+ return NULL;
+ }
+
+ base::PlatformFileError fs_error = base::PLATFORM_FILE_OK;
+ FileSystemOperation* operation =
+ mount_point_provider->CreateFileSystemOperation(url, this, &fs_error);
+
+ if (error_code)
+ *error_code = fs_error;
+ return operation;
+}
+
+
FileSystemURL FileSystemContext::CrackFileSystemURL(
const FileSystemURL& url) const {
if (!url.is_valid())
diff --git a/webkit/browser/fileapi/file_system_context.h b/webkit/browser/fileapi/file_system_context.h
index 974758a..546e32a 100644
--- a/webkit/browser/fileapi/file_system_context.h
+++ b/webkit/browser/fileapi/file_system_context.h
@@ -181,16 +181,6 @@ class WEBKIT_STORAGE_EXPORT FileSystemContext
FileSystemType type,
const DeleteFileSystemCallback& callback);
- // TODO(kinuko): Make this private to FileSystemOperationRunner.
- // Creates a new FileSystemOperation instance by getting an appropriate
- // MountPointProvider for |url| and calling the provider's corresponding
- // CreateFileSystemOperation method.
- // The resolved MountPointProvider could perform further specialization
- // depending on the filesystem type pointed by the |url|.
- FileSystemOperation* CreateFileSystemOperation(
- const FileSystemURL& url,
- base::PlatformFileError* error_code);
-
// Creates new FileStreamReader instance to read a file pointed by the given
// filesystem URL |url| starting from |offset|. |expected_modification_time|
// specifies the expected last modification if the value is non-null, the
@@ -243,11 +233,8 @@ class WEBKIT_STORAGE_EXPORT FileSystemContext
typedef std::map<FileSystemType, FileSystemMountPointProvider*>
MountPointProviderMap;
- // These classes know the target filesystem (i.e. sandbox filesystem)
- // supports synchronous FileUtil.
- friend class LocalFileSystemOperation;
- friend class sync_file_system::LocalFileChangeTracker;
- friend class sync_file_system::LocalFileSyncContext;
+ // For CreateFileSystemOperation.
+ friend class FileSystemOperationRunner;
// Deleters.
friend struct DefaultContextDeleter;
@@ -258,6 +245,17 @@ class WEBKIT_STORAGE_EXPORT FileSystemContext
void DeleteOnCorrectThread() const;
+ // Creates a new FileSystemOperation instance by getting an appropriate
+ // MountPointProvider for |url| and calling the provider's corresponding
+ // CreateFileSystemOperation method.
+ // The resolved MountPointProvider could perform further specialization
+ // depending on the filesystem type pointed by the |url|.
+ //
+ // Called by FileSystemOperationRunner.
+ FileSystemOperation* CreateFileSystemOperation(
+ const FileSystemURL& url,
+ base::PlatformFileError* error_code);
+
// For non-cracked isolated and external mount points, returns a FileSystemURL
// created by cracking |url|. The url is cracked using MountPoints registered
// as |url_crackers_|. If the url cannot be cracked, returns invalid
diff --git a/webkit/browser/fileapi/file_system_dir_url_request_job.cc b/webkit/browser/fileapi/file_system_dir_url_request_job.cc
index a693296..e8f0754 100644
--- a/webkit/browser/fileapi/file_system_dir_url_request_job.cc
+++ b/webkit/browser/fileapi/file_system_dir_url_request_job.cc
@@ -20,7 +20,7 @@
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/common/fileapi/directory_entry.h"
@@ -80,14 +80,7 @@ void FileSystemDirURLRequestJob::StartAsync() {
if (!request_)
return;
url_ = file_system_context_->CrackURL(request_->url());
- base::PlatformFileError error_code;
- FileSystemOperation* operation = GetNewOperation(&error_code);
- if (error_code != base::PLATFORM_FILE_OK) {
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
- net::PlatformFileErrorToNetError(error_code)));
- return;
- }
- operation->ReadDirectory(
+ file_system_context_->operation_runner()->ReadDirectory(
url_,
base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this));
}
@@ -125,16 +118,7 @@ void FileSystemDirURLRequestJob::DidReadDirectory(
}
if (has_more) {
- base::PlatformFileError error_code;
- FileSystemOperation* operation = GetNewOperation(&error_code);
- if (error_code != base::PLATFORM_FILE_OK) {
- NotifyDone(URLRequestStatus(
- URLRequestStatus::FAILED,
- net::PlatformFileErrorToNetError(error_code)));
- return;
- }
-
- operation->ReadDirectory(
+ file_system_context_->operation_runner()->ReadDirectory(
url_,
base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this));
} else {
@@ -143,9 +127,4 @@ void FileSystemDirURLRequestJob::DidReadDirectory(
}
}
-FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation(
- base::PlatformFileError* error_code) {
- return file_system_context_->CreateFileSystemOperation(url_, error_code);
-}
-
} // namespace fileapi
diff --git a/webkit/browser/fileapi/file_system_dir_url_request_job.h b/webkit/browser/fileapi/file_system_dir_url_request_job.h
index 4811dd9..4b574d1 100644
--- a/webkit/browser/fileapi/file_system_dir_url_request_job.h
+++ b/webkit/browser/fileapi/file_system_dir_url_request_job.h
@@ -19,7 +19,6 @@
namespace fileapi {
class FileSystemContext;
-class FileSystemOperation;
struct DirectoryEntry;
// A request job that handles reading filesystem: URLs for directories.
@@ -53,7 +52,6 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemDirURLRequestJob
void DidReadDirectory(base::PlatformFileError result,
const std::vector<DirectoryEntry>& entries,
bool has_more);
- FileSystemOperation* GetNewOperation(base::PlatformFileError* error_code);
std::string data_;
FileSystemURL url_;
diff --git a/webkit/browser/fileapi/file_system_file_stream_reader.cc b/webkit/browser/fileapi/file_system_file_stream_reader.cc
index b55643b..7287178 100644
--- a/webkit/browser/fileapi/file_system_file_stream_reader.cc
+++ b/webkit/browser/fileapi/file_system_file_stream_reader.cc
@@ -12,7 +12,7 @@
#include "net/base/net_errors.h"
#include "webkit/browser/blob/local_file_stream_reader.h"
#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_task_runners.h"
using webkit_blob::LocalFileStreamReader;
@@ -87,13 +87,8 @@ int FileSystemFileStreamReader::CreateSnapshot(
const base::Closure& callback,
const net::CompletionCallback& error_callback) {
DCHECK(!has_pending_create_snapshot_);
- base::PlatformFileError error_code;
- FileSystemOperation* operation =
- file_system_context_->CreateFileSystemOperation(url_, &error_code);
- if (error_code != base::PLATFORM_FILE_OK)
- return net::PlatformFileErrorToNetError(error_code);
has_pending_create_snapshot_ = true;
- operation->CreateSnapshotFile(
+ file_system_context_->operation_runner()->CreateSnapshotFile(
url_,
base::Bind(&FileSystemFileStreamReader::DidCreateSnapshot,
weak_factory_.GetWeakPtr(),
diff --git a/webkit/browser/fileapi/file_system_operation_runner.cc b/webkit/browser/fileapi/file_system_operation_runner.cc
index f12571b..123eb79 100644
--- a/webkit/browser/fileapi/file_system_operation_runner.cc
+++ b/webkit/browser/fileapi/file_system_operation_runner.cc
@@ -386,6 +386,19 @@ OperationID FileSystemOperationRunner::MoveFileLocal(
return id;
}
+base::PlatformFileError FileSystemOperationRunner::SyncGetPlatformPath(
+ const FileSystemURL& url,
+ base::FilePath* platform_path) {
+ base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ FileSystemOperation* operation = CreateLocalFileSystemOperation(url, &error);
+ if (!operation)
+ return error;
+
+ operation->AsLocalFileSystemOperation()->SyncGetPlatformPath(
+ url, platform_path);
+ return base::PLATFORM_FILE_OK;
+}
+
FileSystemOperationRunner::FileSystemOperationRunner(
FileSystemContext* file_system_context)
: file_system_context_(file_system_context) {}
diff --git a/webkit/browser/fileapi/file_system_operation_runner.h b/webkit/browser/fileapi/file_system_operation_runner.h
index 009a1b6..a917eb3 100644
--- a/webkit/browser/fileapi/file_system_operation_runner.h
+++ b/webkit/browser/fileapi/file_system_operation_runner.h
@@ -25,11 +25,11 @@ class FileSystemContext;
// code (therefore in most cases the caller does not need to check the
// returned operation ID).
//
-// Some operations (CopyInForeignFile, RemoveFile, RemoveDirectory,
-// CopyFileLocal and MoveFileLocal) are only supported by filesystems
-// which implement LocalFileSystemOperation. If they are called on
-// other filesystems base::PLATFORM_FILE_ERROR_INVALID_OPERATION is
-// returned via callback.
+// Some operations (e.g. CopyInForeignFile, RemoveFile, RemoveDirectory,
+// CopyFileLocal, MoveFileLocal and SyncGetPlatformPath) are only supported
+// by filesystems which implement LocalFileSystemOperation.
+// If they are called on other filesystems
+// base::PLATFORM_FILE_ERROR_INVALID_OPERATION is returned via callback.
class WEBKIT_STORAGE_EXPORT FileSystemOperationRunner
: public base::SupportsWeakPtr<FileSystemOperationRunner> {
public:
@@ -211,6 +211,12 @@ class WEBKIT_STORAGE_EXPORT FileSystemOperationRunner
const FileSystemURL& dest_url,
const StatusCallback& callback);
+ // This is called only by pepper plugin as of writing to synchronously get
+ // the underlying platform path to upload a file in the sandboxed filesystem
+ // (e.g. TEMPORARY or PERSISTENT).
+ base::PlatformFileError SyncGetPlatformPath(const FileSystemURL& url,
+ base::FilePath* platform_path);
+
private:
friend class FileSystemContext;
explicit FileSystemOperationRunner(FileSystemContext* file_system_context);
diff --git a/webkit/browser/fileapi/file_system_url_request_job.cc b/webkit/browser/fileapi/file_system_url_request_job.cc
index a08682c..617f980 100644
--- a/webkit/browser/fileapi/file_system_url_request_job.cc
+++ b/webkit/browser/fileapi/file_system_url_request_job.cc
@@ -28,7 +28,7 @@
#include "net/url_request/url_request.h"
#include "webkit/browser/blob/file_stream_reader.h"
#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/local_file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/common/fileapi/file_system_util.h"
using net::NetworkDelegate;
@@ -157,15 +157,7 @@ void FileSystemURLRequestJob::StartAsync() {
return;
DCHECK(!reader_.get());
url_ = file_system_context_->CrackURL(request_->url());
- base::PlatformFileError error_code;
- FileSystemOperation* operation =
- file_system_context_->CreateFileSystemOperation(url_, &error_code);
- if (error_code != base::PLATFORM_FILE_OK) {
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
- net::PlatformFileErrorToNetError(error_code)));
- return;
- }
- operation->GetMetadata(
+ file_system_context_->operation_runner()->GetMetadata(
url_,
base::Bind(&FileSystemURLRequestJob::DidGetMetadata,
weak_factory_.GetWeakPtr()));
diff --git a/webkit/browser/fileapi/isolated_file_util_unittest.cc b/webkit/browser/fileapi/isolated_file_util_unittest.cc
index cd07bc9..4fb8432 100644
--- a/webkit/browser/fileapi/isolated_file_util_unittest.cc
+++ b/webkit/browser/fileapi/isolated_file_util_unittest.cc
@@ -338,13 +338,6 @@ TEST_F(IsolatedFileUtilTest, UnregisteredPathsTest) {
// We should not be able to get the valid URL for unregistered files.
ASSERT_FALSE(url.is_valid());
-
- // We should not be able to create a new operation for an invalid URL.
- base::PlatformFileError error_code;
- FileSystemOperation* operation =
- file_system_context()->CreateFileSystemOperation(url, &error_code);
- ASSERT_EQ(NULL, operation);
- ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_URL, error_code);
}
}
diff --git a/webkit/browser/fileapi/local_file_system_operation_unittest.cc b/webkit/browser/fileapi/local_file_system_operation_unittest.cc
index 5e6f7a8..fb30b3e 100644
--- a/webkit/browser/fileapi/local_file_system_operation_unittest.cc
+++ b/webkit/browser/fileapi/local_file_system_operation_unittest.cc
@@ -18,6 +18,7 @@
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/mock_file_change_observer.h"
#include "webkit/browser/fileapi/sandbox_file_system_test_helper.h"
#include "webkit/browser/fileapi/sandbox_mount_point_provider.h"
@@ -81,8 +82,8 @@ class LocalFileSystemOperationTest
sandbox_file_system_.TearDown();
}
- LocalFileSystemOperation* NewOperation() {
- return sandbox_file_system_.NewOperation();
+ FileSystemOperationRunner* operation_runner() {
+ return sandbox_file_system_.operation_runner();
}
int status() const { return status_; }
@@ -239,9 +240,9 @@ class LocalFileSystemOperationTest
AsyncFileTestHelper::CreateFile(
sandbox_file_system_.file_system_context(), url);
- NewOperation()->Remove(url, false /* recursive */,
- base::Bind(&AssertFileErrorEq, FROM_HERE,
- base::PLATFORM_FILE_OK));
+ operation_runner()->Remove(url, false /* recursive */,
+ base::Bind(&AssertFileErrorEq, FROM_HERE,
+ base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
change_observer()->ResetCount();
@@ -296,8 +297,8 @@ class LocalFileSystemOperationTest
TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcDoesntExist) {
change_observer()->ResetCount();
- NewOperation()->Move(URLForPath("a"), URLForPath("b"),
- RecordStatusCallback());
+ operation_runner()->Move(URLForPath("a"), URLForPath("b"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -307,7 +308,7 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureContainsPath) {
FileSystemURL src_dir(CreateDirectory("src"));
FileSystemURL dest_dir(CreateDirectory("src/dest"));
- NewOperation()->Move(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Move(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -319,7 +320,7 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcDirExistsDestFile) {
FileSystemURL dest_dir(CreateDirectory("dest"));
FileSystemURL dest_file(CreateFile("dest/file"));
- NewOperation()->Move(src_dir, dest_file, RecordStatusCallback());
+ operation_runner()->Move(src_dir, dest_file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -332,7 +333,7 @@ TEST_F(LocalFileSystemOperationTest,
FileSystemURL dest_dir(CreateDirectory("dest"));
FileSystemURL dest_file(CreateFile("dest/file"));
- NewOperation()->Move(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Move(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -344,7 +345,7 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcFileExistsDestDir) {
FileSystemURL src_file(CreateFile("src/file"));
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Move(src_file, dest_dir, RecordStatusCallback());
+ operation_runner()->Move(src_file, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -353,8 +354,8 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcFileExistsDestDir) {
TEST_F(LocalFileSystemOperationTest, TestMoveFailureDestParentDoesntExist) {
// Dest. parent path does not exist.
FileSystemURL src_dir(CreateDirectory("src"));
- NewOperation()->Move(src_dir, URLForPath("nonexistent/deset"),
- RecordStatusCallback());
+ operation_runner()->Move(src_dir, URLForPath("nonexistent/deset"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -364,7 +365,7 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcFileAndOverwrite) {
FileSystemURL src_file(CreateFile("src"));
FileSystemURL dest_file(CreateFile("dest"));
- NewOperation()->Move(src_file, dest_file, RecordStatusCallback());
+ operation_runner()->Move(src_file, dest_file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists("dest"));
@@ -379,7 +380,7 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcFileAndOverwrite) {
TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcFileAndNew) {
FileSystemURL src_file(CreateFile("src"));
- NewOperation()->Move(src_file, URLForPath("new"), RecordStatusCallback());
+ operation_runner()->Move(src_file, URLForPath("new"), RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists("new"));
@@ -393,7 +394,7 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirAndOverwrite) {
FileSystemURL src_dir(CreateDirectory("src"));
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Move(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Move(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists("src"));
@@ -411,7 +412,8 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirAndNew) {
FileSystemURL src_dir(CreateDirectory("src"));
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Move(src_dir, URLForPath("dest/new"), RecordStatusCallback());
+ operation_runner()->Move(src_dir, URLForPath("dest/new"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists("src"));
@@ -429,7 +431,7 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirRecursive) {
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Move(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Move(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists("dest/dir"));
@@ -443,8 +445,8 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirRecursive) {
}
TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcDoesntExist) {
- NewOperation()->Copy(URLForPath("a"), URLForPath("b"),
- RecordStatusCallback());
+ operation_runner()->Copy(URLForPath("a"), URLForPath("b"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -454,7 +456,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureContainsPath) {
FileSystemURL src_dir(CreateDirectory("src"));
FileSystemURL dest_dir(CreateDirectory("src/dir"));
- NewOperation()->Copy(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Copy(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -466,7 +468,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcDirExistsDestFile) {
FileSystemURL dest_dir(CreateDirectory("dest"));
FileSystemURL dest_file(CreateFile("dest/file"));
- NewOperation()->Copy(src_dir, dest_file, RecordStatusCallback());
+ operation_runner()->Copy(src_dir, dest_file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -479,7 +481,7 @@ TEST_F(LocalFileSystemOperationTest,
FileSystemURL dest_dir(CreateDirectory("dest"));
FileSystemURL dest_file(CreateFile("dest/file"));
- NewOperation()->Copy(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Copy(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -490,7 +492,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcFileExistsDestDir) {
FileSystemURL src_file(CreateFile("src"));
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Copy(src_file, dest_dir, RecordStatusCallback());
+ operation_runner()->Copy(src_file, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -500,8 +502,8 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureDestParentDoesntExist) {
// Dest. parent path does not exist.
FileSystemURL src_dir(CreateDirectory("src"));
- NewOperation()->Copy(src_dir, URLForPath("nonexistent/dest"),
- RecordStatusCallback());
+ operation_runner()->Copy(src_dir, URLForPath("nonexistent/dest"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -511,7 +513,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureByQuota) {
FileSystemURL src_dir(CreateDirectory("src"));
FileSystemURL src_file(CreateFile("src/file"));
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Truncate(src_file, 6, RecordStatusCallback());
+ operation_runner()->Truncate(src_file, 6, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_EQ(6, GetFileSize("src/file"));
@@ -521,7 +523,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureByQuota) {
GrantQuotaForCurrentUsage();
AddQuota(6 + dest_path_cost - 1);
- NewOperation()->Copy(src_file, dest_file, RecordStatusCallback());
+ operation_runner()->Copy(src_file, dest_file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status());
EXPECT_FALSE(FileExists("dest/file"));
@@ -531,7 +533,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcFileAndOverwrite) {
FileSystemURL src_file(CreateFile("src"));
FileSystemURL dest_file(CreateFile("dest"));
- NewOperation()->Copy(src_file, dest_file, RecordStatusCallback());
+ operation_runner()->Copy(src_file, dest_file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists("dest"));
@@ -544,8 +546,8 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcFileAndOverwrite) {
TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcFileAndNew) {
FileSystemURL src_file(CreateFile("src"));
- NewOperation()->Copy(src_file, URLForPath("new"),
- RecordStatusCallback());
+ operation_runner()->Copy(src_file, URLForPath("new"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists("new"));
@@ -559,7 +561,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcDirAndOverwrite) {
FileSystemURL src_dir(CreateDirectory("src"));
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Copy(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Copy(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -577,7 +579,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcDirAndNew) {
FileSystemURL src_dir(CreateDirectory("src"));
FileSystemURL dest_dir_new(URLForPath("dest"));
- NewOperation()->Copy(src_dir, dest_dir_new, RecordStatusCallback());
+ operation_runner()->Copy(src_dir, dest_dir_new, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists("dest"));
@@ -594,7 +596,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcDirRecursive) {
FileSystemURL dest_dir(CreateDirectory("dest"));
- NewOperation()->Copy(src_dir, dest_dir, RecordStatusCallback());
+ operation_runner()->Copy(src_dir, dest_dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -623,9 +625,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyInForeignFileSuccess) {
GetUsageAndQuota(&before_usage, NULL);
// Check that the file copied and corresponding usage increased.
- NewOperation()->CopyInForeignFile(src_local_disk_file_path,
- URLForPath("dest/file"),
- RecordStatusCallback());
+ operation_runner()->CopyInForeignFile(src_local_disk_file_path,
+ URLForPath("dest/file"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(1, change_observer()->create_file_count());
@@ -653,9 +655,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyInForeignFileFailureByQuota) {
FileSystemURL dest_dir(CreateDirectory("dest"));
GrantQuotaForCurrentUsage();
- NewOperation()->CopyInForeignFile(src_local_disk_file_path,
- URLForPath("dest/file"),
- RecordStatusCallback());
+ operation_runner()->CopyInForeignFile(src_local_disk_file_path,
+ URLForPath("dest/file"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_FALSE(FileExists("dest/file"));
@@ -666,7 +668,7 @@ TEST_F(LocalFileSystemOperationTest, TestCopyInForeignFileFailureByQuota) {
TEST_F(LocalFileSystemOperationTest, TestCreateFileFailure) {
// Already existing file and exclusive true.
FileSystemURL file(CreateFile("file"));
- NewOperation()->CreateFile(file, true, RecordStatusCallback());
+ operation_runner()->CreateFile(file, true, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -675,7 +677,7 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileFailure) {
TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessFileExists) {
// Already existing file and exclusive false.
FileSystemURL file(CreateFile("file"));
- NewOperation()->CreateFile(file, false, RecordStatusCallback());
+ operation_runner()->CreateFile(file, false, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists("file"));
@@ -686,7 +688,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessFileExists) {
TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessExclusive) {
// File doesn't exist but exclusive is true.
- NewOperation()->CreateFile(URLForPath("new"), true, RecordStatusCallback());
+ operation_runner()->CreateFile(URLForPath("new"), true,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists("new"));
@@ -695,8 +698,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessExclusive) {
TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessFileDoesntExist) {
// Non existing file.
- NewOperation()->CreateFile(URLForPath("nonexistent"), false,
- RecordStatusCallback());
+ operation_runner()->CreateFile(URLForPath("nonexistent"), false,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count());
@@ -705,7 +708,7 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessFileDoesntExist) {
TEST_F(LocalFileSystemOperationTest,
TestCreateDirFailureDestParentDoesntExist) {
// Dest. parent path does not exist.
- NewOperation()->CreateDirectory(
+ operation_runner()->CreateDirectory(
URLForPath("nonexistent/dir"), false, false,
RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
@@ -716,8 +719,8 @@ TEST_F(LocalFileSystemOperationTest,
TEST_F(LocalFileSystemOperationTest, TestCreateDirFailureDirExists) {
// Exclusive and dir existing at path.
FileSystemURL dir(CreateDirectory("dir"));
- NewOperation()->CreateDirectory(dir, true, false,
- RecordStatusCallback());
+ operation_runner()->CreateDirectory(dir, true, false,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -726,8 +729,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirFailureDirExists) {
TEST_F(LocalFileSystemOperationTest, TestCreateDirFailureFileExists) {
// Exclusive true and file existing at path.
FileSystemURL file(CreateFile("file"));
- NewOperation()->CreateDirectory(file, true, false,
- RecordStatusCallback());
+ operation_runner()->CreateDirectory(file, true, false,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -736,15 +739,15 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirFailureFileExists) {
TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccess) {
// Dir exists and exclusive is false.
FileSystemURL dir(CreateDirectory("dir"));
- NewOperation()->CreateDirectory(dir, false, false,
- RecordStatusCallback());
+ operation_runner()->CreateDirectory(dir, false, false,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(change_observer()->HasNoChange());
// Dir doesn't exist.
- NewOperation()->CreateDirectory(URLForPath("new"), false, false,
- RecordStatusCallback());
+ operation_runner()->CreateDirectory(URLForPath("new"), false, false,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists("new"));
@@ -753,8 +756,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccess) {
TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccessExclusive) {
// Dir doesn't exist.
- NewOperation()->CreateDirectory(URLForPath("new"), true, false,
- RecordStatusCallback());
+ operation_runner()->CreateDirectory(URLForPath("new"), true, false,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists("new"));
@@ -763,18 +766,18 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccessExclusive) {
}
TEST_F(LocalFileSystemOperationTest, TestExistsAndMetadataFailure) {
- NewOperation()->GetMetadata(URLForPath("nonexistent"),
- RecordMetadataCallback());
+ operation_runner()->GetMetadata(URLForPath("nonexistent"),
+ RecordMetadataCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
- NewOperation()->FileExists(URLForPath("nonexistent"),
- RecordStatusCallback());
+ operation_runner()->FileExists(URLForPath("nonexistent"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
- NewOperation()->DirectoryExists(URLForPath("nonexistent"),
- RecordStatusCallback());
+ operation_runner()->DirectoryExists(URLForPath("nonexistent"),
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -785,24 +788,24 @@ TEST_F(LocalFileSystemOperationTest, TestExistsAndMetadataSuccess) {
FileSystemURL file(CreateFile("dir/file"));
int read_access = 0;
- NewOperation()->DirectoryExists(dir, RecordStatusCallback());
+ operation_runner()->DirectoryExists(dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
++read_access;
- NewOperation()->GetMetadata(dir, RecordMetadataCallback());
+ operation_runner()->GetMetadata(dir, RecordMetadataCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(info().is_directory);
EXPECT_EQ(base::FilePath(), path());
++read_access;
- NewOperation()->FileExists(file, RecordStatusCallback());
+ operation_runner()->FileExists(file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
++read_access;
- NewOperation()->GetMetadata(file, RecordMetadataCallback());
+ operation_runner()->GetMetadata(file, RecordMetadataCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(info().is_directory);
@@ -816,26 +819,26 @@ TEST_F(LocalFileSystemOperationTest, TestExistsAndMetadataSuccess) {
TEST_F(LocalFileSystemOperationTest, TestTypeMismatchErrors) {
FileSystemURL dir(CreateDirectory("dir"));
- NewOperation()->FileExists(dir, RecordStatusCallback());
+ operation_runner()->FileExists(dir, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_FILE, status());
FileSystemURL file(CreateFile("file"));
- NewOperation()->DirectoryExists(file, RecordStatusCallback());
+ operation_runner()->DirectoryExists(file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, status());
}
TEST_F(LocalFileSystemOperationTest, TestReadDirFailure) {
// Path doesn't exist
- NewOperation()->ReadDirectory(URLForPath("nonexistent"),
- RecordReadDirectoryCallback());
+ operation_runner()->ReadDirectory(URLForPath("nonexistent"),
+ RecordReadDirectoryCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
// File exists.
FileSystemURL file(CreateFile("file"));
- NewOperation()->ReadDirectory(file, RecordReadDirectoryCallback());
+ operation_runner()->ReadDirectory(file, RecordReadDirectoryCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -850,7 +853,7 @@ TEST_F(LocalFileSystemOperationTest, TestReadDirSuccess) {
FileSystemURL child_dir(CreateDirectory("dir/child_dir"));
FileSystemURL child_file(CreateFile("dir/child_file"));
- NewOperation()->ReadDirectory(parent_dir, RecordReadDirectoryCallback());
+ operation_runner()->ReadDirectory(parent_dir, RecordReadDirectoryCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_EQ(2u, entries().size());
@@ -867,8 +870,8 @@ TEST_F(LocalFileSystemOperationTest, TestReadDirSuccess) {
TEST_F(LocalFileSystemOperationTest, TestRemoveFailure) {
// Path doesn't exist.
- NewOperation()->Remove(URLForPath("nonexistent"), false /* recursive */,
- RecordStatusCallback());
+ operation_runner()->Remove(URLForPath("nonexistent"), false /* recursive */,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
@@ -882,8 +885,8 @@ TEST_F(LocalFileSystemOperationTest, TestRemoveFailure) {
FileSystemURL child_dir(CreateDirectory("dir/child_dir"));
FileSystemURL child_file(CreateFile("dir/child_file"));
- NewOperation()->Remove(parent_dir, false /* recursive */,
- RecordStatusCallback());
+ operation_runner()->Remove(parent_dir, false /* recursive */,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -892,8 +895,8 @@ TEST_F(LocalFileSystemOperationTest, TestRemoveFailure) {
TEST_F(LocalFileSystemOperationTest, TestRemoveSuccess) {
FileSystemURL empty_dir(CreateDirectory("empty_dir"));
EXPECT_TRUE(DirectoryExists("empty_dir"));
- NewOperation()->Remove(empty_dir, false /* recursive */,
- RecordStatusCallback());
+ operation_runner()->Remove(empty_dir, false /* recursive */,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists("empty_dir"));
@@ -918,8 +921,8 @@ TEST_F(LocalFileSystemOperationTest, TestRemoveSuccessRecursive) {
for (int i = 0; i < 8; ++i)
CreateFile(base::StringPrintf("dir/child_dir/file-%d", i));
- NewOperation()->Remove(parent_dir, true /* recursive */,
- RecordStatusCallback());
+ operation_runner()->Remove(parent_dir, true /* recursive */,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists("parent_dir"));
@@ -939,7 +942,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncate) {
file_util::WriteFile(platform_path, test_data, data_size));
// Check that its length is the size of the data written.
- NewOperation()->GetMetadata(file, RecordMetadataCallback());
+ operation_runner()->GetMetadata(file, RecordMetadataCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(info().is_directory);
@@ -947,7 +950,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncate) {
// Extend the file by truncating it.
int length = 17;
- NewOperation()->Truncate(file, length, RecordStatusCallback());
+ operation_runner()->Truncate(file, length, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -968,7 +971,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncate) {
// Shorten the file by truncating it.
length = 3;
- NewOperation()->Truncate(file, length, RecordStatusCallback());
+ operation_runner()->Truncate(file, length, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -993,7 +996,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncateFailureByQuota) {
GrantQuotaForCurrentUsage();
AddQuota(10);
- NewOperation()->Truncate(file, 10, RecordStatusCallback());
+ operation_runner()->Truncate(file, 10, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
@@ -1001,7 +1004,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncateFailureByQuota) {
EXPECT_EQ(10, GetFileSize("dir/file"));
- NewOperation()->Truncate(file, 11, RecordStatusCallback());
+ operation_runner()->Truncate(file, 11, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -1026,8 +1029,8 @@ TEST_F(LocalFileSystemOperationTest, TestTouchFile) {
ASSERT_NE(last_modified, new_modified_time);
ASSERT_NE(last_accessed, new_accessed_time);
- NewOperation()->TouchFile(file, new_accessed_time, new_modified_time,
- RecordStatusCallback());
+ operation_runner()->TouchFile(file, new_accessed_time, new_modified_time,
+ RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -1044,9 +1047,9 @@ TEST_F(LocalFileSystemOperationTest, TestCreateSnapshotFile) {
FileSystemURL dir(CreateDirectory("dir"));
// Create a file for the testing.
- NewOperation()->DirectoryExists(dir, RecordStatusCallback());
+ operation_runner()->DirectoryExists(dir, RecordStatusCallback());
FileSystemURL file(CreateFile("dir/file"));
- NewOperation()->FileExists(file, RecordStatusCallback());
+ operation_runner()->FileExists(file, RecordStatusCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -1054,7 +1057,7 @@ TEST_F(LocalFileSystemOperationTest, TestCreateSnapshotFile) {
// Since LocalFileSystemOperation assumes the file exists in the local
// directory it should just returns the same metadata and platform_path
// as the file itself.
- NewOperation()->CreateSnapshotFile(file, RecordSnapshotFileCallback());
+ operation_runner()->CreateSnapshotFile(file, RecordSnapshotFileCallback());
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(info().is_directory);
@@ -1081,16 +1084,16 @@ TEST_F(LocalFileSystemOperationTest,
int total_path_cost = GetUsage();
EXPECT_EQ(0, GetDataSizeOnDisk());
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
child_file1, 5000,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
child_file2, 400,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
grandchild_file1, 30,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
grandchild_file2, 2,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -1099,7 +1102,7 @@ TEST_F(LocalFileSystemOperationTest,
EXPECT_EQ(all_file_size, GetDataSizeOnDisk());
EXPECT_EQ(all_file_size + total_path_cost, GetUsage());
- NewOperation()->Move(
+ operation_runner()->Move(
src, dest,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -1134,16 +1137,16 @@ TEST_F(LocalFileSystemOperationTest,
EXPECT_EQ(0, GetDataSizeOnDisk());
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
child_file1, 8000,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
child_file2, 700,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
grandchild_file1, 60,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
- NewOperation()->Truncate(
+ operation_runner()->Truncate(
grandchild_file2, 5,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -1158,7 +1161,7 @@ TEST_F(LocalFileSystemOperationTest,
EXPECT_EQ(expected_usage, usage);
// Copy src to dest1.
- NewOperation()->Copy(
+ operation_runner()->Copy(
src, dest1,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -1173,7 +1176,7 @@ TEST_F(LocalFileSystemOperationTest,
EXPECT_EQ(expected_usage, GetUsage());
// Copy src/dir to dest2.
- NewOperation()->Copy(
+ operation_runner()->Copy(
child_dir, dest2,
base::Bind(&AssertFileErrorEq, FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
diff --git a/webkit/browser/fileapi/local_file_system_operation_write_unittest.cc b/webkit/browser/fileapi/local_file_system_operation_write_unittest.cc
index 8c908e5..e6eda67 100644
--- a/webkit/browser/fileapi/local_file_system_operation_write_unittest.cc
+++ b/webkit/browser/fileapi/local_file_system_operation_write_unittest.cc
@@ -20,12 +20,12 @@
#include "webkit/browser/blob/mock_blob_url_request_context.h"
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
-#include "webkit/browser/fileapi/local_file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/local_file_util.h"
#include "webkit/browser/fileapi/mock_file_change_observer.h"
#include "webkit/browser/fileapi/mock_file_system_context.h"
+#include "webkit/browser/fileapi/test_mount_point_provider.h"
#include "webkit/browser/quota/mock_quota_manager.h"
#include "webkit/common/blob/blob_data.h"
#include "webkit/common/fileapi/file_system_util.h"
@@ -75,9 +75,13 @@ class LocalFileSystemOperationWriteTest
url_request_context_.reset(
new MockBlobURLRequestContext(file_system_context_.get()));
- NewOperation()->CreateFile(
+ file_system_context_->operation_runner()->CreateFile(
URLForPath(virtual_path_), true /* exclusive */,
base::Bind(&AssertStatusEq, base::PLATFORM_FILE_OK));
+
+ static_cast<TestMountPointProvider*>(
+ file_system_context_->GetMountPointProvider(kFileSystemType))
+ ->AddFileChangeObserver(change_observer());
}
virtual void TearDown() {
@@ -86,14 +90,6 @@ class LocalFileSystemOperationWriteTest
base::MessageLoop::current()->RunUntilIdle();
}
- LocalFileSystemOperation* NewOperation() {
- LocalFileSystemOperation* operation =
- file_system_context_->CreateFileSystemOperation(
- URLForPath(base::FilePath()), NULL)->AsLocalFileSystemOperation();
- operation->operation_context()->set_change_observers(change_observers());
- return operation;
- }
-
base::PlatformFileError status() const { return status_; }
base::PlatformFileError cancel_status() const { return cancel_status_; }
void add_bytes_written(int64 bytes, bool complete) {
@@ -178,7 +174,7 @@ TEST_F(LocalFileSystemOperationWriteTest, TestWriteSuccess) {
const GURL blob_url("blob:success");
ScopedTextBlob blob(url_request_context(), blob_url, "Hello, world!\n");
- NewOperation()->Write(
+ file_system_context_->operation_runner()->Write(
&url_request_context(), URLForPath(virtual_path_), blob_url,
0, RecordWriteCallback());
base::MessageLoop::current()->Run();
@@ -197,7 +193,7 @@ TEST_F(LocalFileSystemOperationWriteTest, TestWriteZero) {
url_request_context().blob_storage_controller()
->AddFinishedBlob(blob_url, blob_data.get());
- NewOperation()->Write(
+ file_system_context_->operation_runner()->Write(
&url_request_context(), URLForPath(virtual_path_),
blob_url, 0, RecordWriteCallback());
base::MessageLoop::current()->Run();
@@ -212,7 +208,7 @@ TEST_F(LocalFileSystemOperationWriteTest, TestWriteZero) {
}
TEST_F(LocalFileSystemOperationWriteTest, TestWriteInvalidBlobUrl) {
- NewOperation()->Write(
+ file_system_context_->operation_runner()->Write(
&url_request_context(), URLForPath(virtual_path_),
GURL("blob:invalid"), 0, RecordWriteCallback());
base::MessageLoop::current()->Run();
@@ -229,7 +225,7 @@ TEST_F(LocalFileSystemOperationWriteTest, TestWriteInvalidFile) {
ScopedTextBlob blob(url_request_context(), blob_url,
"It\'ll not be written.");
- NewOperation()->Write(
+ file_system_context_->operation_runner()->Write(
&url_request_context(),
URLForPath(base::FilePath(FILE_PATH_LITERAL("nonexist"))),
blob_url, 0, RecordWriteCallback());
@@ -244,7 +240,7 @@ TEST_F(LocalFileSystemOperationWriteTest, TestWriteInvalidFile) {
TEST_F(LocalFileSystemOperationWriteTest, TestWriteDir) {
base::FilePath virtual_dir_path(FILE_PATH_LITERAL("d"));
- NewOperation()->CreateDirectory(
+ file_system_context_->operation_runner()->CreateDirectory(
URLForPath(virtual_dir_path),
true /* exclusive */, false /* recursive */,
base::Bind(&AssertStatusEq, base::PLATFORM_FILE_OK));
@@ -253,7 +249,8 @@ TEST_F(LocalFileSystemOperationWriteTest, TestWriteDir) {
ScopedTextBlob blob(url_request_context(), blob_url,
"It\'ll not be written, too.");
- NewOperation()->Write(&url_request_context(), URLForPath(virtual_dir_path),
+ file_system_context_->operation_runner()->Write(
+ &url_request_context(), URLForPath(virtual_dir_path),
blob_url, 0, RecordWriteCallback());
base::MessageLoop::current()->Run();
@@ -274,7 +271,7 @@ TEST_F(LocalFileSystemOperationWriteTest, TestWriteFailureByQuota) {
quota_manager_->SetQuota(
kOrigin, FileSystemTypeToQuotaStorageType(kFileSystemType), 10);
- NewOperation()->Write(
+ file_system_context_->operation_runner()->Write(
&url_request_context(), URLForPath(virtual_path_), blob_url,
0, RecordWriteCallback());
base::MessageLoop::current()->Run();
@@ -290,10 +287,11 @@ TEST_F(LocalFileSystemOperationWriteTest, TestImmediateCancelSuccessfulWrite) {
GURL blob_url("blob:success");
ScopedTextBlob blob(url_request_context(), blob_url, "Hello, world!\n");
- FileSystemOperation* write_operation = NewOperation();
- write_operation->Write(&url_request_context(), URLForPath(virtual_path_),
- blob_url, 0, RecordWriteCallback());
- write_operation->Cancel(RecordCancelCallback());
+ FileSystemOperationRunner::OperationID id =
+ file_system_context_->operation_runner()->Write(
+ &url_request_context(), URLForPath(virtual_path_),
+ blob_url, 0, RecordWriteCallback());
+ file_system_context_->operation_runner()->Cancel(id, RecordCancelCallback());
// We use RunAllPendings() instead of Run() here, because we won't dispatch
// callbacks after Cancel() is issued (so no chance to Quit) nor do we need
// to run another write cycle.
@@ -314,12 +312,12 @@ TEST_F(LocalFileSystemOperationWriteTest, TestImmediateCancelFailingWrite) {
ScopedTextBlob blob(url_request_context(), blob_url,
"It\'ll not be written.");
- FileSystemOperation* write_operation = NewOperation();
- write_operation->Write(
- &url_request_context(),
- URLForPath(base::FilePath(FILE_PATH_LITERAL("nonexist"))),
- blob_url, 0, RecordWriteCallback());
- write_operation->Cancel(RecordCancelCallback());
+ FileSystemOperationRunner::OperationID id =
+ file_system_context_->operation_runner()->Write(
+ &url_request_context(),
+ URLForPath(base::FilePath(FILE_PATH_LITERAL("nonexist"))),
+ blob_url, 0, RecordWriteCallback());
+ file_system_context_->operation_runner()->Cancel(id, RecordCancelCallback());
// We use RunAllPendings() instead of Run() here, because we won't dispatch
// callbacks after Cancel() is issued (so no chance to Quit) nor do we need
// to run another write cycle.
diff --git a/webkit/browser/fileapi/sandbox_file_stream_writer.cc b/webkit/browser/fileapi/sandbox_file_stream_writer.cc
index cfdf25f..5b159e8 100644
--- a/webkit/browser/fileapi/sandbox_file_stream_writer.cc
+++ b/webkit/browser/fileapi/sandbox_file_stream_writer.cc
@@ -12,7 +12,7 @@
#include "webkit/browser/blob/local_file_stream_reader.h"
#include "webkit/browser/fileapi/file_observers.h"
#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/local_file_stream_writer.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/common/fileapi/file_system_util.h"
@@ -66,18 +66,11 @@ int SandboxFileStreamWriter::Write(
if (local_file_writer_)
return WriteInternal(buf, buf_len, callback);
- base::PlatformFileError error_code;
- FileSystemOperation* operation =
- file_system_context_->CreateFileSystemOperation(url_, &error_code);
- if (error_code != base::PLATFORM_FILE_OK)
- return net::PlatformFileErrorToNetError(error_code);
-
- DCHECK(operation);
net::CompletionCallback write_task =
base::Bind(&SandboxFileStreamWriter::DidInitializeForWrite,
weak_factory_.GetWeakPtr(),
make_scoped_refptr(buf), buf_len, callback);
- operation->GetMetadata(
+ file_system_context_->operation_runner()->GetMetadata(
url_, base::Bind(&SandboxFileStreamWriter::DidGetFileInfo,
weak_factory_.GetWeakPtr(), write_task));
return net::ERR_IO_PENDING;
diff --git a/webkit/browser/fileapi/sandbox_file_system_test_helper.cc b/webkit/browser/fileapi/sandbox_file_system_test_helper.cc
index d55b013..cc31b19 100644
--- a/webkit/browser/fileapi/sandbox_file_system_test_helper.cc
+++ b/webkit/browser/fileapi/sandbox_file_system_test_helper.cc
@@ -11,10 +11,10 @@
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_task_runners.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/file_system_usage_cache.h"
-#include "webkit/browser/fileapi/local_file_system_operation.h"
#include "webkit/browser/fileapi/mock_file_system_context.h"
#include "webkit/browser/fileapi/sandbox_mount_point_provider.h"
#include "webkit/browser/quota/mock_special_storage_policy.h"
@@ -109,13 +109,8 @@ SandboxFileSystemTestHelper::ComputeCurrentDirectoryDatabaseUsage() {
GetOriginRootPath().AppendASCII("Paths"));
}
-LocalFileSystemOperation* SandboxFileSystemTestHelper::NewOperation() {
- DCHECK(file_system_context_.get());
- DCHECK(file_util_);
- LocalFileSystemOperation* operation = static_cast<LocalFileSystemOperation*>(
- file_system_context_->CreateFileSystemOperation(
- CreateURL(base::FilePath()), NULL));
- return operation;
+FileSystemOperationRunner* SandboxFileSystemTestHelper::operation_runner() {
+ return file_system_context_->operation_runner();
}
FileSystemOperationContext*
diff --git a/webkit/browser/fileapi/sandbox_file_system_test_helper.h b/webkit/browser/fileapi/sandbox_file_system_test_helper.h
index 5a8042b..aa699d5 100644
--- a/webkit/browser/fileapi/sandbox_file_system_test_helper.h
+++ b/webkit/browser/fileapi/sandbox_file_system_test_helper.h
@@ -29,6 +29,7 @@ namespace fileapi {
class FileSystemContext;
class FileSystemFileUtil;
class FileSystemOperationContext;
+class FileSystemOperationRunner;
class LocalFileSystemOperation;
// Filesystem test helper class that encapsulates test environment for
@@ -70,7 +71,7 @@ class SandboxFileSystemTestHelper {
int64 ComputeCurrentDirectoryDatabaseUsage();
- LocalFileSystemOperation* NewOperation();
+ FileSystemOperationRunner* operation_runner();
FileSystemOperationContext* NewOperationContext();
FileSystemContext* file_system_context() const {
diff --git a/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc b/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc
index 5268100..5173a9a 100644
--- a/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc
+++ b/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc
@@ -17,8 +17,8 @@
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_mount_point_provider.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_task_runners.h"
-#include "webkit/browser/fileapi/local_file_system_operation.h"
#include "webkit/browser/fileapi/mock_file_system_options.h"
#include "webkit/browser/fileapi/sandbox_mount_point_provider.h"
#include "webkit/browser/fileapi/syncable/local_file_change_tracker.h"
@@ -29,7 +29,7 @@
using base::PlatformFileError;
using fileapi::FileSystemContext;
-using fileapi::FileSystemOperation;
+using fileapi::FileSystemOperationRunner;
using fileapi::FileSystemURL;
using fileapi::FileSystemURLSet;
using quota::QuotaManager;
@@ -476,9 +476,8 @@ void CannedSyncableFileSystem::ClearChangeForURLInTracker(
url));
}
-FileSystemOperation* CannedSyncableFileSystem::NewOperation() {
- return file_system_context_->CreateFileSystemOperation(URL(std::string()),
- NULL);
+FileSystemOperationRunner* CannedSyncableFileSystem::operation_runner() {
+ return file_system_context_->operation_runner();
}
void CannedSyncableFileSystem::OnSyncEnabled(const FileSystemURL& url) {
@@ -495,7 +494,7 @@ void CannedSyncableFileSystem::DoCreateDirectory(
const FileSystemURL& url,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->CreateDirectory(
+ operation_runner()->CreateDirectory(
url, false /* exclusive */, false /* recursive */, callback);
}
@@ -503,7 +502,7 @@ void CannedSyncableFileSystem::DoCreateFile(
const FileSystemURL& url,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->CreateFile(url, false /* exclusive */, callback);
+ operation_runner()->CreateFile(url, false /* exclusive */, callback);
}
void CannedSyncableFileSystem::DoCopy(
@@ -511,7 +510,7 @@ void CannedSyncableFileSystem::DoCopy(
const FileSystemURL& dest_url,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->Copy(src_url, dest_url, callback);
+ operation_runner()->Copy(src_url, dest_url, callback);
}
void CannedSyncableFileSystem::DoMove(
@@ -519,14 +518,14 @@ void CannedSyncableFileSystem::DoMove(
const FileSystemURL& dest_url,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->Move(src_url, dest_url, callback);
+ operation_runner()->Move(src_url, dest_url, callback);
}
void CannedSyncableFileSystem::DoTruncateFile(
const FileSystemURL& url, int64 size,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->Truncate(url, size, callback);
+ operation_runner()->Truncate(url, size, callback);
}
void CannedSyncableFileSystem::DoTouchFile(
@@ -535,27 +534,27 @@ void CannedSyncableFileSystem::DoTouchFile(
const base::Time& last_modified_time,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->TouchFile(url, last_access_time,
- last_modified_time, callback);
+ operation_runner()->TouchFile(url, last_access_time,
+ last_modified_time, callback);
}
void CannedSyncableFileSystem::DoRemove(
const FileSystemURL& url, bool recursive,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->Remove(url, recursive, callback);
+ operation_runner()->Remove(url, recursive, callback);
}
void CannedSyncableFileSystem::DoFileExists(
const FileSystemURL& url, const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->FileExists(url, callback);
+ operation_runner()->FileExists(url, callback);
}
void CannedSyncableFileSystem::DoDirectoryExists(
const FileSystemURL& url, const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->DirectoryExists(url, callback);
+ operation_runner()->DirectoryExists(url, callback);
}
void CannedSyncableFileSystem::DoVerifyFile(
@@ -563,9 +562,8 @@ void CannedSyncableFileSystem::DoVerifyFile(
const std::string& expected_data,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->GetMetadata(
- url, base::Bind(&OnGetMetadataAndVerifyData,
- expected_data, callback));
+ operation_runner()->GetMetadata(
+ url, base::Bind(&OnGetMetadataAndVerifyData, expected_data, callback));
}
void CannedSyncableFileSystem::DoGetMetadata(
@@ -574,7 +572,7 @@ void CannedSyncableFileSystem::DoGetMetadata(
base::FilePath* platform_path,
const StatusCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
- NewOperation()->GetMetadata(
+ operation_runner()->GetMetadata(
url, base::Bind(&OnGetMetadata, info, platform_path, callback));
}
@@ -584,9 +582,9 @@ void CannedSyncableFileSystem::DoWrite(
const WriteCallback& callback) {
EXPECT_TRUE(is_filesystem_opened_);
WriteHelper* helper = new WriteHelper;
- NewOperation()->Write(url_request_context, url, blob_url, 0,
- base::Bind(&WriteHelper::DidWrite,
- base::Owned(helper), callback));
+ operation_runner()->Write(url_request_context, url, blob_url, 0,
+ base::Bind(&WriteHelper::DidWrite,
+ base::Owned(helper), callback));
}
void CannedSyncableFileSystem::DoWriteString(
@@ -597,9 +595,9 @@ void CannedSyncableFileSystem::DoWriteString(
new MockBlobURLRequestContext(file_system_context_.get()));
const GURL blob_url(std::string("blob:") + data);
WriteHelper* helper = new WriteHelper(url_request_context, blob_url, data);
- NewOperation()->Write(url_request_context, url, blob_url, 0,
- base::Bind(&WriteHelper::DidWrite,
- base::Owned(helper), callback));
+ operation_runner()->Write(url_request_context, url, blob_url, 0,
+ base::Bind(&WriteHelper::DidWrite,
+ base::Owned(helper), callback));
}
void CannedSyncableFileSystem::DoGetUsageAndQuota(
diff --git a/webkit/browser/fileapi/syncable/canned_syncable_file_system.h b/webkit/browser/fileapi/syncable/canned_syncable_file_system.h
index 2242ff4..90082ac 100644
--- a/webkit/browser/fileapi/syncable/canned_syncable_file_system.h
+++ b/webkit/browser/fileapi/syncable/canned_syncable_file_system.h
@@ -29,7 +29,7 @@ class Thread;
namespace fileapi {
class FileSystemContext;
-class FileSystemOperation;
+class FileSystemOperationRunner;
class FileSystemURL;
}
@@ -133,8 +133,7 @@ class CannedSyncableFileSystem
void GetChangedURLsInTracker(fileapi::FileSystemURLSet* urls);
void ClearChangeForURLInTracker(const fileapi::FileSystemURL& url);
- // Returns new FileSystemOperation.
- fileapi::FileSystemOperation* NewOperation();
+ fileapi::FileSystemOperationRunner* operation_runner();
// LocalFileSyncStatus::Observer overrides.
virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) OVERRIDE;
diff --git a/webkit/browser/fileapi/syncable/local_file_sync_context.cc b/webkit/browser/fileapi/syncable/local_file_sync_context.cc
index 4a0a176..56fe032 100644
--- a/webkit/browser/fileapi/syncable/local_file_sync_context.cc
+++ b/webkit/browser/fileapi/syncable/local_file_sync_context.cc
@@ -13,8 +13,8 @@
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_task_runners.h"
-#include "webkit/browser/fileapi/local_file_system_operation.h"
#include "webkit/browser/fileapi/syncable/file_change.h"
#include "webkit/browser/fileapi/syncable/local_file_change_tracker.h"
#include "webkit/browser/fileapi/syncable/local_origin_change_observer.h"
@@ -202,12 +202,6 @@ void LocalFileSyncContext::ApplyRemoteChange(
DCHECK(!sync_status()->IsWritable(url));
DCHECK(!sync_status()->IsWriting(url));
- FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
- file_system_context, url);
- FileSystemOperation* operation =
- file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
- DCHECK(operation);
-
FileSystemOperation::StatusCallback operation_callback;
if (change.change() == FileChange::FILE_CHANGE_ADD_OR_UPDATE) {
operation_callback = base::Bind(
@@ -223,7 +217,10 @@ void LocalFileSyncContext::ApplyRemoteChange(
operation_callback = base::Bind(
&LocalFileSyncContext::DidApplyRemoteChange, this, url, callback);
}
- operation->Remove(url_for_sync, true /* recursive */, operation_callback);
+ FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
+ file_system_context, url);
+ file_system_context->operation_runner()->Remove(
+ url_for_sync, true /* recursive */, operation_callback);
}
void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
@@ -247,10 +244,6 @@ void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
file_system_context, url);
- FileSystemOperation* operation =
- file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
- DCHECK(operation);
-
FileSystemOperation::StatusCallback operation_callback = base::Bind(
&LocalFileSyncContext::DidApplyRemoteChange, this, url, callback);
@@ -262,14 +255,14 @@ void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
if (dir_path.empty() ||
fileapi::VirtualPath::DirName(dir_path) == dir_path) {
// Copying into the root directory.
- operation->AsLocalFileSystemOperation()->CopyInForeignFile(
+ file_system_context->operation_runner()->CopyInForeignFile(
local_path, url_for_sync, operation_callback);
} else {
FileSystemURL dir_url = file_system_context->CreateCrackedFileSystemURL(
url_for_sync.origin(),
url_for_sync.mount_type(),
fileapi::VirtualPath::DirName(url_for_sync.virtual_path()));
- operation->CreateDirectory(
+ file_system_context->operation_runner()->CreateDirectory(
dir_url,
false /* exclusive */,
true /* recursive */,
@@ -283,7 +276,7 @@ void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
break;
}
case SYNC_FILE_TYPE_DIRECTORY:
- operation->CreateDirectory(
+ file_system_context->operation_runner()->CreateDirectory(
url_for_sync, false /* exclusive */, true /* recursive */,
operation_callback);
break;
@@ -337,10 +330,7 @@ void LocalFileSyncContext::GetFileMetadata(
FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
file_system_context, url);
- FileSystemOperation* operation =
- file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
- DCHECK(operation);
- operation->GetMetadata(
+ file_system_context->operation_runner()->GetMetadata(
url_for_sync, base::Bind(&LocalFileSyncContext::DidGetFileMetadata,
this, callback));
}
@@ -748,10 +738,7 @@ void LocalFileSyncContext::DidCreateDirectoryForCopyIn(
FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
file_system_context, dest_url);
- FileSystemOperation* operation =
- file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
- DCHECK(operation);
- operation->AsLocalFileSystemOperation()->CopyInForeignFile(
+ file_system_context->operation_runner()->CopyInForeignFile(
local_path, url_for_sync, callback);
}
diff --git a/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc b/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc
index 1d9f4cd..cf2a822 100644
--- a/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc
+++ b/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc
@@ -17,7 +17,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/blob/mock_blob_url_request_context.h"
#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/isolated_context.h"
#include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h"
#include "webkit/browser/fileapi/syncable/file_change.h"
@@ -163,7 +163,7 @@ class LocalFileSyncContextTest : public testing::Test {
}
ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread());
file_error_ = base::PLATFORM_FILE_ERROR_FAILED;
- file_system->NewOperation()->Truncate(
+ file_system->operation_runner()->Truncate(
url, 1, base::Bind(&LocalFileSyncContextTest::DidModifyFile,
base::Unretained(this)));
}
diff --git a/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc b/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc
index 9f2d871..dc3acde 100644
--- a/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc
+++ b/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc
@@ -12,6 +12,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/blob/mock_blob_url_request_context.h"
#include "webkit/browser/fileapi/file_system_context.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h"
#include "webkit/browser/fileapi/syncable/local_file_change_tracker.h"
#include "webkit/browser/fileapi/syncable/local_file_sync_context.h"
@@ -149,17 +150,17 @@ TEST_F(SyncableFileOperationRunnerTest, SimpleQueue) {
// The URL is in syncing so the write operations won't run.
ResetCallbackStatus();
- file_system_.NewOperation()->CreateFile(
+ file_system_.operation_runner()->CreateFile(
URL(kFile), false /* exclusive */,
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
- file_system_.NewOperation()->Truncate(
+ file_system_.operation_runner()->Truncate(
URL(kFile), 1,
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(0, callback_count_);
// Read operations are not blocked (and are executed before queued ones).
- file_system_.NewOperation()->FileExists(
+ file_system_.operation_runner()->FileExists(
URL(kFile), ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_NOT_FOUND));
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(1, callback_count_);
@@ -174,7 +175,7 @@ TEST_F(SyncableFileOperationRunnerTest, SimpleQueue) {
// Now the file must have been created and updated.
ResetCallbackStatus();
- file_system_.NewOperation()->FileExists(
+ file_system_.operation_runner()->FileExists(
URL(kFile), ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(1, callback_count_);
@@ -191,23 +192,23 @@ TEST_F(SyncableFileOperationRunnerTest, WriteToParentAndChild) {
// Writes to kParent and kChild should be all queued up.
ResetCallbackStatus();
- file_system_.NewOperation()->Truncate(
+ file_system_.operation_runner()->Truncate(
URL(kChild), 1, ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
- file_system_.NewOperation()->Remove(
+ file_system_.operation_runner()->Remove(
URL(kParent), true /* recursive */,
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(0, callback_count_);
// Read operations are not blocked (and are executed before queued ones).
- file_system_.NewOperation()->DirectoryExists(
+ file_system_.operation_runner()->DirectoryExists(
URL(kDir), ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(1, callback_count_);
// Writes to unrelated files must succeed as well.
ResetCallbackStatus();
- file_system_.NewOperation()->CreateDirectory(
+ file_system_.operation_runner()->CreateDirectory(
URL(kOther), false /* exclusive */, false /* recursive */,
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -233,10 +234,10 @@ TEST_F(SyncableFileOperationRunnerTest, CopyAndMove) {
// Copying kDir to other directory should succeed, while moving would fail
// (since the source directory is in syncing).
ResetCallbackStatus();
- file_system_.NewOperation()->Copy(
+ file_system_.operation_runner()->Copy(
URL(kDir), URL("dest-copy"),
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
- file_system_.NewOperation()->Move(
+ file_system_.operation_runner()->Move(
URL(kDir), URL("dest-move"),
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -253,7 +254,7 @@ TEST_F(SyncableFileOperationRunnerTest, CopyAndMove) {
// Now the destination is also locked copying kDir should be queued.
ResetCallbackStatus();
- file_system_.NewOperation()->Copy(
+ file_system_.operation_runner()->Copy(
URL(kDir), URL("dest-copy2"),
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -289,7 +290,7 @@ TEST_F(SyncableFileOperationRunnerTest, Write) {
sync_status()->StartSyncing(URL(kFile));
ResetCallbackStatus();
- file_system_.NewOperation()->Write(
+ file_system_.operation_runner()->Write(
&url_request_context_,
URL(kFile), kBlobURL, 0, GetWriteCallback(FROM_HERE));
base::MessageLoop::current()->RunUntilIdle();
@@ -311,10 +312,10 @@ TEST_F(SyncableFileOperationRunnerTest, QueueAndCancel) {
ASSERT_FALSE(sync_status()->IsWritable(URL(kFile)));
ResetCallbackStatus();
- file_system_.NewOperation()->CreateFile(
+ file_system_.operation_runner()->CreateFile(
URL(kFile), false /* exclusive */,
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_ABORT));
- file_system_.NewOperation()->Truncate(
+ file_system_.operation_runner()->Truncate(
URL(kFile), 1,
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_ABORT));
base::MessageLoop::current()->RunUntilIdle();
@@ -345,7 +346,7 @@ TEST_F(SyncableFileOperationRunnerTest, CopyInForeignFile) {
// The URL is in syncing so CopyIn (which is a write operation) won't run.
ResetCallbackStatus();
- file_system_.NewOperation()->AsLocalFileSystemOperation()->CopyInForeignFile(
+ file_system_.operation_runner()->CopyInForeignFile(
temp_path, URL(kFile),
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -370,7 +371,7 @@ TEST_F(SyncableFileOperationRunnerTest, CopyInForeignFile) {
TEST_F(SyncableFileOperationRunnerTest, Cancel) {
// Prepare a file.
- file_system_.NewOperation()->CreateFile(
+ file_system_.operation_runner()->CreateFile(
URL(kFile), false /* exclusive */,
ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
@@ -378,11 +379,12 @@ TEST_F(SyncableFileOperationRunnerTest, Cancel) {
// Run Truncate and immediately cancel. This shouldn't crash.
ResetCallbackStatus();
- FileSystemOperation* operation = file_system_.NewOperation();
- operation->Truncate(
- URL(kFile), 10,
- ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_ABORT));
- operation->Cancel(ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
+ fileapi::FileSystemOperationRunner::OperationID id =
+ file_system_.operation_runner()->Truncate(
+ URL(kFile), 10,
+ ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_ABORT));
+ file_system_.operation_runner()->Cancel(
+ id, ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(2, callback_count_);
}
diff --git a/webkit/browser/fileapi/test_mount_point_provider.cc b/webkit/browser/fileapi/test_mount_point_provider.cc
index 3b6fb2f..e608b67 100644
--- a/webkit/browser/fileapi/test_mount_point_provider.cc
+++ b/webkit/browser/fileapi/test_mount_point_provider.cc
@@ -81,7 +81,7 @@ TestMountPointProvider::TestMountPointProvider(
require_copy_or_move_validator_(false) {
UpdateObserverList::Source source;
source.AddObserver(quota_util_.get(), task_runner_.get());
- observers_ = UpdateObserverList(source);
+ update_observers_ = UpdateObserverList(source);
}
TestMountPointProvider::~TestMountPointProvider() {
@@ -142,7 +142,8 @@ FileSystemOperation* TestMountPointProvider::CreateFileSystemOperation(
base::PlatformFileError* error_code) const {
scoped_ptr<FileSystemOperationContext> operation_context(
new FileSystemOperationContext(context));
- operation_context->set_update_observers(observers_);
+ operation_context->set_update_observers(update_observers_);
+ operation_context->set_change_observers(change_observers_);
operation_context->set_root_path(base_path_);
return new LocalFileSystemOperation(context, operation_context.Pass());
}
@@ -164,7 +165,7 @@ TestMountPointProvider::CreateFileStreamWriter(
int64 offset,
FileSystemContext* context) const {
return scoped_ptr<fileapi::FileStreamWriter>(
- new SandboxFileStreamWriter(context, url, offset, observers_));
+ new SandboxFileStreamWriter(context, url, offset, update_observers_));
}
FileSystemQuotaUtil* TestMountPointProvider::GetQuotaUtil() {
@@ -184,7 +185,14 @@ void TestMountPointProvider::DeleteFileSystem(
const UpdateObserverList* TestMountPointProvider::GetUpdateObservers(
FileSystemType type) const {
- return &observers_;
+ return &update_observers_;
+}
+
+void TestMountPointProvider::AddFileChangeObserver(
+ FileChangeObserver* observer) {
+ ChangeObserverList::Source source = change_observers_.source();
+ source.AddObserver(observer, task_runner_.get());
+ change_observers_ = ChangeObserverList(source);
}
} // namespace fileapi
diff --git a/webkit/browser/fileapi/test_mount_point_provider.h b/webkit/browser/fileapi/test_mount_point_provider.h
index d4f6628..5f24a08 100644
--- a/webkit/browser/fileapi/test_mount_point_provider.h
+++ b/webkit/browser/fileapi/test_mount_point_provider.h
@@ -74,6 +74,7 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE TestMountPointProvider
scoped_ptr<CopyOrMoveFileValidatorFactory> factory);
const UpdateObserverList* GetUpdateObservers(FileSystemType type) const;
+ void AddFileChangeObserver(FileChangeObserver* observer);
// For CopyOrMoveFileValidatorFactory testing. Once it's set to true
// GetCopyOrMoveFileValidatorFactory will start returning security
@@ -89,7 +90,8 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE TestMountPointProvider
scoped_refptr<base::SequencedTaskRunner> task_runner_;
scoped_ptr<AsyncFileUtilAdapter> local_file_util_;
scoped_ptr<QuotaUtil> quota_util_;
- UpdateObserverList observers_;
+ UpdateObserverList update_observers_;
+ ChangeObserverList change_observers_;
bool require_copy_or_move_validator_;
scoped_ptr<CopyOrMoveFileValidatorFactory>
diff --git a/webkit/support/simple_file_system.cc b/webkit/support/simple_file_system.cc
index 67309f1..b2aa728 100644
--- a/webkit/support/simple_file_system.cc
+++ b/webkit/support/simple_file_system.cc
@@ -23,6 +23,7 @@
#include "webkit/browser/blob/blob_storage_controller.h"
#include "webkit/browser/fileapi/file_permission_policy.h"
#include "webkit/browser/fileapi/file_system_mount_point_provider.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/mock_file_system_context.h"
#include "webkit/common/fileapi/directory_entry.h"
@@ -133,8 +134,8 @@ void SimpleFileSystem::move(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(src_url)->Move(src_url, dest_url,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Move(
+ src_url, dest_url, FinishHandler(callbacks));
}
void SimpleFileSystem::copy(
@@ -147,8 +148,8 @@ void SimpleFileSystem::copy(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(src_url)->Copy(src_url, dest_url,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Copy(
+ src_url, dest_url, FinishHandler(callbacks));
}
void SimpleFileSystem::remove(
@@ -158,8 +159,8 @@ void SimpleFileSystem::remove(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->Remove(url, false /* recursive */,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Remove(
+ url, false /* recursive */, FinishHandler(callbacks));
}
void SimpleFileSystem::removeRecursively(
@@ -169,8 +170,8 @@ void SimpleFileSystem::removeRecursively(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->Remove(url, true /* recursive */,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Remove(
+ url, true /* recursive */, FinishHandler(callbacks));
}
void SimpleFileSystem::readMetadata(
@@ -180,7 +181,8 @@ void SimpleFileSystem::readMetadata(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->GetMetadata(url, GetMetadataHandler(callbacks));
+ file_system_context_->operation_runner()->GetMetadata(
+ url, GetMetadataHandler(callbacks));
}
void SimpleFileSystem::createFile(
@@ -190,7 +192,8 @@ void SimpleFileSystem::createFile(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->CreateFile(url, exclusive, FinishHandler(callbacks));
+ file_system_context_->operation_runner()->CreateFile(
+ url, exclusive, FinishHandler(callbacks));
}
void SimpleFileSystem::createDirectory(
@@ -200,8 +203,8 @@ void SimpleFileSystem::createDirectory(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->CreateDirectory(url, exclusive, false,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->CreateDirectory(
+ url, exclusive, false, FinishHandler(callbacks));
}
void SimpleFileSystem::fileExists(
@@ -211,7 +214,8 @@ void SimpleFileSystem::fileExists(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->FileExists(url, FinishHandler(callbacks));
+ file_system_context_->operation_runner()->FileExists(
+ url, FinishHandler(callbacks));
}
void SimpleFileSystem::directoryExists(
@@ -221,7 +225,8 @@ void SimpleFileSystem::directoryExists(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->DirectoryExists(url, FinishHandler(callbacks));
+ file_system_context_->operation_runner()->DirectoryExists(
+ url, FinishHandler(callbacks));
}
void SimpleFileSystem::readDirectory(
@@ -231,7 +236,8 @@ void SimpleFileSystem::readDirectory(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->ReadDirectory(url, ReadDirectoryHandler(callbacks));
+ file_system_context_->operation_runner()->ReadDirectory(
+ url, ReadDirectoryHandler(callbacks));
}
WebFileWriter* SimpleFileSystem::createFileWriter(
@@ -247,7 +253,7 @@ void SimpleFileSystem::createSnapshotFileAndReadMetadata(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->CreateSnapshotFile(
+ file_system_context_->operation_runner()->CreateSnapshotFile(
url, SnapshotFileHandler(callbacks));
}
@@ -277,11 +283,6 @@ bool SimpleFileSystem::HasFilePermission(
!= fileapi::FILE_PERMISSION_ALWAYS_DENY);
}
-FileSystemOperation* SimpleFileSystem::GetNewOperation(
- const fileapi::FileSystemURL& url) {
- return file_system_context_->CreateFileSystemOperation(url, NULL);
-}
-
FileSystemOperation::StatusCallback
SimpleFileSystem::FinishHandler(WebFileSystemCallbacks* callbacks) {
return base::Bind(&SimpleFileSystem::DidFinish,
diff --git a/webkit/support/simple_file_system.h b/webkit/support/simple_file_system.h
index 6430aa0..9d9f315 100644
--- a/webkit/support/simple_file_system.h
+++ b/webkit/support/simple_file_system.h
@@ -99,8 +99,6 @@ class SimpleFileSystem
private:
// Helpers.
bool HasFilePermission(const fileapi::FileSystemURL& url, int permissions);
- fileapi::FileSystemOperation* GetNewOperation(
- const fileapi::FileSystemURL& url);
// Callback Handlers
fileapi::FileSystemOperation::StatusCallback FinishHandler(
diff --git a/webkit/support/simple_file_writer.cc b/webkit/support/simple_file_writer.cc
index b372fd1..98de70b 100644
--- a/webkit/support/simple_file_writer.cc
+++ b/webkit/support/simple_file_writer.cc
@@ -10,7 +10,7 @@
#include "base/message_loop_proxy.h"
#include "net/url_request/url_request_context.h"
#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/common/fileapi/file_system_types.h"
#include "webkit/glue/webkit_glue.h"
@@ -18,7 +18,7 @@
using fileapi::FileSystemURL;
using fileapi::FileSystemContext;
-using fileapi::FileSystemOperation;
+using fileapi::FileSystemOperationRunner;
using fileapi::WebFileWriterBase;
using WebKit::WebFileWriterClient;
using WebKit::WebString;
@@ -35,7 +35,7 @@ class SimpleFileWriter::IOThreadProxy
IOThreadProxy(const base::WeakPtr<SimpleFileWriter>& simple_writer,
FileSystemContext* file_system_context)
: simple_writer_(simple_writer),
- operation_(NULL),
+ operation_id_(FileSystemOperationRunner::kErrorOperationID),
file_system_context_(file_system_context) {
// The IO thread needs to be running for this class to work.
SimpleResourceLoaderBridge::EnsureIOThread();
@@ -52,10 +52,9 @@ class SimpleFileWriter::IOThreadProxy
}
if (FailIfNotWritable(url))
return;
- DCHECK(!operation_);
- operation_ = GetNewOperation(url);
- operation_->Truncate(url, offset,
- base::Bind(&IOThreadProxy::DidFinish, this));
+ DCHECK_EQ(FileSystemOperationRunner::kErrorOperationID, operation_id_);
+ operation_id_ = file_system_context_->operation_runner()->Truncate(
+ url, offset, base::Bind(&IOThreadProxy::DidFinish, this));
}
void Write(const FileSystemURL& url, const GURL& blob_url, int64 offset) {
@@ -68,10 +67,10 @@ class SimpleFileWriter::IOThreadProxy
if (FailIfNotWritable(url))
return;
DCHECK(request_context_);
- DCHECK(!operation_);
- operation_ = GetNewOperation(url);
- operation_->Write(request_context_, url, blob_url, offset,
- base::Bind(&IOThreadProxy::DidWrite, this));
+ DCHECK_EQ(FileSystemOperationRunner::kErrorOperationID, operation_id_);
+ operation_id_ = file_system_context_->operation_runner()->Write(
+ request_context_, url, blob_url, offset,
+ base::Bind(&IOThreadProxy::DidWrite, this));
}
void Cancel() {
@@ -81,21 +80,18 @@ class SimpleFileWriter::IOThreadProxy
base::Bind(&IOThreadProxy::Cancel, this));
return;
}
- if (!operation_) {
+ if (operation_id_ == FileSystemOperationRunner::kErrorOperationID) {
DidFailOnMainThread(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
return;
}
- operation_->Cancel(base::Bind(&IOThreadProxy::DidFinish, this));
+ file_system_context_->operation_runner()->Cancel(
+ operation_id_, base::Bind(&IOThreadProxy::DidFinish, this));
}
private:
friend class base::RefCountedThreadSafe<IOThreadProxy>;
virtual ~IOThreadProxy() {}
- FileSystemOperation* GetNewOperation( const FileSystemURL& url) {
- return file_system_context_->CreateFileSystemOperation(url, NULL);
- }
-
// Returns true if it is not writable.
bool FailIfNotWritable(const FileSystemURL& url) {
if (url.type() == fileapi::kFileSystemTypeDragged) {
@@ -142,7 +138,7 @@ class SimpleFileWriter::IOThreadProxy
void ClearOperation() {
DCHECK(io_thread_->BelongsToCurrentThread());
- operation_ = NULL;
+ operation_id_ = FileSystemOperationRunner::kErrorOperationID;
}
void DidFinish(base::PlatformFileError result) {
@@ -171,7 +167,7 @@ class SimpleFileWriter::IOThreadProxy
base::WeakPtr<SimpleFileWriter> simple_writer_;
// Only used on the io thread.
- FileSystemOperation* operation_;
+ FileSystemOperationRunner::OperationID operation_id_;
scoped_refptr<FileSystemContext> file_system_context_;
};