summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 19:52:12 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 19:52:12 +0000
commite26908e679e2548b3c727692c654d02ddf95def5 (patch)
tree0b4594ceb93a6959e408237ac8281434b61a4ab7 /sync
parent0c5e365378b25adf31669934edf3f00e4a5ceb37 (diff)
downloadchromium_src-e26908e679e2548b3c727692c654d02ddf95def5.zip
chromium_src-e26908e679e2548b3c727692c654d02ddf95def5.tar.gz
chromium_src-e26908e679e2548b3c727692c654d02ddf95def5.tar.bz2
sync: inject DirectoryBackingStore to Directory and remove "OpenInMemoryForTest" method from production code.
This resulted in consolidated some SyncManager::TestingMode code to the Init code path from OpenDirectory. This is a step towards removing TestingMode in favor of some SyncManager init factories. See bug 117836 BUG=117836 TEST=sync_unit_tests Review URL: https://chromiumcodereview.appspot.com/10641025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/internal_api/sync_manager.cc34
-rw-r--r--sync/syncable/directory.cc35
-rw-r--r--sync/syncable/directory.h20
-rw-r--r--sync/syncable/syncable_mock.cc5
-rw-r--r--sync/syncable/syncable_unittest.cc113
-rw-r--r--sync/test/engine/test_directory_setter_upper.cc6
6 files changed, 100 insertions, 113 deletions
diff --git a/sync/internal_api/sync_manager.cc b/sync/internal_api/sync_manager.cc
index ca54bb3..53916d9 100644
--- a/sync/internal_api/sync_manager.cc
+++ b/sync/internal_api/sync_manager.cc
@@ -55,6 +55,8 @@
#include "sync/syncable/directory.h"
#include "sync/syncable/directory_change_delegate.h"
#include "sync/syncable/entry.h"
+#include "sync/syncable/in_memory_directory_backing_store.h"
+#include "sync/syncable/on_disk_directory_backing_store.h"
#include "sync/util/cryptographer.h"
#include "sync/util/get_session_name.h"
#include "sync/util/time.h"
@@ -895,10 +897,26 @@ bool SyncManager::SyncInternal::Init(
encryptor_ = encryptor;
unrecoverable_error_handler_ = unrecoverable_error_handler;
report_unrecoverable_error_function_ = report_unrecoverable_error_function;
+
+ syncable::DirectoryBackingStore* backing_store = NULL;
+ if (testing_mode_ == TEST_IN_MEMORY) {
+ // TODO(tim): 117836. Use a factory or delegate to create this and don't
+ // depend on TEST_IN_MEMORY here.
+ backing_store =
+ new syncable::InMemoryDirectoryBackingStore(credentials.email);
+ } else {
+ FilePath absolute_db_path(database_path_);
+ file_util::AbsolutePath(&absolute_db_path);
+ backing_store = new syncable::OnDiskDirectoryBackingStore(
+ credentials.email, absolute_db_path);
+ }
+
+ DCHECK(backing_store);
share_.directory.reset(
new syncable::Directory(encryptor_,
unrecoverable_error_handler_,
- report_unrecoverable_error_function_));
+ report_unrecoverable_error_function_,
+ backing_store));
connection_manager_.reset(new SyncAPIServerConnectionManager(
sync_server_and_path, port, use_ssl, post_factory));
@@ -1124,13 +1142,8 @@ bool SyncManager::SyncInternal::OpenDirectory() {
csync::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr()));
syncable::DirOpenResult open_result = syncable::NOT_INITIALIZED;
- if (testing_mode_ == TEST_IN_MEMORY) {
- open_result = directory()->OpenInMemoryForTest(
- username_for_share(), this, transaction_observer);
- } else {
- open_result = directory()->Open(
- database_path_, username_for_share(), this, transaction_observer);
- }
+ open_result = directory()->Open(username_for_share(), this,
+ transaction_observer);
if (open_result != syncable::OPENED) {
LOG(ERROR) << "Could not open share for:" << username_for_share();
return false;
@@ -1180,9 +1193,8 @@ void SyncManager::SyncInternal::UpdateCredentials(
if (connection_manager()->set_auth_token(credentials.sync_token)) {
sync_notifier_->UpdateCredentials(
credentials.email, credentials.sync_token);
- if (testing_mode_ == NON_TEST && initialized_) {
- if (scheduler())
- scheduler()->OnCredentialsUpdated();
+ if (initialized_ && scheduler()) {
+ scheduler()->OnCredentialsUpdated();
}
}
}
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index 8f23319..92ca8fe 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -180,10 +180,11 @@ Directory::Kernel::~Kernel() {
Directory::Directory(
Encryptor* encryptor,
UnrecoverableErrorHandler* unrecoverable_error_handler,
- ReportUnrecoverableErrorFunction report_unrecoverable_error_function)
+ ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
+ DirectoryBackingStore* store)
: cryptographer_(encryptor),
kernel_(NULL),
- store_(NULL),
+ store_(store),
unrecoverable_error_handler_(unrecoverable_error_handler),
report_unrecoverable_error_function_(
report_unrecoverable_error_function),
@@ -195,33 +196,15 @@ Directory::~Directory() {
}
DirOpenResult Directory::Open(
- const FilePath& file_path, const string& name,
+ const string& name,
DirectoryChangeDelegate* delegate,
const csync::WeakHandle<TransactionObserver>&
transaction_observer) {
TRACE_EVENT0("sync", "SyncDatabaseOpen");
- FilePath db_path(file_path);
- file_util::AbsolutePath(&db_path);
- DirectoryBackingStore* store = new OnDiskDirectoryBackingStore(name, db_path);
-
const DirOpenResult result =
- OpenImpl(store, name, delegate, transaction_observer);
-
- if (OPENED != result)
- Close();
- return result;
-}
-
-DirOpenResult Directory::OpenInMemoryForTest(
- const string& name, DirectoryChangeDelegate* delegate,
- const csync::WeakHandle<TransactionObserver>&
- transaction_observer) {
-
- DirectoryBackingStore* store = new InMemoryDirectoryBackingStore(name);
+ OpenImpl(name, delegate, transaction_observer);
- const DirOpenResult result =
- OpenImpl(store, name, delegate, transaction_observer);
if (OPENED != result)
Close();
return result;
@@ -247,13 +230,10 @@ void Directory::InitializeIndices() {
}
DirOpenResult Directory::OpenImpl(
- DirectoryBackingStore* store,
const string& name,
DirectoryChangeDelegate* delegate,
const csync::WeakHandle<TransactionObserver>&
transaction_observer) {
- DCHECK_EQ(static_cast<DirectoryBackingStore*>(NULL), store_);
- store_ = store;
KernelLoadInfo info;
// Temporary indices before kernel_ initialized in case Load fails. We 0(1)
@@ -273,9 +253,7 @@ DirOpenResult Directory::OpenImpl(
}
void Directory::Close() {
- if (store_)
- delete store_;
- store_ = NULL;
+ store_.reset();
if (kernel_) {
delete kernel_;
kernel_ = NULL;
@@ -547,7 +525,6 @@ void Directory::TakeSnapshotForSaveChanges(SaveChangesSnapshot* snapshot) {
bool Directory::SaveChanges() {
bool success = false;
- DCHECK(store_);
base::AutoLock scoped_lock(kernel_->save_changes_mutex);
diff --git a/sync/syncable/directory.h b/sync/syncable/directory.h
index 73eb81d..95b5893 100644
--- a/sync/syncable/directory.h
+++ b/sync/syncable/directory.h
@@ -200,30 +200,24 @@ class Directory {
// Does not take ownership of |encryptor|.
// |report_unrecoverable_error_function| may be NULL.
+ // Takes ownership of |store|.
Directory(
csync::Encryptor* encryptor,
csync::UnrecoverableErrorHandler* unrecoverable_error_handler,
csync::ReportUnrecoverableErrorFunction
- report_unrecoverable_error_function);
+ report_unrecoverable_error_function,
+ DirectoryBackingStore* store);
virtual ~Directory();
// Does not take ownership of |delegate|, which must not be NULL.
// Starts sending events to |delegate| if the returned result is
// OPENED. Note that events to |delegate| may be sent from *any*
// thread. |transaction_observer| must be initialized.
- DirOpenResult Open(const FilePath& file_path, const std::string& name,
+ DirOpenResult Open(const std::string& name,
DirectoryChangeDelegate* delegate,
const csync::WeakHandle<TransactionObserver>&
transaction_observer);
- // Same as above, but does not create a file to persist the database. This is
- // useful for tests where we were not planning to persist this data and don't
- // want to pay the performance penalty of using a real database.
- DirOpenResult OpenInMemoryForTest(
- const std::string& name, DirectoryChangeDelegate* delegate,
- const csync::WeakHandle<TransactionObserver>&
- transaction_observer);
-
// Stops sending events to the delegate and the transaction
// observer.
void Close();
@@ -233,7 +227,7 @@ class Directory {
// by the server only.
Id NextId();
- bool good() const { return NULL != store_; }
+ bool good() const { return NULL != kernel_; }
// The download progress is an opaque token provided by the sync server
// to indicate the continuation state of the next GetUpdates operation.
@@ -313,7 +307,7 @@ class Directory {
UnlinkReason unlink_reason);
DirOpenResult OpenImpl(
- DirectoryBackingStore* store, const std::string& name,
+ const std::string& name,
DirectoryChangeDelegate* delegate,
const csync::WeakHandle<TransactionObserver>&
transaction_observer);
@@ -603,7 +597,7 @@ class Directory {
Kernel* kernel_;
- DirectoryBackingStore* store_;
+ scoped_ptr<DirectoryBackingStore> store_;
csync::UnrecoverableErrorHandler* const unrecoverable_error_handler_;
const csync::ReportUnrecoverableErrorFunction
diff --git a/sync/syncable/syncable_mock.cc b/sync/syncable/syncable_mock.cc
index 77b4743..cbea9ea 100644
--- a/sync/syncable/syncable_mock.cc
+++ b/sync/syncable/syncable_mock.cc
@@ -5,10 +5,13 @@
#include "sync/syncable/syncable_mock.h"
#include "base/location.h"
+#include "sync/syncable/in_memory_directory_backing_store.h"
+
#include "sync/test/null_transaction_observer.h"
MockDirectory::MockDirectory(csync::UnrecoverableErrorHandler* handler)
- : Directory(&encryptor_, handler, NULL) {
+ : Directory(&encryptor_, handler, NULL,
+ new syncable::InMemoryDirectoryBackingStore("store")) {
InitKernelForTest("myk", &delegate_, syncable::NullTransactionObserver());
}
diff --git a/sync/syncable/syncable_unittest.cc b/sync/syncable/syncable_unittest.cc
index b820902..a2bf660 100644
--- a/sync/syncable/syncable_unittest.cc
+++ b/sync/syncable/syncable_unittest.cc
@@ -21,6 +21,7 @@
#include "sync/protocol/bookmark_specifics.pb.h"
#include "sync/syncable/directory_backing_store.h"
#include "sync/syncable/directory_change_delegate.h"
+#include "sync/syncable/in_memory_directory_backing_store.h"
#include "sync/syncable/metahandle_set.h"
#include "sync/syncable/mutable_entry.h"
#include "sync/syncable/on_disk_directory_backing_store.h"
@@ -86,6 +87,7 @@ void ExpectDataFromBookmarkFaviconEquals(BaseTransaction* trans,
class SyncableGeneralTest : public testing::Test {
public:
+ static const char kIndexTestName[];
virtual void SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
db_path_ = temp_dir_.path().Append(
@@ -103,9 +105,12 @@ class SyncableGeneralTest : public testing::Test {
FilePath db_path_;
};
+const char SyncableGeneralTest::kIndexTestName[] = "IndexTest";
+
TEST_F(SyncableGeneralTest, General) {
- Directory dir(&encryptor_, &handler_, NULL);
- ASSERT_EQ(OPENED, dir.OpenInMemoryForTest(
+ Directory dir(&encryptor_, &handler_, NULL,
+ new InMemoryDirectoryBackingStore("SimpleTest"));
+ ASSERT_EQ(OPENED, dir.Open(
"SimpleTest", &delegate_, NullTransactionObserver()));
int64 root_metahandle;
@@ -204,8 +209,9 @@ TEST_F(SyncableGeneralTest, General) {
}
TEST_F(SyncableGeneralTest, ChildrenOps) {
- Directory dir(&encryptor_, &handler_, NULL);
- ASSERT_EQ(OPENED, dir.OpenInMemoryForTest(
+ Directory dir(&encryptor_, &handler_, NULL,
+ new InMemoryDirectoryBackingStore("SimpleTest"));
+ ASSERT_EQ(OPENED, dir.Open(
"SimpleTest", &delegate_, NullTransactionObserver()));
int64 written_metahandle;
@@ -277,8 +283,9 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) {
// Test creating a new meta entry.
{
- Directory dir(&encryptor_, &handler_, NULL);
- ASSERT_EQ(OPENED, dir.Open(db_path_, "IndexTest", &delegate_,
+ Directory dir(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore(kIndexTestName, db_path_));
+ ASSERT_EQ(OPENED, dir.Open(kIndexTestName, &delegate_,
NullTransactionObserver()));
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
@@ -294,8 +301,9 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) {
// The DB was closed. Now reopen it. This will cause index regeneration.
{
- Directory dir(&encryptor_, &handler_, NULL);
- ASSERT_EQ(OPENED, dir.Open(db_path_, "IndexTest",
+ Directory dir(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore(kIndexTestName, db_path_));
+ ASSERT_EQ(OPENED, dir.Open(kIndexTestName,
&delegate_, NullTransactionObserver()));
ReadTransaction trans(FROM_HERE, &dir);
@@ -315,8 +323,9 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) {
// Test creating a deleted, unsynced, server meta entry.
{
- Directory dir(&encryptor_, &handler_, NULL);
- ASSERT_EQ(OPENED, dir.Open(db_path_, "IndexTest", &delegate_,
+ Directory dir(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore(kIndexTestName, db_path_));
+ ASSERT_EQ(OPENED, dir.Open(kIndexTestName, &delegate_,
NullTransactionObserver()));
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
@@ -334,8 +343,9 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) {
// The DB was closed. Now reopen it. This will cause index regeneration.
// Should still be present and valid in the client tag index.
{
- Directory dir(&encryptor_, &handler_, NULL);
- ASSERT_EQ(OPENED, dir.Open(db_path_, "IndexTest", &delegate_,
+ Directory dir(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore(kIndexTestName, db_path_));
+ ASSERT_EQ(OPENED, dir.Open(kIndexTestName, &delegate_,
NullTransactionObserver()));
ReadTransaction trans(FROM_HERE, &dir);
@@ -349,8 +359,9 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) {
}
TEST_F(SyncableGeneralTest, ToValue) {
- Directory dir(&encryptor_, &handler_, NULL);
- ASSERT_EQ(OPENED, dir.OpenInMemoryForTest(
+ Directory dir(&encryptor_, &handler_, NULL,
+ new InMemoryDirectoryBackingStore("SimpleTest"));
+ ASSERT_EQ(OPENED, dir.Open(
"SimpleTest", &delegate_, NullTransactionObserver()));
const Id id = TestIdFactory::FromNumber(99);
@@ -386,8 +397,6 @@ TEST_F(SyncableGeneralTest, ToValue) {
// A Directory whose backing store always fails SaveChanges by returning false.
class TestUnsaveableDirectory : public Directory {
public:
- TestUnsaveableDirectory() : Directory(&encryptor_, &handler_, NULL) {}
-
class UnsaveableBackingStore : public OnDiskDirectoryBackingStore {
public:
UnsaveableBackingStore(const std::string& dir_name,
@@ -398,19 +407,10 @@ class TestUnsaveableDirectory : public Directory {
}
};
- DirOpenResult OpenUnsaveable(
- const FilePath& file_path, const std::string& name,
- DirectoryChangeDelegate* delegate,
- const csync::WeakHandle<TransactionObserver>&
- transaction_observer) {
- DirectoryBackingStore *store = new UnsaveableBackingStore(name, file_path);
- DirOpenResult result =
- OpenImpl(store, name, delegate, transaction_observer);
- if (OPENED != result)
- Close();
- return result;
- }
-
+ TestUnsaveableDirectory(const std::string& dir_name,
+ const FilePath& backing_filepath)
+ : Directory(&encryptor_, &handler_, NULL,
+ new UnsaveableBackingStore(dir_name, backing_filepath)) {}
private:
FakeEncryptor encryptor_;
TestUnrecoverableErrorHandler handler_;
@@ -424,10 +424,11 @@ class SyncableDirectoryTest : public testing::Test {
static const char kName[];
virtual void SetUp() {
- dir_.reset(new Directory(&encryptor_, &handler_, NULL));
+ dir_.reset(new Directory(&encryptor_, &handler_, NULL,
+ new InMemoryDirectoryBackingStore(kName)));
ASSERT_TRUE(dir_.get());
- ASSERT_EQ(OPENED, dir_->OpenInMemoryForTest(kName, &delegate_,
- NullTransactionObserver()));
+ ASSERT_EQ(OPENED, dir_->Open(kName, &delegate_,
+ NullTransactionObserver()));
ASSERT_TRUE(dir_->good());
}
@@ -1337,10 +1338,11 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest {
file_path_ = temp_dir_.path().Append(
FILE_PATH_LITERAL("Test.sqlite3"));
file_util::Delete(file_path_, true);
- dir_.reset(new Directory(&encryptor_, &handler_, NULL));
+ dir_.reset(new Directory(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore(kName, file_path_)));
ASSERT_TRUE(dir_.get());
- ASSERT_EQ(OPENED, dir_->Open(file_path_, kName,
- &delegate_, NullTransactionObserver()));
+ ASSERT_EQ(OPENED, dir_->Open(kName, &delegate_,
+ NullTransactionObserver()));
ASSERT_TRUE(dir_->good());
}
@@ -1352,10 +1354,11 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest {
}
void ReloadDir() {
- dir_.reset(new Directory(&encryptor_, &handler_, NULL));
+ dir_.reset(new Directory(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore(kName, file_path_)));
ASSERT_TRUE(dir_.get());
- ASSERT_EQ(OPENED, dir_->Open(file_path_, kName,
- &delegate_, NullTransactionObserver()));
+ ASSERT_EQ(OPENED, dir_->Open(kName, &delegate_,
+ NullTransactionObserver()));
}
void SaveAndReloadDir() {
@@ -1368,10 +1371,10 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest {
// We first assign the object to a pointer of type TestUnsaveableDirectory
// because the OpenUnsaveable function is not available in the parent class.
- scoped_ptr<TestUnsaveableDirectory> dir(new TestUnsaveableDirectory());
+ scoped_ptr<TestUnsaveableDirectory> dir(new TestUnsaveableDirectory(
+ kName, file_path_));
ASSERT_TRUE(dir.get());
- ASSERT_EQ(OPENED, dir->OpenUnsaveable(
- file_path_, kName, &delegate_, NullTransactionObserver()));
+ ASSERT_EQ(OPENED, dir->Open(kName, &delegate_, NullTransactionObserver()));
// Finally, move the unsaveable directory to the dir_ variable.
dir_ = dir.Pass();
@@ -1509,10 +1512,10 @@ TEST_F(OnDiskSyncableDirectoryTest,
}
dir_->SaveChanges();
- dir_.reset(new Directory(&encryptor_, &handler_, NULL));
+ dir_.reset(new Directory(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore(kName, file_path_)));
ASSERT_TRUE(dir_.get());
- ASSERT_EQ(OPENED, dir_->Open(file_path_, kName,
- &delegate_, NullTransactionObserver()));
+ ASSERT_EQ(OPENED, dir_->Open(kName, &delegate_, NullTransactionObserver()));
ASSERT_TRUE(dir_->good());
{
@@ -1714,17 +1717,14 @@ DirOpenResult SyncableDirectoryTest::SimulateSaveAndReloadDir() {
return FAILED_IN_UNITTEST;
// Do some tricky things to preserve the backing store.
- DirectoryBackingStore* saved_store = dir_->store_;
- dir_->store_ = NULL;
+ DirectoryBackingStore* saved_store = dir_->store_.release();
// Close the current directory.
dir_->Close();
dir_.reset();
- dir_.reset(new Directory(&encryptor_, &handler_, NULL));
- if (!dir_.get())
- return FAILED_IN_UNITTEST;
- DirOpenResult result = dir_->OpenImpl(saved_store, kName, &delegate_,
+ dir_.reset(new Directory(&encryptor_, &handler_, NULL, saved_store));
+ DirOpenResult result = dir_->OpenImpl(kName, &delegate_,
NullTransactionObserver());
// If something went wrong, we need to clear this member. If we don't,
@@ -1757,9 +1757,10 @@ TEST_F(SyncableDirectoryManagement, TestFileRelease) {
FilePath path = temp_dir_.path().Append(
Directory::kSyncDatabaseFilename);
- syncable::Directory dir(&encryptor_, &handler_, NULL);
+ syncable::Directory dir(&encryptor_, &handler_, NULL,
+ new OnDiskDirectoryBackingStore("ScopeTest", path));
DirOpenResult result =
- dir.Open(path, "ScopeTest", &delegate_, NullTransactionObserver());
+ dir.Open("ScopeTest", &delegate_, NullTransactionObserver());
ASSERT_EQ(result, OPENED);
dir.Close();
@@ -1817,11 +1818,10 @@ TEST(SyncableDirectory, StressTransactions) {
FakeEncryptor encryptor;
TestUnrecoverableErrorHandler handler;
NullDirectoryChangeDelegate delegate;
- Directory dir(&encryptor, &handler, NULL);
- FilePath path = temp_dir.path().Append(Directory::kSyncDatabaseFilename);
- file_util::Delete(path, true);
std::string dirname = "stress";
- dir.Open(path, dirname, &delegate, NullTransactionObserver());
+ Directory dir(&encryptor, &handler, NULL,
+ new InMemoryDirectoryBackingStore(dirname));
+ dir.Open(dirname, &delegate, NullTransactionObserver());
const int kThreadCount = 7;
base::PlatformThreadHandle threads[kThreadCount];
@@ -1838,7 +1838,6 @@ TEST(SyncableDirectory, StressTransactions) {
}
dir.Close();
- file_util::Delete(path, true);
}
class SyncableClientTagTest : public SyncableDirectoryTest {
diff --git a/sync/test/engine/test_directory_setter_upper.cc b/sync/test/engine/test_directory_setter_upper.cc
index 5cfeb2e..b73b654 100644
--- a/sync/test/engine/test_directory_setter_upper.cc
+++ b/sync/test/engine/test_directory_setter_upper.cc
@@ -9,6 +9,7 @@
#include "base/location.h"
#include "base/string_util.h"
#include "sync/syncable/directory.h"
+#include "sync/syncable/in_memory_directory_backing_store.h"
#include "sync/syncable/read_transaction.h"
#include "sync/test/null_transaction_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -23,9 +24,10 @@ TestDirectorySetterUpper::TestDirectorySetterUpper() : name_("Test") {}
TestDirectorySetterUpper::~TestDirectorySetterUpper() {}
void TestDirectorySetterUpper::SetUp() {
- directory_.reset(new syncable::Directory(&encryptor_, &handler_, NULL));
+ directory_.reset(new syncable::Directory(&encryptor_, &handler_, NULL,
+ new syncable::InMemoryDirectoryBackingStore(name_)));
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- ASSERT_EQ(syncable::OPENED, directory_->OpenInMemoryForTest(
+ ASSERT_EQ(syncable::OPENED, directory_->Open(
name_, &delegate_, NullTransactionObserver()));
}