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

Side by Side Diff: services/preferences/public/cpp/pref_service_factory.cc

Issue 2777483002: Pref service: Add initial support for pref registration. (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
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 #include "services/preferences/public/cpp/pref_service_factory.h" 5 #include "services/preferences/public/cpp/pref_service_factory.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "components/prefs/persistent_pref_store.h" 8 #include "components/prefs/persistent_pref_store.h"
9 #include "components/prefs/pref_notifier_impl.h" 9 #include "components/prefs/pref_notifier_impl.h"
10 #include "components/prefs/pref_registry.h" 10 #include "components/prefs/pref_registry.h"
11 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
12 #include "components/prefs/pref_value_store.h" 12 #include "components/prefs/pref_value_store.h"
13 #include "services/preferences/public/cpp/persistent_pref_store_client.h" 13 #include "services/preferences/public/cpp/persistent_pref_store_client.h"
14 #include "services/preferences/public/cpp/pref_registry_serializer.h"
14 #include "services/preferences/public/cpp/pref_store_client.h" 15 #include "services/preferences/public/cpp/pref_store_client.h"
15 #include "services/preferences/public/interfaces/preferences.mojom.h" 16 #include "services/preferences/public/interfaces/preferences.mojom.h"
16 #include "services/service_manager/public/cpp/connector.h" 17 #include "services/service_manager/public/cpp/connector.h"
17 18
18 namespace prefs { 19 namespace prefs {
19 namespace { 20 namespace {
20 21
21 // Used to implement a "fire and forget" pattern where we call an interface 22 // Used to implement a "fire and forget" pattern where we call an interface
22 // method, with an attached error handler, but don't care to hold on to the 23 // method, with an attached error handler, but don't care to hold on to the
23 // InterfacePtr after. 24 // InterfacePtr after.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } // namespace 96 } // namespace
96 97
97 void ConnectToPrefService(service_manager::Connector* connector, 98 void ConnectToPrefService(service_manager::Connector* connector,
98 scoped_refptr<PrefRegistry> pref_registry, 99 scoped_refptr<PrefRegistry> pref_registry,
99 ConnectCallback callback) { 100 ConnectCallback callback) {
100 auto connector_ptr = make_scoped_refptr( 101 auto connector_ptr = make_scoped_refptr(
101 new RefCountedInterfacePtr<mojom::PrefStoreConnector>()); 102 new RefCountedInterfacePtr<mojom::PrefStoreConnector>());
102 connector->BindInterface(mojom::kPrefStoreServiceName, &connector_ptr->get()); 103 connector->BindInterface(mojom::kPrefStoreServiceName, &connector_ptr->get());
103 connector_ptr->get().set_connection_error_handler(base::Bind( 104 connector_ptr->get().set_connection_error_handler(base::Bind(
104 &OnConnectError, connector_ptr, base::Passed(ConnectCallback{callback}))); 105 &OnConnectError, connector_ptr, base::Passed(ConnectCallback{callback})));
105 connector_ptr->get()->Connect(base::Bind(&OnConnect, connector_ptr, 106 auto serialized_pref_registry = SerializePrefRegistry(*pref_registry);
106 base::Passed(&pref_registry), 107 connector_ptr->get()->Connect(
107 base::Passed(&callback))); 108 std::move(serialized_pref_registry),
109 base::Bind(&OnConnect, connector_ptr, base::Passed(&pref_registry),
110 base::Passed(&callback)));
108 } 111 }
109 112
110 } // namespace prefs 113 } // namespace prefs
OLDNEW
« no previous file with comments | « services/preferences/public/cpp/pref_registry_serializer.cc ('k') | services/preferences/public/interfaces/preferences.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698