Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1990)

Unified Diff: components/filesystem/public/cpp/prefs/pref_service_factory.cc

Issue 1624683002: mash: Add a simple, temporary preferences store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/filesystem/public/cpp/prefs/pref_service_factory.cc
diff --git a/components/filesystem/public/cpp/prefs/pref_service_factory.cc b/components/filesystem/public/cpp/prefs/pref_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b2209e75b9a80990c355823f3c2a517a3fe013e6
--- /dev/null
+++ b/components/filesystem/public/cpp/prefs/pref_service_factory.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/filesystem/public/cpp/prefs/pref_service_factory.h"
+
+#include "base/bind.h"
+#include "base/prefs/pref_notifier_impl.h"
+#include "base/prefs/pref_registry.h"
+#include "base/prefs/pref_service.h"
+#include "base/prefs/pref_value_store.h"
+#include "base/prefs/value_map_pref_store.h"
+#include "base/prefs/writeable_pref_store.h"
+#include "components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h"
+#include "mojo/shell/public/cpp/application_impl.h"
+
+namespace filesystem {
+
+namespace {
+
+// Do-nothing default implementation.
+void DoNothingHandleReadError(PersistentPrefStore::PrefReadError error) {}
+
+} // namespace
+
+scoped_ptr<PrefService> CreatePrefService(mojo::ApplicationImpl* application,
+ PrefRegistry* pref_registry) {
+ filesystem::FileSystemPtr filesystem;
+ application->ConnectToService("mojo:filesystem", &filesystem);
+
+ scoped_refptr<FilesystemJsonPrefStore> user_prefs =
+ new FilesystemJsonPrefStore("preferences.json", std::move(filesystem),
+ nullptr /* TODO(erg): pref filter */);
+
+ PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
+ scoped_ptr<PrefService> pref_service(new PrefService(
+ pref_notifier,
+ new PrefValueStore(nullptr, nullptr, nullptr, nullptr, user_prefs.get(),
+ nullptr, pref_registry->defaults().get(),
+ pref_notifier),
+ user_prefs.get(), pref_registry, base::Bind(&DoNothingHandleReadError),
+ true /* async */));
+ return pref_service;
+}
+
+} // namespace filesystem
« no previous file with comments | « components/filesystem/public/cpp/prefs/pref_service_factory.h ('k') | components/filesystem/public/interfaces/file.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698