| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(service_manager::Connector* connector, |
| 99 scoped_refptr<PrefRegistry> pref_registry, | 99 scoped_refptr<PrefRegistry> pref_registry, |
| 100 ConnectCallback callback) { | 100 ConnectCallback callback, |
| 101 base::StringPiece service_name) { |
| 101 auto connector_ptr = make_scoped_refptr( | 102 auto connector_ptr = make_scoped_refptr( |
| 102 new RefCountedInterfacePtr<mojom::PrefStoreConnector>()); | 103 new RefCountedInterfacePtr<mojom::PrefStoreConnector>()); |
| 103 connector->BindInterface(mojom::kPrefStoreServiceName, &connector_ptr->get()); | 104 connector->BindInterface(service_name.as_string(), &connector_ptr->get()); |
| 104 connector_ptr->get().set_connection_error_handler(base::Bind( | 105 connector_ptr->get().set_connection_error_handler(base::Bind( |
| 105 &OnConnectError, connector_ptr, base::Passed(ConnectCallback{callback}))); | 106 &OnConnectError, connector_ptr, base::Passed(ConnectCallback{callback}))); |
| 106 auto serialized_pref_registry = SerializePrefRegistry(*pref_registry); | 107 auto serialized_pref_registry = SerializePrefRegistry(*pref_registry); |
| 107 connector_ptr->get()->Connect( | 108 connector_ptr->get()->Connect( |
| 108 std::move(serialized_pref_registry), | 109 std::move(serialized_pref_registry), |
| 109 base::Bind(&OnConnect, connector_ptr, base::Passed(&pref_registry), | 110 base::Bind(&OnConnect, connector_ptr, base::Passed(&pref_registry), |
| 110 base::Passed(&callback))); | 111 base::Passed(&callback))); |
| 111 } | 112 } |
| 112 | 113 |
| 113 } // namespace prefs | 114 } // namespace prefs |
| OLD | NEW |