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

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: Coding style fixes 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..afe11015f242ba2e0cd2a90bf4d4c7abbe41a28f
--- /dev/null
+++ b/content/browser/indexed_db/indexed_db_database_impl.h
@@ -0,0 +1,197 @@
+// 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 "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*,
+ const string16& unique_identifier);
+ scoped_refptr<IndexedDBBackingStore> BackingStore() const;
+
+ static const int64_t kInvalidId = 0;
+ int64_t id() const { return metadata_.id; }
+ void AddObjectStore(const IndexedDBObjectStoreMetadata&,
+ int64_t new_max_object_store_id);
+ void RemoveObjectStore(int64_t object_store_id);
+ void AddIndex(int64_t object_store_id,
+ const IndexedDBIndexMetadata&,
+ int64_t new_max_index_id);
+ void RemoveIndex(int64_t object_store_id, int64_t index_id);
+
+ void OpenConnection(scoped_refptr<IndexedDBCallbacksWrapper>,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
+ int64_t transaction_id,
+ int64_t version);
+ void DeleteDatabase(scoped_refptr<IndexedDBCallbacksWrapper>);
+ const IndexedDBDatabaseMetadata& metadata() const { return metadata_; }
+
+ // IndexedDBDatabase
+ virtual void CreateObjectStore(int64_t transaction_id,
+ int64_t object_store_id,
+ const string16& name,
+ const IndexedDBKeyPath&,
+ bool auto_increment) OVERRIDE;
+ virtual void DeleteObjectStore(int64_t transaction_id,
+ int64_t object_store_id) OVERRIDE;
+ virtual void CreateTransaction(
+ int64_t transaction_id,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
+ const std::vector<int64_t>& object_store_ids,
+ unsigned short mode) OVERRIDE;
+ virtual void Close(scoped_refptr<IndexedDBDatabaseCallbacksWrapper>) OVERRIDE;
+
+ virtual void Commit(int64_t transaction_id) OVERRIDE;
+ virtual void Abort(int64_t transaction_id) OVERRIDE;
+ virtual void Abort(int64_t transaction_id,
+ scoped_refptr<IndexedDBDatabaseError>) OVERRIDE;
+
+ virtual void CreateIndex(int64_t transaction_id,
+ int64_t object_store_id,
+ int64_t index_id,
+ const string16& name,
+ const IndexedDBKeyPath&,
+ bool unique,
+ bool multi_entry) OVERRIDE;
+ virtual void DeleteIndex(int64_t transaction_id,
+ int64_t object_store_id,
+ int64_t 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_t transaction_id,
+ int64_t object_store_id,
+ int64_t index_id,
+ scoped_ptr<IndexedDBKeyRange>,
+ bool key_only,
+ scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
+ virtual void Put(int64_t transaction_id,
+ int64_t object_store_id,
+ std::vector<char>* value,
+ scoped_ptr<IndexedDBKey>,
+ PutMode,
+ scoped_refptr<IndexedDBCallbacksWrapper>,
+ const std::vector<int64_t>& index_ids,
+ const std::vector<IndexKeys>&) OVERRIDE;
+ virtual void SetIndexKeys(int64_t transaction_id,
+ int64_t object_store_id,
+ scoped_ptr<IndexedDBKey> primary_key,
+ const std::vector<int64_t>& index_ids,
+ const std::vector<IndexKeys>&) OVERRIDE;
+ virtual void SetIndexesReady(int64_t transaction_id,
+ int64_t object_store_id,
+ const std::vector<int64_t>& index_ids) OVERRIDE;
+ virtual void OpenCursor(int64_t transaction_id,
+ int64_t object_store_id,
+ int64_t index_id,
+ scoped_ptr<IndexedDBKeyRange>,
+ indexed_db::CursorDirection,
+ bool key_only,
+ TaskType,
+ scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
+ virtual void Count(int64_t transaction_id,
+ int64_t object_store_id,
+ int64_t index_id,
+ scoped_ptr<IndexedDBKeyRange>,
+ scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
+ virtual void DeleteRange(int64_t transaction_id,
+ int64_t object_store_id,
+ scoped_ptr<IndexedDBKeyRange>,
+ scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
+ virtual void Clear(int64_t transaction_id,
+ int64_t object_store_id,
+ scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
+
+ private:
+ IndexedDBDatabaseImpl(const string16& name,
+ IndexedDBBackingStore* database,
+ IndexedDBFactoryImpl*,
+ const string16& unique_identifier);
+ virtual ~IndexedDBDatabaseImpl();
+
+ bool IsOpenConnectionBlocked() const;
+ bool OpenInternal();
+ void RunVersionChangeTransaction(
+ scoped_refptr<IndexedDBCallbacksWrapper>,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
+ int64_t transaction_id,
+ int64_t requested_version);
+ void RunVersionChangeTransactionFinal(
+ scoped_refptr<IndexedDBCallbacksWrapper>,
+ scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
+ int64_t transaction_id,
+ int64_t requested_version);
+ size_t ConnectionCount() const;
+ void ProcessPendingCalls();
+
+ bool IsDeleteDatabaseBlocked() const;
+ void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacksWrapper>);
+
+ 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_t, 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_

Powered by Google App Engine
This is Rietveld 408576698