// Copyright 2016 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. module content; import "components/leveldb/public/interfaces/leveldb.mojom"; // Gives information about changes to a LevelDB database. // The reason this is a parameter to DeleteAll and GetAll below, instead of // being specified when opening a LevelDBWrapper, is to avoid the client getting // callbacks for changes that have already been applied to its database that // it's fetching via GetAll or it's clearing via DeleteAll. interface LevelDBObserver { KeyChanged(array key, array new_value, array old_value, string source); KeyDeleted(array key, string source); AllDeleted(string source); }; struct KeyValue { array key; array value; }; // A wrapper around leveldb that supports giving notifications when values // change. interface LevelDBWrapper { // Sets the database entry for "key" to "value". Returns OK on success. Put(array key, array value, string source) => (leveldb.DatabaseError status); // Remove the database entry (if any) for "key". Returns OK on // success, and a non-OK status on error. It is not an error if "key" // did not exist in the database. Delete(array key, string source) => (leveldb.DatabaseError status); // Removes all the entries. DeleteAll(LevelDBObserver observer, string source) => (leveldb.DatabaseError status); // Returns the value of the given key. Get(array key) => (leveldb.DatabaseError status, array value); // Only used with small databases. Returns all key/value pairs. [Sync] GetAll(LevelDBObserver observer) => (leveldb.DatabaseError status, array data); };