Chromium Code Reviews| 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/threading/thread_restrictions.h" | |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" | |
| 10 | 12 |
| 11 namespace prefs { | 13 namespace prefs { |
| 12 | 14 |
| 13 PersistentPrefStoreClient::PersistentPrefStoreClient( | 15 PersistentPrefStoreClient::PersistentPrefStoreClient( |
| 14 mojom::PersistentPrefStoreConnectorPtr connector) | 16 mojom::PersistentPrefStoreConnectorPtr connector) |
| 15 : connector_(std::move(connector)) {} | 17 : connector_(std::move(connector)) {} |
| 16 | 18 |
| 17 void PersistentPrefStoreClient::SetValue(const std::string& key, | 19 void PersistentPrefStoreClient::SetValue(const std::string& key, |
| 18 std::unique_ptr<base::Value> value, | 20 std::unique_ptr<base::Value> value, |
| 19 uint32_t flags) { | 21 uint32_t flags) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 const { | 65 const { |
| 64 return read_error_; | 66 return read_error_; |
| 65 } | 67 } |
| 66 | 68 |
| 67 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::ReadPrefs() { | 69 PersistentPrefStore::PrefReadError PersistentPrefStoreClient::ReadPrefs() { |
| 68 PrefReadError read_error = PrefReadError::PREF_READ_ERROR_NONE; | 70 PrefReadError read_error = PrefReadError::PREF_READ_ERROR_NONE; |
| 69 bool read_only = false; | 71 bool read_only = false; |
| 70 std::unique_ptr<base::DictionaryValue> local_prefs; | 72 std::unique_ptr<base::DictionaryValue> local_prefs; |
| 71 mojom::PersistentPrefStorePtr pref_store; | 73 mojom::PersistentPrefStorePtr pref_store; |
| 72 mojom::PrefStoreObserverRequest observer_request; | 74 mojom::PrefStoreObserverRequest observer_request; |
| 75 base::ThreadRestrictions::AssertWaitAllowed(); | |
|
jam
2017/03/22 14:58:12
nit: curious why you added this? mojo::SyncCallRes
Sam McNally
2017/03/28 23:06:22
It was intended to detect inadvertent post-startup
| |
| 76 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_calls; | |
| 73 if (!connector_->Connect(&read_error, &read_only, &local_prefs, &pref_store, | 77 if (!connector_->Connect(&read_error, &read_only, &local_prefs, &pref_store, |
| 74 &observer_request)) { | 78 &observer_request)) { |
| 75 NOTREACHED(); | 79 NOTREACHED(); |
| 76 } | 80 } |
| 77 | 81 |
| 78 OnCreateComplete(read_error, read_only, std::move(local_prefs), | 82 OnCreateComplete(read_error, read_only, std::move(local_prefs), |
| 79 std::move(pref_store), std::move(observer_request)); | 83 std::move(pref_store), std::move(observer_request)); |
| 80 return read_error_; | 84 return read_error_; |
| 81 } | 85 } |
| 82 | 86 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 read_only_ = read_only; | 124 read_only_ = read_only; |
| 121 pref_store_ = std::move(pref_store); | 125 pref_store_ = std::move(pref_store); |
| 122 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) | 126 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) |
| 123 error_delegate_->OnError(read_error_); | 127 error_delegate_->OnError(read_error_); |
| 124 error_delegate_.reset(); | 128 error_delegate_.reset(); |
| 125 | 129 |
| 126 Init(std::move(cached_prefs), true, std::move(observer_request)); | 130 Init(std::move(cached_prefs), true, std::move(observer_request)); |
| 127 } | 131 } |
| 128 | 132 |
| 129 } // namespace prefs | 133 } // namespace prefs |
| OLD | NEW |