summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 14:45:35 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 14:45:35 +0000
commit20b570674a567f61c5aabc498a992cbcf9e9b408 (patch)
tree14b269eba78f74d66f9d63b2b9513c7d4716fac1 /webkit
parent444ea9d2af11dbb9bdfefaa443929c85b998a5da (diff)
downloadchromium_src-20b570674a567f61c5aabc498a992cbcf9e9b408.zip
chromium_src-20b570674a567f61c5aabc498a992cbcf9e9b408.tar.gz
chromium_src-20b570674a567f61c5aabc498a992cbcf9e9b408.tar.bz2
Make CannedSyncableFileSystem testable in multi-thread environment
BUG=154234 TEST=SyncableContextTest.*,SyncableFileSystemTest.* Review URL: https://chromiumcodereview.appspot.com/11066115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/fileapi/syncable/canned_syncable_file_system.cc186
-rw-r--r--webkit/fileapi/syncable/canned_syncable_file_system.h42
-rw-r--r--webkit/fileapi/syncable/local_file_change_tracker_unittest.cc37
-rw-r--r--webkit/fileapi/syncable/local_file_sync_context.h1
-rw-r--r--webkit/fileapi/syncable/local_file_sync_context_unittest.cc18
-rw-r--r--webkit/fileapi/syncable/syncable_file_system_unittest.cc28
6 files changed, 195 insertions, 117 deletions
diff --git a/webkit/fileapi/syncable/canned_syncable_file_system.cc b/webkit/fileapi/syncable/canned_syncable_file_system.cc
index bb832df..d7f4f26 100644
--- a/webkit/fileapi/syncable/canned_syncable_file_system.cc
+++ b/webkit/fileapi/syncable/canned_syncable_file_system.cc
@@ -7,6 +7,8 @@
#include "base/bind.h"
#include "base/file_util.h"
#include "base/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
+#include "base/task_runner_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation_context.h"
@@ -24,15 +26,47 @@ using quota::QuotaManager;
namespace fileapi {
+namespace {
+
+typedef CannedSyncableFileSystem::StatusCallback StatusCallback;
+
+void Quit() { MessageLoop::current()->Quit(); }
+
+void AssignAndQuit(base::TaskRunner* original_task_runner,
+ PlatformFileError* result_out,
+ PlatformFileError result) {
+ DCHECK(result_out);
+ *result_out = result;
+ original_task_runner->PostTask(FROM_HERE, base::Bind(&Quit));
+}
+
+PlatformFileError RunOnThread(
+ base::SingleThreadTaskRunner* task_runner,
+ const tracked_objects::Location& location,
+ const base::Callback<void(const StatusCallback& callback)>& task) {
+ scoped_ptr<PlatformFileError> result(
+ new PlatformFileError(base::PLATFORM_FILE_ERROR_FAILED));
+ task_runner->PostTask(
+ location,
+ base::Bind(task, base::Bind(&AssignAndQuit,
+ base::MessageLoopProxy::current(),
+ result.get())));
+ MessageLoop::current()->Run();
+ return *result;
+}
+
+} // namespace
+
CannedSyncableFileSystem::CannedSyncableFileSystem(
- const GURL& origin, const std::string& service)
+ const GURL& origin, const std::string& service,
+ base::SingleThreadTaskRunner* io_task_runner)
: service_name_(service),
test_helper_(origin, kFileSystemTypeSyncable),
result_(base::PLATFORM_FILE_OK),
sync_status_(SYNC_STATUS_OK),
+ io_task_runner_(io_task_runner),
is_filesystem_set_up_(false),
- is_filesystem_opened_(false),
- weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ is_filesystem_opened_(false) {
}
CannedSyncableFileSystem::~CannedSyncableFileSystem() {}
@@ -47,7 +81,7 @@ void CannedSyncableFileSystem::SetUp() {
quota_manager_ = new QuotaManager(
false /* is_incognito */,
data_dir_.path(),
- base::MessageLoopProxy::current(),
+ io_task_runner_,
base::MessageLoopProxy::current(),
storage_policy);
@@ -81,7 +115,7 @@ PlatformFileError CannedSyncableFileSystem::OpenFileSystem() {
test_helper_.origin(), test_helper_.type(),
true /* create */,
base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem,
- weak_factory_.GetWeakPtr()));
+ base::Unretained(this)));
MessageLoop::current()->RunAllPending();
return result_;
}
@@ -90,6 +124,7 @@ SyncStatusCode CannedSyncableFileSystem::MaybeInitializeFileSystemContext(
LocalFileSyncContext* sync_context) {
DCHECK(sync_context);
sync_status_ = SYNC_STATUS_UNKNOWN;
+ EXPECT_EQ(io_task_runner_.get(), sync_context->io_task_runner_.get());
sync_context->MaybeInitializeFileSystemContext(
test_helper_.origin(),
file_system_context_,
@@ -101,82 +136,109 @@ SyncStatusCode CannedSyncableFileSystem::MaybeInitializeFileSystemContext(
PlatformFileError CannedSyncableFileSystem::CreateDirectory(
const FileSystemURL& url) {
- EXPECT_TRUE(is_filesystem_opened_);
- result_ = base::PLATFORM_FILE_ERROR_FAILED;
- test_helper_.NewOperation()->CreateDirectory(
- url, false /* exclusive */, false /* recursive */,
- base::Bind(&CannedSyncableFileSystem::StatusCallback,
- weak_factory_.GetWeakPtr()));
- MessageLoop::current()->RunAllPending();
- return result_;
+ return RunOnThread(io_task_runner_,
+ FROM_HERE,
+ base::Bind(&CannedSyncableFileSystem::DoCreateDirectory,
+ base::Unretained(this), url));
}
PlatformFileError CannedSyncableFileSystem::CreateFile(
const FileSystemURL& url) {
- EXPECT_TRUE(is_filesystem_opened_);
- result_ = base::PLATFORM_FILE_ERROR_FAILED;
- test_helper_.NewOperation()->CreateFile(
- url, false /* exclusive */,
- base::Bind(&CannedSyncableFileSystem::StatusCallback,
- weak_factory_.GetWeakPtr()));
- MessageLoop::current()->RunAllPending();
- return result_;
+ return RunOnThread(io_task_runner_,
+ FROM_HERE,
+ base::Bind(&CannedSyncableFileSystem::DoCreateFile,
+ base::Unretained(this), url));
}
PlatformFileError CannedSyncableFileSystem::Copy(
const FileSystemURL& src_url, const FileSystemURL& dest_url) {
- result_ = base::PLATFORM_FILE_ERROR_FAILED;
- test_helper_.NewOperation()->Copy(
- src_url, dest_url,
- base::Bind(&CannedSyncableFileSystem::StatusCallback,
- weak_factory_.GetWeakPtr()));
- MessageLoop::current()->RunAllPending();
- return result_;
+ return RunOnThread(io_task_runner_,
+ FROM_HERE,
+ base::Bind(&CannedSyncableFileSystem::DoCopy,
+ base::Unretained(this), src_url, dest_url));
}
PlatformFileError CannedSyncableFileSystem::Move(
const FileSystemURL& src_url, const FileSystemURL& dest_url) {
- result_ = base::PLATFORM_FILE_ERROR_FAILED;
- test_helper_.NewOperation()->Move(
- src_url, dest_url,
- base::Bind(&CannedSyncableFileSystem::StatusCallback,
- weak_factory_.GetWeakPtr()));
- MessageLoop::current()->RunAllPending();
- return result_;
+ return RunOnThread(io_task_runner_,
+ FROM_HERE,
+ base::Bind(&CannedSyncableFileSystem::DoMove,
+ base::Unretained(this), src_url, dest_url));
}
PlatformFileError CannedSyncableFileSystem::TruncateFile(
const FileSystemURL& url, int64 size) {
- EXPECT_TRUE(is_filesystem_opened_);
- result_ = base::PLATFORM_FILE_ERROR_FAILED;
- test_helper_.NewOperation()->Truncate(
- url, size,
- base::Bind(&CannedSyncableFileSystem::StatusCallback,
- weak_factory_.GetWeakPtr()));
- MessageLoop::current()->RunAllPending();
- return result_;
+ return RunOnThread(io_task_runner_,
+ FROM_HERE,
+ base::Bind(&CannedSyncableFileSystem::DoTruncateFile,
+ base::Unretained(this), url, size));
}
PlatformFileError CannedSyncableFileSystem::Remove(
const FileSystemURL& url, bool recursive) {
- EXPECT_TRUE(is_filesystem_opened_);
- result_ = base::PLATFORM_FILE_ERROR_FAILED;
- test_helper_.NewOperation()->Remove(
- url, recursive,
- base::Bind(&CannedSyncableFileSystem::StatusCallback,
- weak_factory_.GetWeakPtr()));
- MessageLoop::current()->RunAllPending();
- return result_;
+ return RunOnThread(io_task_runner_,
+ FROM_HERE,
+ base::Bind(&CannedSyncableFileSystem::DoRemove,
+ base::Unretained(this), url, recursive));
}
PlatformFileError CannedSyncableFileSystem::DeleteFileSystem() {
EXPECT_TRUE(is_filesystem_set_up_);
- file_system_context_->DeleteFileSystem(
- test_helper_.origin(), test_helper_.type(),
- base::Bind(&CannedSyncableFileSystem::StatusCallback,
- weak_factory_.GetWeakPtr()));
- MessageLoop::current()->RunAllPending();
- return result_;
+ return RunOnThread(io_task_runner_,
+ FROM_HERE,
+ base::Bind(&FileSystemContext::DeleteFileSystem,
+ file_system_context_,
+ test_helper_.origin(),
+ test_helper_.type()));
+}
+
+FileSystemOperation* CannedSyncableFileSystem::NewOperation() {
+ return file_system_context_->CreateFileSystemOperation(URL(""), NULL);
+}
+
+void CannedSyncableFileSystem::DoCreateDirectory(
+ const FileSystemURL& url,
+ const StatusCallback& callback) {
+ EXPECT_TRUE(is_filesystem_opened_);
+ NewOperation()->CreateDirectory(
+ url, false /* exclusive */, false /* recursive */, callback);
+}
+
+void CannedSyncableFileSystem::DoCreateFile(
+ const FileSystemURL& url,
+ const StatusCallback& callback) {
+ EXPECT_TRUE(is_filesystem_opened_);
+ NewOperation()->CreateFile(url, false /* exclusive */, callback);
+}
+
+void CannedSyncableFileSystem::DoCopy(
+ const FileSystemURL& src_url,
+ const FileSystemURL& dest_url,
+ const StatusCallback& callback) {
+ EXPECT_TRUE(is_filesystem_opened_);
+ NewOperation()->Copy(src_url, dest_url, callback);
+}
+
+void CannedSyncableFileSystem::DoMove(
+ const FileSystemURL& src_url,
+ const FileSystemURL& dest_url,
+ const StatusCallback& callback) {
+ EXPECT_TRUE(is_filesystem_opened_);
+ NewOperation()->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);
+}
+
+void CannedSyncableFileSystem::DoRemove(
+ const FileSystemURL& url, bool recursive,
+ const StatusCallback& callback) {
+ EXPECT_TRUE(is_filesystem_opened_);
+ NewOperation()->Remove(url, recursive, callback);
}
void CannedSyncableFileSystem::DidOpenFileSystem(
@@ -192,14 +254,4 @@ void CannedSyncableFileSystem::DidInitializeFileSystemContext(
MessageLoop::current()->Quit();
}
-void CannedSyncableFileSystem::StatusCallback(PlatformFileError result) {
- result_ = result;
-}
-
-FileSystemOperationContext* CannedSyncableFileSystem::NewOperationContext() {
- FileSystemOperationContext* context = test_helper_.NewOperationContext();
- context->set_allowed_bytes_growth(kint64max);
- return context;
-}
-
} // namespace fileapi
diff --git a/webkit/fileapi/syncable/canned_syncable_file_system.h b/webkit/fileapi/syncable/canned_syncable_file_system.h
index 0106567..359d53c 100644
--- a/webkit/fileapi/syncable/canned_syncable_file_system.h
+++ b/webkit/fileapi/syncable/canned_syncable_file_system.h
@@ -7,7 +7,7 @@
#include <string>
-#include "base/basictypes.h"
+#include "base/callback_forward.h"
#include "base/message_loop.h"
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
@@ -16,8 +16,9 @@
#include "webkit/fileapi/syncable/sync_status_code.h"
namespace base {
-class Thread;
class MessageLoopProxy;
+class SingleThreadTaskRunner;
+class Thread;
}
namespace quota {
@@ -27,6 +28,7 @@ class QuotaManager;
namespace fileapi {
class FileSystemContext;
+class FileSystemOperation;
class LocalFileSyncContext;
// A canned syncable filesystem for testing.
@@ -34,7 +36,11 @@ class LocalFileSyncContext;
// (as we do so for each isolated application).
class CannedSyncableFileSystem {
public:
- CannedSyncableFileSystem(const GURL& origin, const std::string& service);
+ typedef base::Callback<void(base::PlatformFileError)> StatusCallback;
+
+ CannedSyncableFileSystem(const GURL& origin,
+ const std::string& service,
+ base::SingleThreadTaskRunner* io_task_runner);
~CannedSyncableFileSystem();
// SetUp must be called before using this instance.
@@ -67,7 +73,7 @@ class CannedSyncableFileSystem {
// Helper routines to perform file system operations.
// OpenFileSystem() must have been called before calling any of them.
- // (They run on the current thread and returns synchronously).
+ // They run on io_task_runner.
base::PlatformFileError CreateDirectory(const FileSystemURL& url);
base::PlatformFileError CreateFile(const FileSystemURL& url);
base::PlatformFileError Copy(const FileSystemURL& src_url,
@@ -80,15 +86,33 @@ class CannedSyncableFileSystem {
// Pruges the file system local storage.
base::PlatformFileError DeleteFileSystem();
+ // Returns new FileSystemOperation.
+ FileSystemOperation* NewOperation();
+
private:
+ // Operation methods body.
+ void DoCreateDirectory(const FileSystemURL& url,
+ const StatusCallback& callback);
+ void DoCreateFile(const FileSystemURL& url,
+ const StatusCallback& callback);
+ void DoCopy(const FileSystemURL& src_url,
+ const FileSystemURL& dest_url,
+ const StatusCallback& callback);
+ void DoMove(const FileSystemURL& src_url,
+ const FileSystemURL& dest_url,
+ const StatusCallback& callback);
+ void DoTruncateFile(const FileSystemURL& url,
+ int64 size,
+ const StatusCallback& callback);
+ void DoRemove(const FileSystemURL& url,
+ bool recursive,
+ const StatusCallback& callback);
+
// Callbacks.
void DidOpenFileSystem(base::PlatformFileError result,
const std::string& name,
const GURL& root);
void DidInitializeFileSystemContext(SyncStatusCode status);
- void StatusCallback(base::PlatformFileError result);
-
- FileSystemOperationContext* NewOperationContext();
ScopedTempDir data_dir_;
const std::string service_name_;
@@ -100,12 +124,12 @@ class CannedSyncableFileSystem {
base::PlatformFileError result_;
SyncStatusCode sync_status_;
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+
// Boolean flags mainly for helping debug.
bool is_filesystem_set_up_;
bool is_filesystem_opened_;
- base::WeakPtrFactory<CannedSyncableFileSystem> weak_factory_;
-
DISALLOW_COPY_AND_ASSIGN(CannedSyncableFileSystem);
};
diff --git a/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc b/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc
index 51d98fd..64fbed6 100644
--- a/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc
+++ b/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc
@@ -13,22 +13,33 @@
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_task_runners.h"
#include "webkit/fileapi/syncable/canned_syncable_file_system.h"
-#include "webkit/fileapi/syncable/local_file_change_tracker.h"
+#include "webkit/fileapi/syncable/local_file_sync_context.h"
#include "webkit/fileapi/syncable/sync_status_code.h"
#include "webkit/fileapi/syncable/syncable_file_system_util.h"
+#include "webkit/quota/quota_manager.h"
namespace fileapi {
class LocalFileChangeTrackerTest : public testing::Test {
public:
LocalFileChangeTrackerTest()
- : file_system_(GURL("http://example.com"), "test") {}
+ : file_system_(GURL("http://example.com"), "test",
+ base::MessageLoopProxy::current()) {}
virtual void SetUp() OVERRIDE {
file_system_.SetUp();
+
+ sync_context_ = new LocalFileSyncContext(base::MessageLoopProxy::current(),
+ base::MessageLoopProxy::current());
+ ASSERT_EQ(SYNC_STATUS_OK,
+ file_system_.MaybeInitializeFileSystemContext(sync_context_));
}
virtual void TearDown() OVERRIDE {
+ if (sync_context_)
+ sync_context_->ShutdownOnUIThread();
+ sync_context_ = NULL;
+
message_loop_.RunAllPending();
file_system_.TearDown();
// Make sure we don't leave the external filesystem.
@@ -38,15 +49,6 @@ class LocalFileChangeTrackerTest : public testing::Test {
}
protected:
- void RegisterChangeTracker() {
- scoped_ptr<LocalFileChangeTracker> tracker(
- new LocalFileChangeTracker(
- file_system_context()->partition_path(),
- file_system_context()->task_runners()->file_task_runner()));
- ASSERT_EQ(tracker->Initialize(file_system_context()), SYNC_STATUS_OK);
- file_system_context()->SetLocalFileChangeTracker(tracker.Pass());
- }
-
FileSystemURL URL(const std::string& path) {
return file_system_.URL(path);
}
@@ -86,14 +88,12 @@ class LocalFileChangeTrackerTest : public testing::Test {
MessageLoop message_loop_;
CannedSyncableFileSystem file_system_;
+ scoped_refptr<LocalFileSyncContext> sync_context_;
DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTrackerTest);
};
TEST_F(LocalFileChangeTrackerTest, GetChanges) {
- // Register a new change tracker (before opening a file system).
- RegisterChangeTracker();
-
EXPECT_EQ(base::PLATFORM_FILE_OK,
file_system_.OpenFileSystem());
@@ -148,9 +148,6 @@ TEST_F(LocalFileChangeTrackerTest, GetChanges) {
}
TEST_F(LocalFileChangeTrackerTest, RestoreCreateAndModifyChanges) {
- // Register a new change tracker (before opening a file system).
- RegisterChangeTracker();
-
EXPECT_EQ(base::PLATFORM_FILE_OK,
file_system_.OpenFileSystem());
@@ -238,9 +235,6 @@ TEST_F(LocalFileChangeTrackerTest, RestoreCreateAndModifyChanges) {
}
TEST_F(LocalFileChangeTrackerTest, RestoreRemoveChanges) {
- // Register a new change tracker (before opening a file system).
- RegisterChangeTracker();
-
EXPECT_EQ(base::PLATFORM_FILE_OK,
file_system_.OpenFileSystem());
@@ -329,9 +323,6 @@ TEST_F(LocalFileChangeTrackerTest, RestoreRemoveChanges) {
}
TEST_F(LocalFileChangeTrackerTest, RestoreMoveChanges) {
- // Register a new change tracker (before opening a file system).
- RegisterChangeTracker();
-
EXPECT_EQ(base::PLATFORM_FILE_OK,
file_system_.OpenFileSystem());
diff --git a/webkit/fileapi/syncable/local_file_sync_context.h b/webkit/fileapi/syncable/local_file_sync_context.h
index 2f6d25c..cbb8c0a 100644
--- a/webkit/fileapi/syncable/local_file_sync_context.h
+++ b/webkit/fileapi/syncable/local_file_sync_context.h
@@ -57,6 +57,7 @@ class FILEAPI_EXPORT LocalFileSyncContext
private:
typedef std::deque<StatusCallback> StatusCallbackQueue;
friend class base::RefCountedThreadSafe<LocalFileSyncContext>;
+ friend class CannedSyncableFileSystem;
~LocalFileSyncContext();
diff --git a/webkit/fileapi/syncable/local_file_sync_context_unittest.cc b/webkit/fileapi/syncable/local_file_sync_context_unittest.cc
index ab74b2b..48aca29 100644
--- a/webkit/fileapi/syncable/local_file_sync_context_unittest.cc
+++ b/webkit/fileapi/syncable/local_file_sync_context_unittest.cc
@@ -4,6 +4,8 @@
#include "webkit/fileapi/syncable/local_file_sync_context.h"
+#include <vector>
+
#include "base/bind.h"
#include "base/file_path.h"
#include "base/message_loop.h"
@@ -17,13 +19,17 @@
#include "webkit/fileapi/syncable/sync_status_code.h"
#include "webkit/fileapi/syncable/syncable_file_system_util.h"
+// This tests SyncableContext behavior in multi-thread /
+// multi-file-system-context environment.
+// Basic combined tests (single-thread / single-file-system-context)
+// that involve SyncableContext are also in syncable_file_system_unittests.cc.
+
namespace fileapi {
namespace {
const char kOrigin1[] = "http://example.com";
const char kOrigin2[] = "http://chromium.org";
const char kServiceName[] = "test";
-const FileSystemType kSyncableType = kFileSystemTypeSyncable;
}
class LocalFileSyncContextTest : public testing::Test {
@@ -71,7 +77,8 @@ TEST_F(LocalFileSyncContextTest, ConstructAndDestruct) {
}
TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) {
- CannedSyncableFileSystem file_system(GURL(kOrigin1), kServiceName);
+ CannedSyncableFileSystem file_system(GURL(kOrigin1), kServiceName,
+ io_task_runner_);
file_system.SetUp();
sync_context_ = new LocalFileSyncContext(ui_task_runner_, io_task_runner_);
@@ -111,8 +118,10 @@ TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) {
}
TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) {
- CannedSyncableFileSystem file_system1(GURL(kOrigin1), kServiceName);
- CannedSyncableFileSystem file_system2(GURL(kOrigin2), kServiceName);
+ CannedSyncableFileSystem file_system1(GURL(kOrigin1), kServiceName,
+ io_task_runner_);
+ CannedSyncableFileSystem file_system2(GURL(kOrigin2), kServiceName,
+ io_task_runner_);
file_system1.SetUp();
file_system2.SetUp();
@@ -160,6 +169,7 @@ TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) {
EXPECT_EQ(kURL2, urls[0]);
sync_context_->ShutdownOnUIThread();
+ sync_context_ = NULL;
file_system1.TearDown();
file_system2.TearDown();
diff --git a/webkit/fileapi/syncable/syncable_file_system_unittest.cc b/webkit/fileapi/syncable/syncable_file_system_unittest.cc
index a739277..487c65e 100644
--- a/webkit/fileapi/syncable/syncable_file_system_unittest.cc
+++ b/webkit/fileapi/syncable/syncable_file_system_unittest.cc
@@ -9,8 +9,9 @@
#include "webkit/fileapi/isolated_context.h"
#include "webkit/fileapi/local_file_system_operation.h"
#include "webkit/fileapi/syncable/canned_syncable_file_system.h"
-#include "webkit/fileapi/syncable/syncable_file_system_util.h"
#include "webkit/fileapi/syncable/local_file_change_tracker.h"
+#include "webkit/fileapi/syncable/local_file_sync_context.h"
+#include "webkit/fileapi/syncable/syncable_file_system_util.h"
#include "webkit/quota/quota_manager.h"
#include "webkit/quota/quota_types.h"
@@ -23,7 +24,8 @@ namespace fileapi {
class SyncableFileSystemTest : public testing::Test {
public:
SyncableFileSystemTest()
- : file_system_(GURL("http://example.com/"), "test"),
+ : file_system_(GURL("http://example.com/"), "test",
+ base::MessageLoopProxy::current()),
quota_status_(quota::kQuotaStatusUnknown),
usage_(-1),
quota_(-1),
@@ -31,9 +33,18 @@ class SyncableFileSystemTest : public testing::Test {
void SetUp() {
file_system_.SetUp();
+
+ sync_context_ = new LocalFileSyncContext(base::MessageLoopProxy::current(),
+ base::MessageLoopProxy::current());
+ ASSERT_EQ(SYNC_STATUS_OK,
+ file_system_.MaybeInitializeFileSystemContext(sync_context_));
}
void TearDown() {
+ if (sync_context_)
+ sync_context_->ShutdownOnUIThread();
+ sync_context_ = NULL;
+
file_system_.TearDown();
// Make sure we don't leave the external filesystem.
@@ -64,15 +75,6 @@ class SyncableFileSystemTest : public testing::Test {
*quota = quota_;
}
- void RegisterChangeTracker() {
- scoped_ptr<LocalFileChangeTracker> tracker(
- new LocalFileChangeTracker(
- file_system_context()->partition_path(),
- file_system_context()->task_runners()->file_task_runner()));
- ASSERT_EQ(tracker->Initialize(file_system_context()), SYNC_STATUS_OK);
- file_system_context()->SetLocalFileChangeTracker(tracker.Pass());
- }
-
void VerifyAndClearChange(const FileSystemURL& url,
const FileChange& expected_change) {
SCOPED_TRACE(testing::Message() << url.path().value() <<
@@ -105,6 +107,7 @@ class SyncableFileSystemTest : public testing::Test {
MessageLoop message_loop_;
CannedSyncableFileSystem file_system_;
+ scoped_refptr<LocalFileSyncContext> sync_context_;
QuotaStatusCode quota_status_;
int64 usage_;
@@ -174,9 +177,6 @@ TEST_F(SyncableFileSystemTest, SyncableLocalSandboxCombined) {
// Combined testing with LocalFileChangeTracker.
TEST_F(SyncableFileSystemTest, ChangeTrackerSimple) {
- // Register a new change tracker (before opening a file system).
- RegisterChangeTracker();
-
EXPECT_EQ(base::PLATFORM_FILE_OK,
file_system_.OpenFileSystem());