Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: services/preferences/public/interfaces/preferences.mojom

Issue 2791893002: Pref service: Batch pref updates. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/preferences/public/cpp/tests/pref_store_client_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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";
11 const string kForwarderServiceName = "preferences_forwarder"; 11 const string kForwarderServiceName = "preferences_forwarder";
12 12
13 // The know pref store types. 13 // The know pref store types.
14 // 14 //
15 // Should be kept in sync with PrefValueStore::PrefStoreType. 15 // Should be kept in sync with PrefValueStore::PrefStoreType.
16 enum PrefStoreType { 16 enum PrefStoreType {
17 MANAGED, 17 MANAGED,
18 SUPERVISED_USER, 18 SUPERVISED_USER,
19 EXTENSION, 19 EXTENSION,
20 COMMAND_LINE, 20 COMMAND_LINE,
21 USER, 21 USER,
22 RECOMMENDED, 22 RECOMMENDED,
23 DEFAULT, 23 DEFAULT,
24 }; 24 };
25 25
26 // Allows observing changes to prefs stored in a |PrefStore|. 26 // Allows observing changes to prefs stored in a |PrefStore|.
27 interface PrefStoreObserver { 27 interface PrefStoreObserver {
28 // The preference with the given |key| has changed. If |value| is null then 28 // Preferences have been changed.
29 // the preference was deleted. 29 OnPrefsChanged(array<PrefUpdate> updates);
30 OnPrefChanged(string key, mojo.common.mojom.Value? value);
31 30
32 // The PrefStore has been initialized (asynchronously). 31 // The PrefStore has been initialized (asynchronously).
33 OnInitializationCompleted(bool succeeded); 32 OnInitializationCompleted(bool succeeded);
34 }; 33 };
35 34
36 // Captures the connections to a PrefStore by supplying the initial state of the 35 // Captures the connections to a PrefStore by supplying the initial state of the
37 // store and a handle to receive notifications on. 36 // store and a handle to receive notifications on.
38 struct PrefStoreConnection { 37 struct PrefStoreConnection {
39 // Handle to receive updates on. 38 // Handle to receive updates on.
40 PrefStoreObserver& observer; 39 PrefStoreObserver& observer;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // be received. The client asserts that it is already connected to the 92 // be received. The client asserts that it is already connected to the
94 // |already_connected_types| pref stores through some other means, so the 93 // |already_connected_types| pref stores through some other means, so the
95 // Connect call will not connect to those. 94 // Connect call will not connect to those.
96 [Sync] 95 [Sync]
97 Connect(PrefRegistry pref_registry, 96 Connect(PrefRegistry pref_registry,
98 array<PrefStoreType> already_connected_types) => 97 array<PrefStoreType> already_connected_types) =>
99 (PersistentPrefStoreConnection connection, 98 (PersistentPrefStoreConnection connection,
100 map<PrefStoreType, PrefStoreConnection> connections); 99 map<PrefStoreType, PrefStoreConnection> connections);
101 }; 100 };
102 101
102 // An update to a pref.
103 struct PrefUpdate {
104 // The key of the pref being updated.
105 string key;
106 // The new value; a null |value| indicates a delete.
107 mojo.common.mojom.Value? value;
108 //|flags| is a bitmask of WritablePrefStore::PrefWriteFlags.
109 uint32 flags;
110 };
111
103 // An interface providing mutation access to a PersistentPrefStore. 112 // An interface providing mutation access to a PersistentPrefStore.
104 interface PersistentPrefStore { 113 interface PersistentPrefStore {
105 // Sets the value for |key|. A null |value| indicates a delete. |flags| is a 114 // Sets the values for prefs.
106 // bitmask of WritablePrefStore::PrefWriteFlags. 115 SetValues(array<PrefUpdate> updates);
107 SetValue(string key, mojo.common.mojom.Value? value, uint32 flags);
108 116
109 // These mirror the C++ PersistentPrefStore methods. 117 // These mirror the C++ PersistentPrefStore methods.
110 CommitPendingWrite(); 118 CommitPendingWrite();
111 SchedulePendingLossyWrites(); 119 SchedulePendingLossyWrites();
112 ClearMutableValues(); 120 ClearMutableValues();
113 }; 121 };
114 122
115 // A registry of all prefs registered by a single client. 123 // A registry of all prefs registered by a single client.
116 struct PrefRegistry { 124 struct PrefRegistry {
117 map<string, PrefRegistration> registrations; 125 map<string, PrefRegistration> registrations;
118 }; 126 };
119 127
120 struct PrefRegistration { 128 struct PrefRegistration {
121 mojo.common.mojom.Value default_value; 129 mojo.common.mojom.Value default_value;
122 130
123 // A bitfield of flags. Flag values are defined in 131 // A bitfield of flags. Flag values are defined in
124 // PrefRegistry::PrefRegistrationFlags and 132 // PrefRegistry::PrefRegistrationFlags and
125 // PrefRegistrySyncable::PrefRegistrationFlags. 133 // PrefRegistrySyncable::PrefRegistrationFlags.
126 uint32 flags; 134 uint32 flags;
127 }; 135 };
128 136
129 interface PrefServiceControl { 137 interface PrefServiceControl {
130 // Initializes the pref service. This must be called before the service can 138 // Initializes the pref service. This must be called before the service can
131 // be used. 139 // be used.
132 Init(PersistentPrefStoreConfiguration configuration); 140 Init(PersistentPrefStoreConfiguration configuration);
133 }; 141 };
OLDNEW
« no previous file with comments | « services/preferences/public/cpp/tests/pref_store_client_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698