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/persistent_pref_store_client.h" | 5 #include "services/preferences/public/cpp/persistent_pref_store_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/prefs/pref_registry.h" | 10 #include "components/prefs/pref_registry.h" |
| 11 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" |
11 #include "services/preferences/public/cpp/pref_registry_serializer.h" | 12 #include "services/preferences/public/cpp/pref_registry_serializer.h" |
12 | 13 |
13 namespace prefs { | 14 namespace prefs { |
14 | 15 |
15 PersistentPrefStoreClient::PersistentPrefStoreClient( | 16 PersistentPrefStoreClient::PersistentPrefStoreClient( |
16 mojom::PrefStoreConnectorPtr connector, | 17 mojom::PrefStoreConnectorPtr connector, |
17 scoped_refptr<PrefRegistry> pref_registry) | 18 scoped_refptr<PrefRegistry> pref_registry) |
18 : connector_(std::move(connector)), | 19 : connector_(std::move(connector)), |
19 pref_registry_(std::move(pref_registry)) { | 20 pref_registry_(std::move(pref_registry)) { |
20 DCHECK(connector_); | 21 DCHECK(connector_); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::GetReadError() | 76 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::GetReadError() |
76 const { | 77 const { |
77 return read_error_; | 78 return read_error_; |
78 } | 79 } |
79 | 80 |
80 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::ReadPrefs() { | 81 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::ReadPrefs() { |
81 mojom::PersistentPrefStoreConnectionPtr connection; | 82 mojom::PersistentPrefStoreConnectionPtr connection; |
82 std::unordered_map<PrefValueStore::PrefStoreType, | 83 std::unordered_map<PrefValueStore::PrefStoreType, |
83 prefs::mojom::PrefStoreConnectionPtr> | 84 prefs::mojom::PrefStoreConnectionPtr> |
84 other_pref_stores; | 85 other_pref_stores; |
| 86 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_calls; |
85 if (!connector_->Connect(SerializePrefRegistry(*pref_registry_), &connection, | 87 if (!connector_->Connect(SerializePrefRegistry(*pref_registry_), &connection, |
86 &other_pref_stores)) { | 88 &other_pref_stores)) { |
87 NOTREACHED(); | 89 NOTREACHED(); |
88 } | 90 } |
89 pref_registry_ = nullptr; | 91 pref_registry_ = nullptr; |
90 OnConnect(std::move(connection), std::move(other_pref_stores)); | 92 OnConnect(std::move(connection), std::move(other_pref_stores)); |
91 return read_error_; | 93 return read_error_; |
92 } | 94 } |
93 | 95 |
94 void PersistentPrefStoreClient::ReadPrefsAsync( | 96 void PersistentPrefStoreClient::ReadPrefsAsync( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 139 |
138 if (connection->pref_store_connection) { | 140 if (connection->pref_store_connection) { |
139 Init(std::move(connection->pref_store_connection->initial_prefs), true, | 141 Init(std::move(connection->pref_store_connection->initial_prefs), true, |
140 std::move(connection->pref_store_connection->observer)); | 142 std::move(connection->pref_store_connection->observer)); |
141 } else { | 143 } else { |
142 Init(nullptr, false, nullptr); | 144 Init(nullptr, false, nullptr); |
143 } | 145 } |
144 } | 146 } |
145 | 147 |
146 } // namespace prefs | 148 } // namespace prefs |
OLD | NEW |