Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This provides a way for any service to connect to the pref service to access | 5 // This provides a way for any service to connect to the pref service to access |
| 6 // the application's current preferences. | 6 // the application's current preferences. |
| 7 | 7 |
| 8 // Access is provided through a synchronous interface, exposed using the | 8 // Access is provided through a synchronous interface, exposed using the |
| 9 // |PrefService| class. | 9 // |PrefService| class. |
| 10 | 10 |
| 11 #ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_ | 11 #ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_ |
| 12 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_ | 12 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_ |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "services/preferences/public/interfaces/preferences.mojom.h" | |
| 17 | 18 |
| 18 class PrefRegistry; | 19 class PrefRegistry; |
| 19 class PrefService; | 20 class PrefService; |
| 20 | 21 |
| 21 namespace service_manager { | 22 namespace service_manager { |
| 22 class Connector; | 23 class Connector; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace prefs { | 26 namespace prefs { |
| 26 | 27 |
| 27 // Note that |PrefService| might not be fully initialized yet and thus you need | 28 // Note that |PrefService| might not be fully initialized yet and thus you need |
| 28 // to call |AddPrefInitObserver| on it before using it. Passed |nullptr| on | 29 // to call |AddPrefInitObserver| on it before using it. Passed |nullptr| on |
| 29 // failure. | 30 // failure. |
| 30 using ConnectCallback = base::Callback<void(std::unique_ptr<::PrefService>)>; | 31 using ConnectCallback = base::Callback<void(std::unique_ptr<::PrefService>)>; |
| 31 | 32 |
| 32 // Create a |PrefService| object acting as a client library for the pref | 33 // Create a |PrefService| object acting as a client library for the pref |
| 33 // service, by connecting to the service using |connector|. Connecting is | 34 // service, by connecting to the service using |connector|. Connecting is |
| 34 // asynchronous and |callback| will be called when it has been established. All | 35 // asynchronous and |callback| will be called when it has been established. All |
| 35 // preferences that will be accessed need to be registered in |pref_registry| | 36 // preferences that will be accessed need to be registered in |pref_registry| |
| 36 // first. | 37 // first. |
| 37 void ConnectToPrefService(service_manager::Connector* connector, | 38 void ConnectToPrefService( |
| 38 scoped_refptr<PrefRegistry> pref_registry, | 39 service_manager::Connector* connector, |
| 39 ConnectCallback callback); | 40 scoped_refptr<PrefRegistry> pref_registry, |
| 41 ConnectCallback callback, | |
| 42 const std::string& service_name = mojom::kPrefStoreServiceName); | |
|
Sam McNally
2017/03/27 05:42:11
base::StringPiece
tibell
2017/03/28 00:34:31
Done.
| |
| 40 | 43 |
| 41 } // namespace prefs | 44 } // namespace prefs |
| 42 | 45 |
| 43 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_ | 46 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_SERVICE_FACTORY_H_ |
| OLD | NEW |