| // 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 blink.mojom; |
| |
| import "mojo/public/mojom/base/file_path.mojom"; |
| import "mojo/public/mojom/base/string16.mojom"; |
| import "mojo/public/mojom/base/string16.mojom"; |
| import "mojo/public/mojom/base/time.mojom"; |
| import "third_party/blink/public/mojom/blob/blob.mojom"; |
| import "url/mojom/origin.mojom"; |
| |
| // kIDBMaxMessageSize is 128MB, originally based on |
| // IPC::Channel::kMaximumMessageSize. The "usable" size is this value less |
| // the overhead size. |
| const int32 kIDBMaxMessageSize = 134217728; |
| |
| // kIDBMaxMessageOverhead is the size we expect to be used for the rest of |
| // the message we will send. The "usable" size is the max size less this value. |
| const int32 kIDBMaxMessageOverhead = 1048576; // 1MB; arbitrarily chosen. |
| |
| enum IDBCursorDirection { |
| Next, |
| NextNoDuplicate, |
| Prev, |
| PrevNoDuplicate, |
| }; |
| |
| enum IDBDataLoss { |
| None, |
| Total, |
| }; |
| |
| // In order of the least to the highest precedent in terms of sort order. |
| // These values are written to logs. New enum values can be added, but |
| // existing enums must never be renumbered or deleted and reused. |
| enum IDBKeyType { |
| Invalid, |
| Array, |
| Binary, |
| String, |
| Date, |
| Number, |
| Null, |
| Min, |
| }; |
| |
| union IDBKeyData { |
| array<IDBKey> key_array; |
| array<uint8> binary; |
| mojo_base.mojom.String16 string; |
| double date; |
| double number; |
| // TODO(jsbell): These types should be cleaned up end-to-end, leaving only the |
| // dataful options above. |
| bool other_invalid; |
| bool other_null; |
| }; |
| |
| // Defined as a structure so that it can by typemapped with StructTraits. |
| struct IDBKey { |
| IDBKeyData data; |
| }; |
| |
| // In order of the least to the highest precedent in terms of sort order. |
| // These values are written to logs. New enum values can be added, but |
| // existing enums must never be renumbered or deleted and reused. |
| enum IDBKeyPathType { |
| Null, |
| String, |
| Array, |
| }; |
| |
| // Represents WebIDBKeyPathTypeString and WebIDBKeyPathTypeArray in a key path. |
| union IDBKeyPathData { |
| mojo_base.mojom.String16 string; |
| array<mojo_base.mojom.String16> string_array; |
| }; |
| |
| struct IDBKeyPath { |
| // A null value here corresponds to WebIDBKeyPathTypeNull. |
| IDBKeyPathData? data; |
| }; |
| |
| struct IDBKeyRange { |
| IDBKey lower; |
| IDBKey upper; |
| bool lower_open; |
| bool upper_open; |
| }; |
| |
| enum IDBOperationType { |
| Add, |
| Put, |
| Delete, |
| Clear, |
| }; |
| |
| enum IDBPutMode { |
| AddOrUpdate, |
| AddOnly, |
| CursorUpdate, |
| }; |
| |
| enum IDBTaskType { |
| Normal, |
| Preemptive, |
| }; |
| |
| enum IDBTransactionMode { |
| ReadOnly, |
| ReadWrite, |
| VersionChange, |
| }; |
| |
| enum IDBStatus { |
| OK, |
| NotFound, |
| Corruption, |
| NotSupported, |
| InvalidArgument, |
| IOError, |
| }; |
| |
| struct IDBIndexMetadata { |
| int64 id; |
| mojo_base.mojom.String16 name; |
| IDBKeyPath key_path; |
| bool unique; |
| bool multi_entry; |
| }; |
| |
| struct IDBObjectStoreMetadata { |
| int64 id; |
| mojo_base.mojom.String16 name; |
| IDBKeyPath key_path; |
| bool auto_increment; |
| int64 max_index_id; |
| map<int64, IDBIndexMetadata> indexes; |
| }; |
| |
| struct IDBDatabaseMetadata { |
| int64 id; |
| mojo_base.mojom.String16 name; |
| int64 version; |
| int64 max_object_store_id; |
| map<int64, IDBObjectStoreMetadata> object_stores; |
| }; |
| |
| struct IDBNameAndVersion { |
| mojo_base.mojom.String16 name; |
| int64 version; |
| }; |
| |
| struct IDBIndexKeys { |
| int64 index_id; |
| array<IDBKey> index_keys; |
| }; |
| |
| struct IDBFileInfo { |
| mojo_base.mojom.FilePath path; |
| mojo_base.mojom.String16 name; |
| mojo_base.mojom.Time last_modified; |
| }; |
| |
| struct IDBBlobInfo { |
| blink.mojom.Blob blob; |
| string uuid; |
| mojo_base.mojom.String16 mime_type; |
| int64 size; |
| IDBFileInfo? file; |
| }; |
| |
| struct IDBValue { |
| array<uint8> bits; |
| array<IDBBlobInfo> blob_or_file_info; |
| }; |
| |
| struct IDBReturnValue { |
| IDBValue value; |
| IDBKey primary_key; |
| IDBKeyPath key_path; |
| }; |
| |
| struct IDBObservation { |
| int64 object_store_id; |
| IDBOperationType type; |
| IDBKeyRange key_range; |
| IDBValue? value; |
| }; |
| |
| struct IDBObserverTransaction { |
| int64 id; |
| array<int64> scope; |
| }; |
| |
| struct IDBObserverChanges { |
| map<int32, array<int32>> observation_index_map; |
| map<int32, IDBObserverTransaction> transaction_map; |
| array<IDBObservation> observations; |
| }; |
| |
| // The IDBCallbacks interface is used to return results for individual requests. |
| // Some requests may return multiple results before completion, such as |
| // UpgradeNeeded before SuccessDatabase. |
| // |
| // TODO(https://crbug.com/627484): Many of these could be replaced with |
| // replies associated with particular messages. |
| interface IDBCallbacks { |
| Error(int32 code, mojo_base.mojom.String16 message); |
| |
| // Factory::GetDatabaseInfo |
| SuccessNamesAndVersionsList(array<IDBNameAndVersion> value); |
| |
| // Factory::GetDatabaseNames |
| SuccessStringList(array<mojo_base.mojom.String16> value); |
| |
| // Factory::Open / DeleteDatabase |
| Blocked(int64 existing_version); |
| |
| // Factory::Open |
| UpgradeNeeded(associated IDBDatabase database, int64 old_version, |
| IDBDataLoss data_loss, string data_loss_message, |
| IDBDatabaseMetadata db_metadata); |
| SuccessDatabase(associated IDBDatabase? database, |
| IDBDatabaseMetadata metadata); |
| |
| // Database::OpenCursor |
| SuccessCursor(associated IDBCursor cursor, |
| IDBKey key, |
| IDBKey primary_key, |
| IDBValue? value); |
| |
| // Database::Get / Cursor::Advance |
| SuccessValue(IDBReturnValue? value); |
| |
| // Cursor::Continue / Advance |
| SuccessCursorContinue(IDBKey key, IDBKey primary_key, IDBValue? value); |
| |
| // Cursor::Prefetch |
| SuccessCursorPrefetch(array<IDBKey> keys, |
| array<IDBKey> primary_keys, |
| array<IDBValue> values); |
| |
| // Database::GetAll |
| SuccessArray(array<IDBReturnValue> values); |
| |
| // Database::Put / Cursor::Update |
| SuccessKey(IDBKey key); |
| |
| // Database::Count / DeleteRange |
| // Factory::DeleteDatabase |
| SuccessInteger(int64 value); |
| |
| // Cursor::Continue / Advance |
| Success(); |
| }; |
| |
| // The IDBDatabaseCallbacks interface is used to notification of events out of |
| // band to individual requests. A single instance is used for the lifetime of |
| // a database connection. |
| interface IDBDatabaseCallbacks { |
| ForcedClose(); |
| VersionChange(int64 old_version, int64 new_version); |
| Abort(int64 transaction_id, int32 code, |
| mojo_base.mojom.String16 message); |
| Complete(int64 transaction_id); |
| Changes(IDBObserverChanges changes); |
| }; |
| |
| struct IDBError { |
| int32 error_code; |
| mojo_base.mojom.String16 error_message; |
| }; |
| |
| struct IDBCursorValue { |
| IDBKey key; |
| IDBKey primary_key; |
| IDBValue value; |
| }; |
| |
| interface IDBCursor { |
| // Advance() can call its return callback in one of 3 ways: |
| // * with |error| set and |value| unset, if an error occurs |
| // * with |error| unset and |value| set, under normal operation |
| // * with |error| unset and |value| unset, under normal operation when the end |
| // of the source being iterated is reached |
| Advance(uint32 count) => (IDBError? error, IDBCursorValue? value); |
| |
| // Avoid calling the following function "Continue" since the Mojo |
| // Java bindings generate incorrect Java as a result. We've named |
| // the following function "CursorContinue" as a workaround. |
| CursorContinue(IDBKey key, |
| IDBKey primary_key, |
| associated IDBCallbacks callbacks); |
| Prefetch(int32 count, associated IDBCallbacks callbacks); |
| PrefetchReset(int32 used_prefetches, int32 unused_prefetches); |
| }; |
| |
| interface IDBDatabase { |
| CreateObjectStore(int64 transaction_id, |
| int64 object_store_id, |
| mojo_base.mojom.String16 name, |
| IDBKeyPath key_path, |
| bool auto_increment); |
| DeleteObjectStore(int64 transaction_id, |
| int64 object_store_id); |
| RenameObjectStore(int64 transaction_id, |
| int64 object_store_id, |
| mojo_base.mojom.String16 new_name); |
| CreateTransaction(int64 transaction_id, |
| array<int64> object_store_ids, |
| IDBTransactionMode mode); |
| Close(); |
| VersionChangeIgnored(); |
| AddObserver(int64 transaction_id, |
| int32 observer_id, |
| bool include_transaction, |
| bool no_records, |
| bool values, |
| uint32 operation_types); |
| RemoveObservers(array<int32> observers); |
| Get(int64 transaction_id, |
| int64 object_store_id, |
| int64 index_id, |
| IDBKeyRange key_range, |
| bool key_only, |
| associated IDBCallbacks callbacks); |
| GetAll(int64 transaction_id, |
| int64 object_store_id, |
| int64 index_id, |
| IDBKeyRange key_range, |
| bool key_only, |
| int64 max_count, |
| associated IDBCallbacks callbacks); |
| Put(int64 transaction_id, |
| int64 object_store_id, |
| IDBValue value, |
| IDBKey key, |
| IDBPutMode mode, |
| array<IDBIndexKeys> index_keys, |
| associated IDBCallbacks callbacks); |
| SetIndexKeys(int64 transaction_id, |
| int64 object_store_id, |
| IDBKey primary_key, |
| array<IDBIndexKeys> index_keys); |
| SetIndexesReady(int64 transaction_id, |
| int64 object_store_id, |
| array<int64> index_ids); |
| OpenCursor(int64 transaction_id, |
| int64 object_store_id, |
| int64 index_id, |
| IDBKeyRange key_range, |
| IDBCursorDirection direction, |
| bool key_only, |
| IDBTaskType task_type, |
| associated IDBCallbacks callbacks); |
| Count(int64 transaction_id, |
| int64 object_store_id, |
| int64 index_id, |
| IDBKeyRange key_range, |
| associated IDBCallbacks callbacks); |
| DeleteRange(int64 transaction_id, |
| int64 object_store_id, |
| IDBKeyRange key_range, |
| associated IDBCallbacks callbacks); |
| Clear(int64 transaction_id, |
| int64 object_store_id, |
| associated IDBCallbacks callbacks); |
| CreateIndex(int64 transaction_id, |
| int64 object_store_id, |
| int64 index_id, |
| mojo_base.mojom.String16 name, |
| IDBKeyPath key_path, |
| bool unique, |
| bool multi_entry); |
| DeleteIndex(int64 transaction_id, |
| int64 object_store_id, |
| int64 index_id); |
| RenameIndex(int64 transaction_id, |
| int64 object_store_id, |
| int64 index_id, |
| mojo_base.mojom.String16 new_name); |
| Abort(int64 transaction_id); |
| Commit(int64 transaction_id); |
| }; |
| |
| interface IDBFactory { |
| GetDatabaseInfo(associated IDBCallbacks callbacks); |
| GetDatabaseNames(associated IDBCallbacks callbacks); |
| Open(associated IDBCallbacks callbacks, |
| associated IDBDatabaseCallbacks database_callbacks, |
| mojo_base.mojom.String16 name, |
| int64 version, |
| int64 transaction_id); |
| DeleteDatabase(associated IDBCallbacks callbacks, |
| mojo_base.mojom.String16 name, bool force_close); |
| AbortTransactionsAndCompactDatabase() => (IDBStatus status); |
| AbortTransactionsForDatabase() => (IDBStatus status); |
| }; |