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

Side by Side Diff: content/common/leveldb_wrapper.mojom

Issue 2593503005: Don't abuse LevelDBObserver interface to pass GetAll result. (Closed)
Patch Set: modify sanity_check test to give async callbacks a chance to cause problems Created 3 years, 12 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
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 content.mojom; 5 module content.mojom;
6 6
7 import "components/leveldb/public/interfaces/leveldb.mojom"; 7 import "components/leveldb/public/interfaces/leveldb.mojom";
8 8
9 // Gives information about changes to a LevelDB database. 9 // Gives information about changes to a LevelDB database.
10 // Note that observer methods are called before the callbacks for the 10 // Note that observer methods are called before the callbacks for the
11 // LevelDBWrapper methods are run. 11 // LevelDBWrapper methods are run.
12 interface LevelDBObserver { 12 interface LevelDBObserver {
13 KeyAdded(array<uint8> key, array<uint8> value, string source); 13 KeyAdded(array<uint8> key, array<uint8> value, string source);
14 KeyChanged(array<uint8> key, array<uint8> new_value, array<uint8> old_value, 14 KeyChanged(array<uint8> key, array<uint8> new_value, array<uint8> old_value,
15 string source); 15 string source);
16 KeyDeleted(array<uint8> key, array<uint8> old_value, string source); 16 KeyDeleted(array<uint8> key, array<uint8> old_value, string source);
17 AllDeleted(string source); 17 AllDeleted(string source);
18
19 // Since the GetAll call is synchronous, observers need this asynchronously
20 // delivered notification to avoid applying changes to the returned array
21 // that it already contains.
22 GetAllComplete(string source);
23 }; 18 };
24 19
25 struct KeyValue { 20 struct KeyValue {
26 array<uint8> key; 21 array<uint8> key;
27 array<uint8> value; 22 array<uint8> value;
28 }; 23 };
29 24
25 // Since the GetAll call is synchronous, LevelDBWrapper users need this
26 // asynchronously delivered notification to avoid applying changes to the
27 // returned array that it already contains. This is not sent over the
28 // normal LevelDBObserver interface as there can be many observers and
29 // only the connection that made the GetAll call needs to be notified of
30 // its completion.
31 interface LevelDBWrapperGetAllCallback {
32 Complete(bool success);
33 };
34
30 // A wrapper around leveldb that supports giving notifications when values 35 // A wrapper around leveldb that supports giving notifications when values
31 // change. 36 // change.
32 interface LevelDBWrapper { 37 interface LevelDBWrapper {
33 AddObserver(associated LevelDBObserver observer); 38 AddObserver(associated LevelDBObserver observer);
34 39
35 // Sets the database entry for |key| to |value|. Returns OK on success. 40 // Sets the database entry for |key| to |value|. Returns OK on success.
36 Put(array<uint8> key, array<uint8> value, string source) => (bool success); 41 Put(array<uint8> key, array<uint8> value, string source) => (bool success);
37 42
38 // Remove the database entry (if any) for |key|. Returns OK on success, and a 43 // Remove the database entry (if any) for |key|. Returns OK on success, and a
39 // non-OK status on error. It is not an error if |key| did not exist in the 44 // non-OK status on error. It is not an error if |key| did not exist in the
40 // database. 45 // database.
41 Delete(array<uint8> key, string source) => (bool success); 46 Delete(array<uint8> key, string source) => (bool success);
42 47
43 // Removes all the entries. 48 // Removes all the entries.
44 DeleteAll(string source) => (bool success); 49 DeleteAll(string source) => (bool success);
45 50
46 // Returns the value of the |key|. 51 // Returns the value of the |key|.
47 Get(array<uint8> key) => (bool success, array<uint8> value); 52 Get(array<uint8> key) => (bool success, array<uint8> value);
48 53
49 // Only used with small databases. Returns all key/value pairs. 54 // Only used with small databases. Returns all key/value pairs.
50 [Sync] 55 [Sync]
51 GetAll(string source) 56 GetAll(associated LevelDBWrapperGetAllCallback complete_callback)
52 => (leveldb.mojom.DatabaseError status, array<KeyValue> data); 57 => (leveldb.mojom.DatabaseError status, array<KeyValue> data);
53 }; 58 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698