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

Unified Diff: services/preferences/public/cpp/pref_service_factory.h

Issue 2762333003: Pref service: add a factory to create the client lib (Closed)
Patch Set: Address more review comments from sammc@ Created 3 years, 9 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
« no previous file with comments | « services/preferences/public/cpp/BUILD.gn ('k') | services/preferences/public/cpp/pref_service_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/preferences/public/cpp/pref_service_factory.h
diff --git a/services/preferences/public/cpp/pref_service_factory.h b/services/preferences/public/cpp/pref_service_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..0926b06f822eed644b76f6e10e3f0735c9c0680d
--- /dev/null
+++ b/services/preferences/public/cpp/pref_service_factory.h
@@ -0,0 +1,43 @@
+// Copyright 2017 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.
+
+// This provides a way for any service to connect to the pref service to access
+// the application's current preferences.
+
+// Access is provided through a synchronous interface, exposed using the
+// |PrefService| class.
+
+#ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_
Ken Rockot(use gerrit already) 2017/03/22 06:21:01 I have to say it's kind of a bummer that the pref
tibell 2017/03/22 06:26:12 I know. I know. :) When this service has taken ove
+#define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_
+
+#include <memory>
+
+#include "base/callback.h"
+
+class PrefRegistry;
+class PrefService;
+
+namespace service_manager {
+class Connector;
+}
+
+namespace prefs {
+
+// Note that |PrefService| might not be fully initialized yet and thus you need
+// to call |AddPrefInitObserver| on it before using it. Passed |nullptr| on
+// failure.
+using ConnectCallback = base::Callback<void(std::unique_ptr<::PrefService>)>;
+
+// Create a |PrefService| object acting as a client library for the pref
+// service, by connecting to the service using |connector|. Connecting is
+// asynchronous and |callback| will be called when it has been established. All
+// preferences that will be accessed need to be registered in |pref_registry|
+// first.
+void ConnectToPrefService(service_manager::Connector* connector,
+ scoped_refptr<PrefRegistry> pref_registry,
+ const ConnectCallback& callback);
+
+} // namespace prefs
+
+#endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_
« no previous file with comments | « services/preferences/public/cpp/BUILD.gn ('k') | services/preferences/public/cpp/pref_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698