summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/state_store.h1
-rw-r--r--chrome/browser/value_store/value_store_frontend.cc11
-rw-r--r--chrome/browser/value_store/value_store_frontend.h1
3 files changed, 9 insertions, 4 deletions
diff --git a/chrome/browser/extensions/state_store.h b/chrome/browser/extensions/state_store.h
index 8e8ef7a..54f5995 100644
--- a/chrome/browser/extensions/state_store.h
+++ b/chrome/browser/extensions/state_store.h
@@ -26,6 +26,7 @@ class StateStore
typedef ValueStoreFrontend::ReadCallback ReadCallback;
StateStore(Profile* profile, const FilePath& db_path);
+ // This variant is useful for testing (using a mock ValueStore).
StateStore(Profile* profile, ValueStore* store);
virtual ~StateStore();
diff --git a/chrome/browser/value_store/value_store_frontend.cc b/chrome/browser/value_store/value_store_frontend.cc
index 58dd258..b820155 100644
--- a/chrome/browser/value_store/value_store_frontend.cc
+++ b/chrome/browser/value_store/value_store_frontend.cc
@@ -13,7 +13,6 @@ using content::BrowserThread;
class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> {
public:
Backend() : storage_(NULL) {}
- explicit Backend(ValueStore* storage) : storage_(storage) {}
void Init(const FilePath& db_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
@@ -23,10 +22,11 @@ class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> {
storage_ = new FailingValueStore();
}
- void InitWithStore(ValueStore* storage) {
+ // This variant is useful for testing (using a mock ValueStore).
+ void InitWithStore(scoped_ptr<ValueStore> storage) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!storage_);
- storage_ = storage;
+ storage_ = storage.release();
}
void Get(const std::string& key,
@@ -90,7 +90,10 @@ ValueStoreFrontend::ValueStoreFrontend(const FilePath& db_path)
}
ValueStoreFrontend::ValueStoreFrontend(ValueStore* value_store)
- : backend_(new Backend(value_store)) {
+ : backend_(new Backend()) {
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&ValueStoreFrontend::Backend::InitWithStore,
+ backend_, base::Passed(scoped_ptr<ValueStore>(value_store))));
}
ValueStoreFrontend::~ValueStoreFrontend() {
diff --git a/chrome/browser/value_store/value_store_frontend.h b/chrome/browser/value_store/value_store_frontend.h
index d5d96dd..ad8dc78 100644
--- a/chrome/browser/value_store/value_store_frontend.h
+++ b/chrome/browser/value_store/value_store_frontend.h
@@ -26,6 +26,7 @@ class ValueStoreFrontend
typedef base::Callback<void(scoped_ptr<base::Value>)> ReadCallback;
explicit ValueStoreFrontend(const FilePath& db_path);
+ // This variant is useful for testing (using a mock ValueStore).
explicit ValueStoreFrontend(ValueStore* value_store);
~ValueStoreFrontend();