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 #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" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void OnConnectError( | 88 void OnConnectError( |
89 scoped_refptr<RefCountedInterfacePtr<mojom::PrefStoreConnector>> | 89 scoped_refptr<RefCountedInterfacePtr<mojom::PrefStoreConnector>> |
90 connector_ptr, | 90 connector_ptr, |
91 ConnectCallback callback) { | 91 ConnectCallback callback) { |
92 callback.Run(nullptr); | 92 callback.Run(nullptr); |
93 connector_ptr->reset(); | 93 connector_ptr->reset(); |
94 } | 94 } |
95 | 95 |
96 } // namespace | 96 } // namespace |
97 | 97 |
98 void ConnectToPrefService(service_manager::Connector* connector, | 98 void ConnectToPrefService( |
99 scoped_refptr<PrefRegistry> pref_registry, | 99 service_manager::Connector* connector, |
100 ConnectCallback callback, | 100 scoped_refptr<PrefRegistry> pref_registry, |
101 base::StringPiece service_name) { | 101 const std::vector<PrefValueStore::PrefStoreType>& already_connected_types, |
| 102 ConnectCallback callback, |
| 103 base::StringPiece service_name) { |
102 auto connector_ptr = make_scoped_refptr( | 104 auto connector_ptr = make_scoped_refptr( |
103 new RefCountedInterfacePtr<mojom::PrefStoreConnector>()); | 105 new RefCountedInterfacePtr<mojom::PrefStoreConnector>()); |
104 connector->BindInterface(service_name.as_string(), &connector_ptr->get()); | 106 connector->BindInterface(service_name.as_string(), &connector_ptr->get()); |
105 connector_ptr->get().set_connection_error_handler(base::Bind( | 107 connector_ptr->get().set_connection_error_handler(base::Bind( |
106 &OnConnectError, connector_ptr, base::Passed(ConnectCallback{callback}))); | 108 &OnConnectError, connector_ptr, base::Passed(ConnectCallback{callback}))); |
107 auto serialized_pref_registry = SerializePrefRegistry(*pref_registry); | 109 auto serialized_pref_registry = SerializePrefRegistry(*pref_registry); |
108 connector_ptr->get()->Connect( | 110 connector_ptr->get()->Connect( |
109 std::move(serialized_pref_registry), | 111 std::move(serialized_pref_registry), already_connected_types, |
110 base::Bind(&OnConnect, connector_ptr, base::Passed(&pref_registry), | 112 base::Bind(&OnConnect, connector_ptr, base::Passed(&pref_registry), |
111 base::Passed(&callback))); | 113 base::Passed(&callback))); |
112 } | 114 } |
113 | 115 |
114 } // namespace prefs | 116 } // namespace prefs |
OLD | NEW |