| 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..e599aa65c00e97a7773a61d354125be7cd9c0da4
|
| --- /dev/null
|
| +++ b/content/browser/indexed_db/database_impl.h
|
| @@ -0,0 +1,186 @@
|
| +// 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 <string>
|
| +#include <vector>
|
| +
|
| +#include "Source/modules/indexeddb/indexed_db.mojom.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"
|
| +
|
| +namespace content {
|
| +
|
| +class IndexedDBConnection;
|
| +class IndexedDBContext;
|
| +
|
| +class DatabaseImpl : public indexed_db::mojom::Database {
|
| + public:
|
| + DatabaseImpl(BrowserContext* context,
|
| + IndexedDBContext* indexed_db_context,
|
| + indexed_db::mojom::DatabaseRequest request);
|
| + ~DatabaseImpl() override;
|
| +
|
| + static void Create(BrowserContext* context,
|
| + indexed_db::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);
|
| + };
|
| +
|
| + // indexed_db::mojom::Database:
|
| + void CreateObjectStore(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + const std::string& name,
|
| + const IndexedDBKeyPath& key_path,
|
| + bool auto_increment) override;
|
| +
|
| + void DeleteObjectStore(int64_t transaction_id,
|
| + int64_t object_store_id) override;
|
| +
|
| + void CreateTransaction(
|
| + int64_t id,
|
| + const std::vector<int64_t>& scope,
|
| + indexed_db::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 std::string& name,
|
| + const 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 transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + indexed_db::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,
|
| + indexed_db::mojom::KeyRangePtr key_range,
|
| + int64_t max_count,
|
| + bool key_only) override;
|
| +
|
| + void Put(
|
| + int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + const std::vector<int8_t>& value,
|
| + std::vector<indexed_db::mojom::BlobInfoPtr> blob_info,
|
| + indexed_db::mojom::KeyPtr key,
|
| + indexed_db::mojom::PutMode put_mode,
|
| + const std::vector<int64_t>& index_ids,
|
| + std::vector<std::vector<indexed_db::mojom::KeyPtr>> index_keys) override;
|
| +
|
| + void DeleteRange(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + indexed_db::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,
|
| + indexed_db::mojom::KeyPtr primary_key,
|
| + const std::vector<int64_t>& index_ids,
|
| + std::vector<std::vector<indexed_db::mojom::KeyPtr>> index_keys) override;
|
| +
|
| + void SetIndexesReady(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + const std::vector<int64_t>& index_ids) override;
|
| +
|
| + void OpenCursor(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + indexed_db::mojom::KeyRangePtr key_range,
|
| + indexed_db::mojom::CursorDirection direction,
|
| + bool key_only,
|
| + indexed_db::mojom::TaskType task_type) override;
|
| +
|
| + void Count(int64_t transaction_id,
|
| + int64_t object_store_id,
|
| + int64_t index_id,
|
| + indexed_db::mojom::KeyRangePtr key_range) override;
|
| +
|
| + void AckReceivedBlobs(const std::vector<std::string>& uuids) override;
|
| +
|
| + void CrashRendererAndClosePipe(bad_message::BadMessageReason reason);
|
| +
|
| + 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);
|
| +
|
| + BrowserContext* context_;
|
| + scoped_refptr<IndexedDBContext> indexed_db_context_;
|
| + IDMap<IndexedDBConnection, IDMapOwnPointer> connection_map_;
|
| + mojo::StrongBinding<indexed_db::mojom::Database> binding_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DatabaseImpl);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_INDEXED_DB_DATABASE_IMPL_H_
|
|
|