1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <list> 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <map> 107dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include <string> 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <utility> 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <vector> 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/basictypes.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/ref_counted.h" 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db.h" 1758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "content/browser/indexed_db/indexed_db_backing_store.h" 18eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "content/browser/indexed_db/indexed_db_callbacks.h" 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_metadata.h" 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_pending_connection.h" 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/list_set.h" 23116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "third_party/WebKit/public/platform/WebIDBTypes.h" 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "url/gurl.h" 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content { 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 280529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochclass IndexedDBBlobInfo; 29eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass IndexedDBConnection; 30eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass IndexedDBDatabaseCallbacks; 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBFactory; 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBKey; 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBKeyPath; 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBKeyRange; 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBTransaction; 3623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)struct IndexedDBValue; 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class CONTENT_EXPORT IndexedDBDatabase 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBDatabase>) { 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public: 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // An index and corresponding set of keys 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) typedef std::pair<int64, std::vector<IndexedDBKey> > IndexKeys; 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Identifier is pair of (origin url, database name). 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) typedef std::pair<GURL, base::string16> Identifier; 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) static const int64 kInvalidId = 0; 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) static const int64 kMinimumIndexId = 30; 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) static scoped_refptr<IndexedDBDatabase> Create( 51a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& name, 52424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) IndexedDBBackingStore* backing_store, 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBFactory* factory, 540529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch const Identifier& unique_identifier, 550529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch leveldb::Status* s); 56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const Identifier& identifier() const { return identifier_; } 581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) IndexedDBBackingStore* backing_store() { return backing_store_.get(); } 5958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 id() const { return metadata_.id; } 61ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const base::string16& name() const { return metadata_.name; } 62ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void AddObjectStore(const IndexedDBObjectStoreMetadata& metadata, 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 new_max_object_store_id); 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void RemoveObjectStore(int64 object_store_id); 66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void AddIndex(int64 object_store_id, 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const IndexedDBIndexMetadata& metadata, 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 new_max_index_id); 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void RemoveIndex(int64 object_store_id, int64 index_id); 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void OpenConnection(const IndexedDBPendingConnection& connection); 72eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void DeleteDatabase(scoped_refptr<IndexedDBCallbacks> callbacks); 73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const IndexedDBDatabaseMetadata& metadata() const { return metadata_; } 74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void CreateObjectStore(int64 transaction_id, 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& name, 78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const IndexedDBKeyPath& key_path, 79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool auto_increment); 80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void DeleteObjectStore(int64 transaction_id, int64 object_store_id); 81eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void CreateTransaction(int64 transaction_id, 82eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch IndexedDBConnection* connection, 83eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const std::vector<int64>& object_store_ids, 84116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch blink::WebIDBTransactionMode mode); 8558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void Close(IndexedDBConnection* connection, bool forced); 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void ForceClose(); 87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 88116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Ack that one of the connections notified with a "versionchange" event did 89116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // not promptly close. Therefore a "blocked" event should be fired at the 90116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // pending connection. 91116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void VersionChangeIgnored(); 92116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Commit(int64 transaction_id); 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Abort(int64 transaction_id); 95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Abort(int64 transaction_id, const IndexedDBDatabaseError& error); 96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void CreateIndex(int64 transaction_id, 98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 index_id, 100a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& name, 101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const IndexedDBKeyPath& key_path, 102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool unique, 103868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool multi_entry); 104868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void DeleteIndex(int64 transaction_id, int64 object_store_id, int64 index_id); 105868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 106868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBTransactionCoordinator& transaction_coordinator() { 107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return transaction_coordinator_; 108868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 109ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const IndexedDBTransactionCoordinator& transaction_coordinator() const { 110ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch return transaction_coordinator_; 111ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch } 112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void TransactionCreated(IndexedDBTransaction* transaction); 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void TransactionFinished(IndexedDBTransaction* transaction, bool committed); 115868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 1161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Called by transactions to report failure committing to the backing store. 117116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void TransactionCommitFailed(const leveldb::Status& status); 1181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Get(int64 transaction_id, 120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 index_id, 122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBKeyRange> key_range, 123868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool key_only, 124eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks); 125868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Put(int64 transaction_id, 126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 12723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) IndexedDBValue* value, 12803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) ScopedVector<storage::BlobDataHandle>* handles, 129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBKey> key, 130116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch blink::WebIDBPutMode mode, 131eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks, 132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const std::vector<IndexKeys>& index_keys); 133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void SetIndexKeys(int64 transaction_id, 134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBKey> primary_key, 136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const std::vector<IndexKeys>& index_keys); 137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void SetIndexesReady(int64 transaction_id, 138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 139868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const std::vector<int64>& index_ids); 140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void OpenCursor(int64 transaction_id, 141868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 142868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 index_id, 143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBKeyRange> key_range, 144116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch blink::WebIDBCursorDirection, 145868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool key_only, 146116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch blink::WebIDBTaskType task_type, 147eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks); 148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Count(int64 transaction_id, 149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 index_id, 151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBKeyRange> key_range, 152eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks); 153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void DeleteRange(int64 transaction_id, 154868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 155868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBKeyRange> key_range, 156eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks); 157868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Clear(int64 transaction_id, 158868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 object_store_id, 159eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks); 160868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 161ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Number of connections that have progressed passed initial open call. 162ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch size_t ConnectionCount() const; 163ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Number of open calls that are blocked on other connections. 164ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch size_t PendingOpenCount() const; 165ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Number of pending upgrades (0 or 1). Also included in ConnectionCount(). 166ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch size_t PendingUpgradeCount() const; 167ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Number of running upgrades (0 or 1). Also included in ConnectionCount(). 168ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch size_t RunningUpgradeCount() const; 169ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Number of pending deletes, blocked on other connections. 170ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch size_t PendingDeleteCount() const; 171ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 1723551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Asynchronous tasks scheduled within transactions: 1733551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void CreateObjectStoreAbortOperation(int64 object_store_id, 1743551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 1753551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void DeleteObjectStoreOperation( 176cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int64 object_store_id, 1773551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 1783551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void DeleteObjectStoreAbortOperation( 1793551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) const IndexedDBObjectStoreMetadata& object_store_metadata, 1803551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 1813551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void VersionChangeOperation(int64 version, 1823551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 1833551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_ptr<IndexedDBConnection> connection, 1843551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 185a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void VersionChangeAbortOperation(const base::string16& previous_version, 1863551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) int64 previous_int_version, 1873551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 1883551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void DeleteIndexOperation(int64 object_store_id, 189cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int64 index_id, 1903551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 1913551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void CreateIndexAbortOperation(int64 object_store_id, 1923551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) int64 index_id, 1933551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 1943551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void DeleteIndexAbortOperation(int64 object_store_id, 1953551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) const IndexedDBIndexMetadata& index_metadata, 1963551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 1973551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void GetOperation(int64 object_store_id, 1983551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) int64 index_id, 1993551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_ptr<IndexedDBKeyRange> key_range, 2003551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) indexed_db::CursorType cursor_type, 2013551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 2023551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 2033551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) struct PutOperationParams; 2043551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void PutOperation(scoped_ptr<PutOperationParams> params, 2053551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 2063551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void SetIndexesReadyOperation(size_t index_count, 2073551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 2083551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) struct OpenCursorOperationParams; 2093551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void OpenCursorOperation(scoped_ptr<OpenCursorOperationParams> params, 2103551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 2113551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void CountOperation(int64 object_store_id, 2123551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) int64 index_id, 2133551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_ptr<IndexedDBKeyRange> key_range, 2143551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 2153551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 2163551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void DeleteRangeOperation(int64 object_store_id, 2173551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_ptr<IndexedDBKeyRange> key_range, 2183551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 2193551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 2203551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void ClearOperation(int64 object_store_id, 2213551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 2223551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 2233551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 224868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 225868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) friend class base::RefCounted<IndexedDBDatabase>; 226868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 2271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci class PendingDeleteCall; 2281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci class PendingSuccessCall; 2291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci class PendingUpgradeCall; 2301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci typedef std::map<int64, IndexedDBTransaction*> TransactionMap; 2321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci typedef std::list<IndexedDBPendingConnection> PendingOpenCallList; 2331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci typedef std::list<PendingDeleteCall*> PendingDeleteCallList; 2341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci typedef list_set<IndexedDBConnection*> ConnectionSet; 2351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 236a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) IndexedDBDatabase(const base::string16& name, 237424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) IndexedDBBackingStore* backing_store, 2383551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBFactory* factory, 2393551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) const Identifier& unique_identifier); 240868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ~IndexedDBDatabase(); 241868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 242868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool IsOpenConnectionBlocked() const; 243a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) leveldb::Status OpenInternal(); 244eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void RunVersionChangeTransaction(scoped_refptr<IndexedDBCallbacks> callbacks, 245eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_ptr<IndexedDBConnection> connection, 246eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch int64 transaction_id, 2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int64 requested_version); 248eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void RunVersionChangeTransactionFinal( 249eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks, 250eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_ptr<IndexedDBConnection> connection, 251868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 transaction_id, 252868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 requested_version); 253868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void ProcessPendingCalls(); 254868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 255868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool IsDeleteDatabaseBlocked() const; 256eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacks> callbacks); 257868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 258a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<IndexedDBConnection> CreateConnection( 259a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 260a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int child_process_id); 261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 2627dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch IndexedDBTransaction* GetTransaction(int64 transaction_id) const; 2637dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 2647dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch bool ValidateObjectStoreId(int64 object_store_id) const; 2657dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch bool ValidateObjectStoreIdAndIndexId(int64 object_store_id, 2667dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch int64 index_id) const; 2677dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch bool ValidateObjectStoreIdAndOptionalIndexId(int64 object_store_id, 2687dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch int64 index_id) const; 2697dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch bool ValidateObjectStoreIdAndNewIndexId(int64 object_store_id, 2707dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch int64 index_id) const; 2717dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 272868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_refptr<IndexedDBBackingStore> backing_store_; 273868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBDatabaseMetadata metadata_; 274868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 275ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const Identifier identifier_; 276868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_refptr<IndexedDBFactory> factory_; 277868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 278868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBTransactionCoordinator transaction_coordinator_; 279868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 280868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) TransactionMap transactions_; 281868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PendingOpenCallList pending_open_calls_; 282eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_ptr<PendingUpgradeCall> pending_run_version_change_transaction_call_; 283eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_ptr<PendingSuccessCall> pending_second_half_open_; 284868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PendingDeleteCallList pending_delete_calls_; 285868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 286eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ConnectionSet connections_; 287f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 288f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabase); 289868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}; 290868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 291868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace content 292868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 293868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ 294