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 "mojo/public/cpp/bindings/sync_call_restrictions.h" |
12 #include "services/preferences/public/cpp/pref_registry_serializer.h" | 12 #include "services/preferences/public/cpp/pref_registry_serializer.h" |
13 | 13 |
14 namespace prefs { | 14 namespace prefs { |
15 | 15 |
16 PersistentPrefStoreClient::PersistentPrefStoreClient( | 16 PersistentPrefStoreClient::PersistentPrefStoreClient( |
17 mojom::PrefStoreConnectorPtr connector, | 17 mojom::PrefStoreConnectorPtr connector, |
18 scoped_refptr<PrefRegistry> pref_registry) | 18 scoped_refptr<PrefRegistry> pref_registry, |
| 19 std::vector<PrefValueStore::PrefStoreType> already_connected_types) |
19 : connector_(std::move(connector)), | 20 : connector_(std::move(connector)), |
20 pref_registry_(std::move(pref_registry)) { | 21 pref_registry_(std::move(pref_registry)), |
| 22 already_connected_types_(std::move(already_connected_types)) { |
21 DCHECK(connector_); | 23 DCHECK(connector_); |
22 } | 24 } |
23 | 25 |
24 PersistentPrefStoreClient::PersistentPrefStoreClient( | 26 PersistentPrefStoreClient::PersistentPrefStoreClient( |
25 mojom::PersistentPrefStoreConnectionPtr connection) { | 27 mojom::PersistentPrefStoreConnectionPtr connection) { |
26 OnConnect(std::move(connection), | 28 OnConnect(std::move(connection), |
27 std::unordered_map<PrefValueStore::PrefStoreType, | 29 std::unordered_map<PrefValueStore::PrefStoreType, |
28 prefs::mojom::PrefStoreConnectionPtr>()); | 30 prefs::mojom::PrefStoreConnectionPtr>()); |
29 } | 31 } |
30 | 32 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 const { | 79 const { |
78 return read_error_; | 80 return read_error_; |
79 } | 81 } |
80 | 82 |
81 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::ReadPrefs() { | 83 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::ReadPrefs() { |
82 mojom::PersistentPrefStoreConnectionPtr connection; | 84 mojom::PersistentPrefStoreConnectionPtr connection; |
83 std::unordered_map<PrefValueStore::PrefStoreType, | 85 std::unordered_map<PrefValueStore::PrefStoreType, |
84 prefs::mojom::PrefStoreConnectionPtr> | 86 prefs::mojom::PrefStoreConnectionPtr> |
85 other_pref_stores; | 87 other_pref_stores; |
86 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_calls; | 88 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_calls; |
87 if (!connector_->Connect(SerializePrefRegistry(*pref_registry_), &connection, | 89 if (!connector_->Connect(SerializePrefRegistry(*pref_registry_), |
| 90 already_connected_types_, &connection, |
88 &other_pref_stores)) { | 91 &other_pref_stores)) { |
89 NOTREACHED(); | 92 NOTREACHED(); |
90 } | 93 } |
91 pref_registry_ = nullptr; | 94 pref_registry_ = nullptr; |
92 OnConnect(std::move(connection), std::move(other_pref_stores)); | 95 OnConnect(std::move(connection), std::move(other_pref_stores)); |
93 return read_error_; | 96 return read_error_; |
94 } | 97 } |
95 | 98 |
96 void PersistentPrefStoreClient::ReadPrefsAsync( | 99 void PersistentPrefStoreClient::ReadPrefsAsync( |
97 ReadErrorDelegate* error_delegate) { | 100 ReadErrorDelegate* error_delegate) { |
98 error_delegate_.reset(error_delegate); | 101 error_delegate_.reset(error_delegate); |
99 connector_->Connect(SerializePrefRegistry(*pref_registry_), | 102 connector_->Connect(SerializePrefRegistry(*pref_registry_), |
| 103 already_connected_types_, |
100 base::Bind(&PersistentPrefStoreClient::OnConnect, | 104 base::Bind(&PersistentPrefStoreClient::OnConnect, |
101 base::Unretained(this))); | 105 base::Unretained(this))); |
102 pref_registry_ = nullptr; | 106 pref_registry_ = nullptr; |
103 } | 107 } |
104 | 108 |
105 void PersistentPrefStoreClient::CommitPendingWrite() { | 109 void PersistentPrefStoreClient::CommitPendingWrite() { |
106 DCHECK(pref_store_); | 110 DCHECK(pref_store_); |
107 pref_store_->CommitPendingWrite(); | 111 pref_store_->CommitPendingWrite(); |
108 } | 112 } |
109 | 113 |
(...skipping 29 matching lines...) Expand all Loading... |
139 | 143 |
140 if (connection->pref_store_connection) { | 144 if (connection->pref_store_connection) { |
141 Init(std::move(connection->pref_store_connection->initial_prefs), true, | 145 Init(std::move(connection->pref_store_connection->initial_prefs), true, |
142 std::move(connection->pref_store_connection->observer)); | 146 std::move(connection->pref_store_connection->observer)); |
143 } else { | 147 } else { |
144 Init(nullptr, false, nullptr); | 148 Init(nullptr, false, nullptr); |
145 } | 149 } |
146 } | 150 } |
147 | 151 |
148 } // namespace prefs | 152 } // namespace prefs |
OLD | NEW |