OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 module prefs.mojom; | 5 module prefs.mojom; |
6 | 6 |
7 import "mojo/common/values.mojom"; | 7 import "mojo/common/values.mojom"; |
8 import "services/preferences/public/interfaces/preferences_configuration.mojom"; | 8 import "services/preferences/public/interfaces/preferences_configuration.mojom"; |
9 | 9 |
10 const string kServiceName = "preferences"; | 10 const string kServiceName = "preferences"; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // Initial values of the PrefStore. These will not be communicated through | 63 // Initial values of the PrefStore. These will not be communicated through |
64 // OnPrefChanged. | 64 // OnPrefChanged. |
65 mojo.common.mojom.DictionaryValue initial_prefs; | 65 mojo.common.mojom.DictionaryValue initial_prefs; |
66 | 66 |
67 // Is the PrefStore initialized? If not it should not be used before | 67 // Is the PrefStore initialized? If not it should not be used before |
68 // OnInitializationCompleted has been called. | 68 // OnInitializationCompleted has been called. |
69 bool is_initialized; | 69 bool is_initialized; |
70 }; | 70 }; |
71 | 71 |
| 72 struct PersistentPrefStoreConnection { |
| 73 enum ReadError { |
| 74 NONE = 0, |
| 75 JSON_PARSE = 1, |
| 76 JSON_TYPE = 2, |
| 77 ACCESS_DENIED = 3, |
| 78 FILE_OTHER = 4, |
| 79 FILE_LOCKED = 5, |
| 80 NO_FILE = 6, |
| 81 JSON_REPEAT = 7, |
| 82 // OTHER = 8, // Deprecated. |
| 83 FILE_NOT_SPECIFIED = 9, |
| 84 ASYNCHRONOUS_TASK_INCOMPLETE = 10, |
| 85 }; |
| 86 |
| 87 PrefStoreConnection? pref_store_connection; |
| 88 PersistentPrefStore? pref_store; |
| 89 ReadError read_error; |
| 90 bool read_only; |
| 91 }; |
| 92 |
72 // Manages actual read of preference data. Accepts observers who subscribe to | 93 // Manages actual read of preference data. Accepts observers who subscribe to |
73 // preferences, notifying them of changes. | 94 // preferences, notifying them of changes. |
74 interface PrefStore { | 95 interface PrefStore { |
75 // Add an observer of changes. This current values of all prefs will not be | 96 // Add an observer of changes. This current values of all prefs will not be |
76 // communicated through a call to |observer| but instead be returned in | 97 // communicated through a call to |observer| but instead be returned in |
77 // |initial_prefs|. | 98 // |initial_prefs|. |
78 AddObserver() => (PrefStoreConnection connection); | 99 AddObserver() => (PrefStoreConnection connection); |
79 }; | 100 }; |
80 | 101 |
81 // Manages a registry of all pref stores. Registered pref stores can be | 102 // Manages a registry of all pref stores. Registered pref stores can be |
82 // connected to through the |PrefStoreConnector| interface. | 103 // connected to through the |PrefStoreConnector| interface. |
83 interface PrefStoreRegistry { | 104 interface PrefStoreRegistry { |
84 // Register a pref store. | 105 // Register a pref store. |
85 Register(PrefStoreType type, PrefStore pref_store); | 106 Register(PrefStoreType type, PrefStore pref_store); |
86 }; | 107 }; |
87 | 108 |
88 // Allows connections to pref stores registered with |PrefStoreRegistry|. | 109 // Allows connections to pref stores registered with |PrefStoreRegistry|. |
89 interface PrefStoreConnector { | 110 interface PrefStoreConnector { |
90 // Connect to all registered pref stores, retrieving the current values of all | 111 // Connect to all registered pref stores, retrieving the current values of all |
91 // prefs in each store and an |observer| interfaces through which updates can | 112 // prefs in each store and an |observer| interfaces through which updates can |
92 // be received. | 113 // be received. |
93 Connect() => (map<PrefStoreType, PrefStoreConnection> connections); | 114 [Sync] |
| 115 Connect(PrefRegistry pref_registry) => |
| 116 (PersistentPrefStoreConnection connection, |
| 117 map<PrefStoreType, PrefStoreConnection> connections); |
94 }; | 118 }; |
95 | 119 |
96 // An interface providing mutation access to a PersistentPrefStore. | 120 // An interface providing mutation access to a PersistentPrefStore. |
97 interface PersistentPrefStore { | 121 interface PersistentPrefStore { |
98 // Sets the value for |key|. A null |value| indicates a delete. |flags| is a | 122 // Sets the value for |key|. A null |value| indicates a delete. |flags| is a |
99 // bitmask of WritablePrefStore::PrefWriteFlags. | 123 // bitmask of WritablePrefStore::PrefWriteFlags. |
100 SetValue(string key, mojo.common.mojom.Value? value, uint32 flags); | 124 SetValue(string key, mojo.common.mojom.Value? value, uint32 flags); |
101 | 125 |
102 // These mirror the C++ PersistentPrefStore methods. | 126 // These mirror the C++ PersistentPrefStore methods. |
103 CommitPendingWrite(); | 127 CommitPendingWrite(); |
104 SchedulePendingLossyWrites(); | 128 SchedulePendingLossyWrites(); |
105 ClearMutableValues(); | 129 ClearMutableValues(); |
106 }; | 130 }; |
107 | 131 |
108 // A connector that provides a way to connect to a PersistentPrefStore. | 132 struct PrefRegistry { |
109 interface PersistentPrefStoreConnector { | 133 map<string, PrefRegistration> registrations; |
110 enum ReadError { | 134 }; |
111 NONE = 0, | |
112 JSON_PARSE = 1, | |
113 JSON_TYPE = 2, | |
114 ACCESS_DENIED = 3, | |
115 FILE_OTHER = 4, | |
116 FILE_LOCKED = 5, | |
117 NO_FILE = 6, | |
118 JSON_REPEAT = 7, | |
119 // OTHER = 8, // Deprecated. | |
120 FILE_NOT_SPECIFIED = 9, | |
121 ASYNCHRONOUS_TASK_INCOMPLETE = 10, | |
122 }; | |
123 | 135 |
124 // Connects to the PersistentPrefStore. | 136 struct OwningPrefRegistration { |
125 // A null |preferences| indicates that the pref service failed to load prefs. | 137 mojo.common.mojom.Value default_value; |
126 // |pref_store| provides write access; |observer| is used to observe writes | 138 uint32 flags; |
127 // instigated by other clients. | 139 }; |
128 [Sync] | 140 |
129 Connect() => ( | 141 union PrefRegistration { |
130 ReadError read_error, | 142 OwningPrefRegistration owning_registration; |
131 bool read_only, | |
132 mojo.common.mojom.DictionaryValue? preferences, | |
133 PersistentPrefStore? pref_store, | |
134 PrefStoreObserver&? observer); | |
135 }; | 143 }; |
136 | 144 |
137 interface PrefServiceControl { | 145 interface PrefServiceControl { |
138 // Initializes the pref service. This must be called before the service can | 146 // Initializes the pref service. This must be called before the service can |
139 // be used. | 147 // be used. |
140 Init(PersistentPrefStoreConfiguration configuration); | 148 Init(PersistentPrefStoreConfiguration configuration); |
141 }; | 149 }; |
OLD | NEW |