| Index: content/browser/indexed_db/database_impl.h
|
| diff --git a/content/browser/indexed_db/database_impl.h b/content/browser/indexed_db/database_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b23dca44e3fd5c9df2431d9785e1682d2262a927
|
| --- /dev/null
|
| +++ b/content/browser/indexed_db/database_impl.h
|
| @@ -0,0 +1,184 @@
|
| +// 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.
|
| +
|
| +#ifndef CONTENT_BROWSER_INDEXED_DB_DATABASE_IMPL_H_
|
| +#define CONTENT_BROWSER_INDEXED_DB_DATABASE_IMPL_H_
|
| +
|
| +#include "base/id_map.h"
|
| +#include "base/macros.h"
|
| +#include "content/browser/bad_message.h"
|
| +#include "content/public/browser/browser_context.h"
|
| +#include "mojo/public/cpp/bindings/strong_binding.h"
|
| +#include "third_party/WebKit/public/platform/modules/indexeddb/indexed_db.mojom.h"
|
| +
|
| +namespace content {
|
| +class IndexedDBConnection;
|
| +class IndexedDBContext;
|
| +}
|
| +
|
| +namespace indexed_db {
|
| +
|
| +class DatabaseImpl : public mojom::Database {
|
| + public:
|
| + DatabaseImpl(content::BrowserContext* context,
|
| + content::IndexedDBContext* indexed_db_context,
|
| + mojom::DatabaseRequest request);
|
| + ~DatabaseImpl() override;
|
| +
|
| + static void Create(content::BrowserContext* context,
|
| + mojom::DatabaseRequest request);
|
| +
|
| + private:
|
| + // IDMap for RefCounted types
|
| + template <typename RefCountedType>
|
| + class RefIDMap {
|
| + public:
|
| + typedef int32_t KeyType;
|
| +
|
| + RefIDMap() {}
|
| + ~RefIDMap() {}
|
| +
|
| + KeyType Add(RefCountedType* data) {
|
| + return map_.Add(new scoped_refptr<RefCountedType>(data));
|
| + }
|
| +
|
| + RefCountedType* Lookup(KeyType id) {
|
| + scoped_refptr<RefCountedType>* ptr = map_.Lookup(id);
|
| + if (ptr == NULL)
|
| + return NULL;
|
| + return ptr->get();
|
| + }
|
| +
|
| + void Remove(KeyType id) { map_.Remove(id); }
|
| +
|
| + void set_check_on_null_data(bool value) {
|
| + map_.set_check_on_null_data(value);
|
| + }
|
| +
|
| + private:
|
| + IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RefIDMap);
|
| + };
|
| +
|
| + // mojom::Database:
|
| + void CreateObjectStore(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + const mojo::String& name,
|
| + const ::content::IndexedDBKeyPath& key_path,
|
| + bool auto_increment) override;
|
| +
|
| + void DeleteObjectStore(int64_t transaction_id,
|
| + int64_t object_store_id) override;
|
| +
|
| + void CreateTransaction(int64_t id,
|
| + mojo::Array<int64_t> scope,
|
| + mojom::TransactionMode transaction_mode) override;
|
| +
|
| + void Close() override;
|
| +
|
| + void VersionChangeIgnored() override;
|
| +
|
| + void Abort(int64_t transaction_id) override;
|
| +
|
| + void Commit(int64_t transaction_id) override;
|
| +
|
| + void CreateIndex(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + const mojo::String& name,
|
| + const ::content::IndexedDBKeyPath& key_path,
|
| + bool unique,
|
| + bool multi_entry) override;
|
| +
|
| + void DeleteIndex(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id) override;
|
| +
|
| + void Get(int64_t database_id,
|
| + int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + mojom::KeyRangePtr key_range,
|
| + bool key_only,
|
| + const GetCallback& callback) override;
|
| +
|
| + void GetAll(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + mojom::KeyRangePtr key_range,
|
| + int64_t max_count,
|
| + bool key_only) override;
|
| +
|
| + void Put(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + mojo::Array<int8_t> value,
|
| + mojo::Array<mojom::BlobInfoPtr> blob_info,
|
| + mojom::KeyPtr key,
|
| + mojom::PutMode put_mode,
|
| + mojo::Array<int64_t> index_ids,
|
| + mojo::Array<mojo::Array<mojom::KeyPtr>> index_keys) override;
|
| +
|
| + void DeleteRange(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + mojom::KeyRangePtr key_range) override;
|
| +
|
| + void Clear(int64_t transaction_id, int64_t object_store_id) override;
|
| +
|
| + void SetIndexKeys(
|
| + int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + mojom::KeyPtr primary_key,
|
| + mojo::Array<int64_t> index_ids,
|
| + mojo::Array<mojo::Array<mojom::KeyPtr>> index_keys) override;
|
| +
|
| + void SetIndexesReady(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + mojo::Array<int64_t> index_ids) override;
|
| +
|
| + void OpenCursor(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + mojom::KeyRangePtr key_range,
|
| + mojom::CursorDirection direction,
|
| + bool key_only,
|
| + mojom::TaskType task_type) override;
|
| +
|
| + void Count(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + mojom::KeyRangePtr key_range) override;
|
| +
|
| + void AckReceivedBlobs(mojo::Array<mojo::String> uuids) override;
|
| +
|
| + void CrashRendererAndClosePipe(content::bad_message::BadMessageReason reason);
|
| +
|
| + content::RenderProcessHost* GetRenderProcessHost();
|
| +
|
| +#if 0
|
| + int64_t HostTransactionId(int64_t transaction_id);
|
| +#endif
|
| +
|
| + // Helper templates.
|
| + template <class ReturnType>
|
| + ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
|
| + int32_t ipc_return_object_id);
|
| + template <class ReturnType>
|
| + ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
|
| + int32_t ipc_return_object_id);
|
| +
|
| + template <typename MapType>
|
| + void DestroyObject(MapType* map, int32_t ipc_object_id);
|
| +
|
| + content::BrowserContext* context_;
|
| + scoped_refptr<content::IndexedDBContext> indexed_db_context_;
|
| + IDMap<content::IndexedDBConnection, IDMapOwnPointer> connection_map_;
|
| + mojo::StrongBinding<mojom::Database> binding_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DatabaseImpl);
|
| +};
|
| +
|
| +} // namespace indexed_db
|
| +
|
| +#endif // CONTENT_BROWSER_INDEXED_DB_DATABASE_IMPL_H_
|
|
|