Extensions: Using common ValueStoreFactory for all value stores.

1. Introduce new ValueStoreFactory interface used for the creation of
   ValueStore's in all namespaces (local, sync, and managed), and for all
   types (extension and application).
2. Delete SettingsStorageFactory/LeveldbSettingsStorageFactory,
   and switched to ValueStoreFactory.
3. Created a new TestValueStoreFactory (for testing). This combines
   settings_sync_unittest.cc:TestingValueStoreFactory and
   ScopedSettingsStorageFactory.
4. ValueStoreFrontend::Backend always lazilily initializes using the
   ValueStoreFactory. This makes unnecessary StateStore's deferred
   initialization mechanism - which will be removed in an upcoming CL.
5. A new ValueStoreFactoryImpl to mint new ValueStore's for Chrome.
   This currently delegates to a new LegacyValueStoreFactory which
   creates new LeveldbValueStore. An upcoming CL will add a second
   delegated factory (currently called ProfileValueStoreFactory) to
   support a unified (per-profile) extensions database.
6. Removed memcheck suppression for SettingsStorageFactory as this
   class is now deleted (crbug.com/163922).

BUG=453946,163922

Review URL: https://codereview.chromium.org/1803193002

Cr-Commit-Position: refs/heads/master@{#383137}
diff --git a/chrome/browser/extensions/test_extension_system.cc b/chrome/browser/extensions/test_extension_system.cc
index 19f17ce..f1165963 100644
--- a/chrome/browser/extensions/test_extension_system.cc
+++ b/chrome/browser/extensions/test_extension_system.cc
@@ -25,6 +25,7 @@
 #include "extensions/browser/quota_service.h"
 #include "extensions/browser/runtime_data.h"
 #include "extensions/browser/state_store.h"
+#include "extensions/browser/value_store/test_value_store_factory.h"
 #include "extensions/browser/value_store/testing_value_store.h"
 
 using content::BrowserThread;
@@ -33,11 +34,10 @@
 
 TestExtensionSystem::TestExtensionSystem(Profile* profile)
     : profile_(profile),
-      value_store_(NULL),
+      store_factory_(new TestValueStoreFactory()),
       info_map_(new InfoMap()),
       quota_service_(new QuotaService()),
-      app_sorting_(new ChromeAppSorting(profile_)) {
-}
+      app_sorting_(new ChromeAppSorting(profile_)) {}
 
 TestExtensionSystem::~TestExtensionSystem() {
 }
@@ -51,11 +51,8 @@
     const base::CommandLine* command_line,
     const base::FilePath& install_directory,
     bool autoupdate_enabled) {
-  // The ownership of |value_store_| is immediately transferred to state_store_,
-  // but we keep a naked pointer to the TestingValueStore.
-  scoped_ptr<TestingValueStore> value_store(new TestingValueStore());
-  value_store_ = value_store.get();
-  state_store_.reset(new StateStore(profile_, std::move(value_store)));
+  state_store_.reset(new StateStore(
+      profile_, store_factory_, ValueStoreFrontend::BackendType::RULES, false));
   management_policy_.reset(new ManagementPolicy());
   management_policy_->RegisterProviders(
       ExtensionManagementFactory::GetForBrowserContext(profile_)
@@ -105,6 +102,10 @@
   return state_store_.get();
 }
 
+scoped_refptr<ValueStoreFactory> TestExtensionSystem::store_factory() {
+  return store_factory_;
+}
+
 InfoMap* TestExtensionSystem::info_map() { return info_map_.get(); }
 
 QuotaService* TestExtensionSystem::quota_service() {
@@ -135,7 +136,9 @@
 }
 
 TestingValueStore* TestExtensionSystem::value_store() {
-  return value_store_;
+  // These tests use TestingValueStore in a way that ensures it only ever mints
+  // instances of TestingValueStore.
+  return static_cast<TestingValueStore*>(store_factory_->LastCreatedStore());
 }
 
 // static