// 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.mojom; import "components/leveldb/public/interfaces/leveldb.mojom"; // Gives information about changes to a LevelDB database. // Note that observer methods are called before the callbacks for the // LevelDBWrapper methods are run. interface LevelDBObserver { KeyAdded(array key, array value, string source); KeyChanged(array key, array new_value, array old_value, string source); KeyDeleted(array key, array old_value, string source); AllDeleted(string source); }; struct KeyValue { array key; array value; }; // Since the GetAll call is synchronous, LevelDBWrapper users need this // asynchronously delivered notification to avoid applying changes to the // returned array that it already contains. This is not sent over the // normal LevelDBObserver interface as there can be many observers and // only the connection that made the GetAll call needs to be notified of // its completion. interface LevelDBWrapperGetAllCallback { Complete(bool success); }; // A wrapper around leveldb that supports giving notifications when values // change. interface LevelDBWrapper { AddObserver(associated LevelDBObserver observer); // Sets the database entry for |key| to |value|. Returns OK on success. Put(array key, array value, string source) => (bool success); // 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) => (bool success); // Removes all the entries. DeleteAll(string source) => (bool success); // Returns the value of the |key|. Get(array key) => (bool success, array value); // Only used with small databases. Returns all key/value pairs. [Sync] GetAll(associated LevelDBWrapperGetAllCallback complete_callback) => (leveldb.mojom.DatabaseError status, array data); };