Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: content/browser/indexed_db/indexed_db_database_impl.h

Issue 15564008: Migrate the IndexedDB backend from Blink to Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update to ToT again Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_database_impl.h
diff --git a/content/browser/indexed_db/indexed_db_database_impl.h b/content/browser/indexed_db/indexed_db_database_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..d71cf0e728564940860baf156d0bdd5a9a4caf4c
--- /dev/null
+++ b/content/browser/indexed_db/indexed_db_database_impl.h
@@ -0,0 +1,204 @@
+// Copyright (c) 2013 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_INDEXED_DB_DATABASE_IMPL_H_
+#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_IMPL_H_
+
+#include <list>
+#include <map>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h"
+#include "content/browser/indexed_db/indexed_db_metadata.h"
+#include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
+#include "content/browser/indexed_db/list_set.h"
+
+namespace content {
+
+class IndexedDBBackingStore;
+class IndexedDBDatabase;
+class IndexedDBFactoryImpl;
+class IndexedDBTransaction;
+
+class IndexedDBDatabaseImpl : public IndexedDBDatabase {
+ public:
+ static scoped_refptr<IndexedDBDatabaseImpl> Create(
+ const string16& name,
+ IndexedDBBackingStore* database,
+ IndexedDBFactoryImpl* factory,
+ const string16& unique_identifier);
+ scoped_refptr<IndexedDBBackingStore> BackingStore() const;
+
+ static const int64 kInvalidId = 0;
+ int64 id() const { return metadata_.id; }
+ void AddObjectStore(const IndexedDBObjectStoreMetadata& metadata,
+ int64 new_max_object_store_id);
+ void RemoveObjectStore(int64 object_store_id);
+ void AddIndex(int64 object_store_id,
+ const IndexedDBIndexMetadata& metadata,
+ int64 new_max_index_id);
+ void RemoveIndex(int64 object_store_id, int64 index_id);
+
+ void OpenConnection(
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks,
+ int64 transaction_id,
+ int64 version);
+ void DeleteDatabase(scoped_refptr<IndexedDBCallbacksWrapper> callbacks);
+ const IndexedDBDatabaseMetadata& metadata() const { return metadata_; }
+
+ // IndexedDBDatabase
+ virtual void CreateObjectStore(int64 transaction_id,
+ int64 object_store_id,
+ const string16& name,
+ const IndexedDBKeyPath& key_path,
+ bool auto_increment) OVERRIDE;
+ virtual void DeleteObjectStore(int64 transaction_id, int64 object_store_id)
+ OVERRIDE;
+ virtual void CreateTransaction(
+ int64 transaction_id,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks,
+ const std::vector<int64>& object_store_ids,
+ uint16 mode) OVERRIDE;
+ virtual void Close(scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks)
+ OVERRIDE;
+
+ virtual void Commit(int64 transaction_id) OVERRIDE;
+ virtual void Abort(int64 transaction_id) OVERRIDE;
+ virtual void Abort(int64 transaction_id,
+ scoped_refptr<IndexedDBDatabaseError> error) OVERRIDE;
+
+ virtual void CreateIndex(int64 transaction_id,
+ int64 object_store_id,
+ int64 index_id,
+ const string16& name,
+ const IndexedDBKeyPath& key_path,
+ bool unique,
+ bool multi_entry) OVERRIDE;
+ virtual void DeleteIndex(int64 transaction_id,
+ int64 object_store_id,
+ int64 index_id) OVERRIDE;
+
+ IndexedDBTransactionCoordinator& transaction_coordinator() {
+ return transaction_coordinator_;
+ }
+
+ void TransactionStarted(IndexedDBTransaction* transaction);
+ void TransactionFinished(IndexedDBTransaction* transaction);
+ void TransactionFinishedAndCompleteFired(IndexedDBTransaction* transaction);
+ void TransactionFinishedAndAbortFired(IndexedDBTransaction* transaction);
+
+ virtual void Get(int64 transaction_id,
+ int64 object_store_id,
+ int64 index_id,
+ scoped_ptr<IndexedDBKeyRange> key_range,
+ bool key_only,
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks) OVERRIDE;
+ virtual void Put(int64 transaction_id,
+ int64 object_store_id,
+ std::vector<char>* value,
+ scoped_ptr<IndexedDBKey> key,
+ PutMode mode,
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks,
+ const std::vector<int64>& index_ids,
+ const std::vector<IndexKeys>& index_keys) OVERRIDE;
+ virtual void SetIndexKeys(int64 transaction_id,
+ int64 object_store_id,
+ scoped_ptr<IndexedDBKey> primary_key,
+ const std::vector<int64>& index_ids,
+ const std::vector<IndexKeys>& index_keys) OVERRIDE;
+ virtual void SetIndexesReady(int64 transaction_id,
+ int64 object_store_id,
+ const std::vector<int64>& index_ids) OVERRIDE;
+ virtual void OpenCursor(int64 transaction_id,
+ int64 object_store_id,
+ int64 index_id,
+ scoped_ptr<IndexedDBKeyRange> key_range,
+ indexed_db::CursorDirection,
+ bool key_only,
+ TaskType task_type,
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks)
+ OVERRIDE;
+ virtual void Count(int64 transaction_id,
+ int64 object_store_id,
+ int64 index_id,
+ scoped_ptr<IndexedDBKeyRange> key_range,
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks)
+ OVERRIDE;
+ virtual void DeleteRange(int64 transaction_id,
+ int64 object_store_id,
+ scoped_ptr<IndexedDBKeyRange> key_range,
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks)
+ OVERRIDE;
+ virtual void Clear(int64 transaction_id,
+ int64 object_store_id,
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks)
+ OVERRIDE;
+
+ private:
+ IndexedDBDatabaseImpl(const string16& name,
+ IndexedDBBackingStore* database,
+ IndexedDBFactoryImpl* factory,
+ const string16& unique_identifier);
+ virtual ~IndexedDBDatabaseImpl();
+
+ bool IsOpenConnectionBlocked() const;
+ bool OpenInternal();
+ void RunVersionChangeTransaction(
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks,
+ int64 transaction_id,
+ int64 requested_version);
+ void RunVersionChangeTransactionFinal(
+ scoped_refptr<IndexedDBCallbacksWrapper> callbacks,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks,
+ int64 transaction_id,
+ int64 requested_version);
+ size_t ConnectionCount() const;
+ void ProcessPendingCalls();
+
+ bool IsDeleteDatabaseBlocked() const;
+ void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacksWrapper> callbacks);
+
+ class VersionChangeOperation;
+
+ // When a "versionchange" transaction aborts, these restore the back-end
+ // object hierarchy.
+ class VersionChangeAbortOperation;
+
+ scoped_refptr<IndexedDBBackingStore> backing_store_;
+ IndexedDBDatabaseMetadata metadata_;
+
+ string16 identifier_;
+ // This might not need to be a scoped_refptr since the factory's lifetime is
+ // that of the page group, but it's better to be conservitive than sorry.
+ scoped_refptr<IndexedDBFactoryImpl> factory_;
+
+ IndexedDBTransactionCoordinator transaction_coordinator_;
+ IndexedDBTransaction* running_version_change_transaction_;
+
+ typedef std::map<int64, IndexedDBTransaction*> TransactionMap;
+ TransactionMap transactions_;
+
+ class PendingOpenCall;
+ typedef std::list<PendingOpenCall*> PendingOpenCallList;
+ PendingOpenCallList pending_open_calls_;
+ scoped_ptr<PendingOpenCall> pending_run_version_change_transaction_call_;
+ scoped_ptr<PendingOpenCall> pending_second_half_open_;
+
+ class PendingDeleteCall;
+ typedef std::list<PendingDeleteCall*> PendingDeleteCallList;
+ PendingDeleteCallList pending_delete_calls_;
+
+ typedef list_set<scoped_refptr<IndexedDBDatabaseCallbacksWrapper> >
+ DatabaseCallbacksSet;
+ DatabaseCallbacksSet database_callbacks_set_;
+
+ bool closing_connection_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_IMPL_H_
« no previous file with comments | « content/browser/indexed_db/indexed_db_database_error.h ('k') | content/browser/indexed_db/indexed_db_database_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698