Chromium Code Reviews| Index: services/preferences/user_prefs.h |
| diff --git a/services/preferences/user_prefs.h b/services/preferences/user_prefs.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..69b4bf21967386349be296a2264ffbf503719d4c |
| --- /dev/null |
| +++ b/services/preferences/user_prefs.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef SERVICES_PREFERENCES_USER_PREFS_H_ |
| +#define SERVICES_PREFERENCES_USER_PREFS_H_ |
| + |
| +#include <memory> |
| +#include <unordered_map> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "services/preferences/public/interfaces/preferences.mojom.h" |
| +#include "services/preferences/public/interfaces/tracked_preference_validation_delegate.mojom.h" |
| + |
| +namespace base { |
| +class Value; |
| +} |
| + |
| +namespace prefs { |
| + |
| +class UserPrefs : public mojom::PersistentPrefStoreConnector, |
|
tibell
2017/03/10 02:18:27
Sorry to be a pain, but I think it would be nice t
Sam McNally
2017/03/10 02:43:25
Done.
|
| + public PrefStore::Observer { |
| + public: |
| + UserPrefs(scoped_refptr<PersistentPrefStore> backing_pref_store, |
| + mojom::TrackedPreferenceValidationDelegatePtr validation_delegate); |
| + |
| + ~UserPrefs() override; |
| + |
| + // mojom::PersistentPrefStoreConnector override: |
| + void Connect(const ConnectCallback& callback) override; |
| + |
| + private: |
| + class Connection; |
| + |
| + void SetValue(const std::string& key, |
| + std::unique_ptr<base::Value> value, |
| + uint32_t flags); |
| + |
| + void CommitPendingWrite(); |
| + void SchedulePendingLossyWrites(); |
| + void ClearMutableValues(); |
| + |
| + // PrefStore::Observer: |
| + void OnPrefValueChanged(const std::string& key) override; |
| + void OnInitializationCompleted(bool succeeded) override; |
| + |
| + void CallConnectCallback( |
| + const mojom::PersistentPrefStoreConnector::ConnectCallback& callback); |
| + void OnConnectionError(Connection* connection); |
| + |
| + scoped_refptr<PersistentPrefStore> backing_pref_store_; |
| + mojom::TrackedPreferenceValidationDelegatePtr validation_delegate_; |
| + |
| + bool initializing_ = false; |
| + std::vector<ConnectCallback> pending_connect_callbacks_; |
| + |
| + std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; |
|
tibell
2017/03/10 02:18:27
Could this just be set<std::unique_ptr<Connection>
Sam McNally
2017/03/10 02:43:25
Lookup by unique_ptr is inefficient.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(UserPrefs); |
| +}; |
| + |
| +} // namespace prefs |
| + |
| +#endif // SERVICES_PREFERENCES_USER_PREFS_H_ |