Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_connection.h |
| diff --git a/content/browser/indexed_db/indexed_db_connection.h b/content/browser/indexed_db/indexed_db_connection.h |
| index ce60ebd8cc5f6cf33d5f811011e0a24d4cc40abc..1b7c9da1d36b07d2ca7ce07b23906f3120fe5032 100644 |
| --- a/content/browser/indexed_db/indexed_db_connection.h |
| +++ b/content/browser/indexed_db/indexed_db_connection.h |
| @@ -6,20 +6,25 @@ |
| #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
| #include <memory> |
| +#include <unordered_map> |
| #include <vector> |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/weak_ptr.h" |
| #include "content/browser/indexed_db/indexed_db_database.h" |
| -#include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
| -#include "content/browser/indexed_db/indexed_db_observer.h" |
| +#include "url/origin.h" |
| namespace content { |
| +class IndexedDBDatabaseCallbacks; |
| +class IndexedDBDatabaseError; |
| +class IndexedDBObserver; |
| +class IndexedDBTransaction; |
| class CONTENT_EXPORT IndexedDBConnection { |
| public: |
| - IndexedDBConnection(scoped_refptr<IndexedDBDatabase> db, |
| + IndexedDBConnection(int child_process_id, |
| + scoped_refptr<IndexedDBDatabase> db, |
| scoped_refptr<IndexedDBDatabaseCallbacks> callbacks); |
| virtual ~IndexedDBConnection(); |
| @@ -38,6 +43,7 @@ class CONTENT_EXPORT IndexedDBConnection { |
| virtual void RemoveObservers(const std::vector<int32_t>& remove_observer_ids); |
| int32_t id() const { return id_; } |
| + int child_process_id() const { return child_process_id_; } |
| IndexedDBDatabase* database() const { return database_.get(); } |
| IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } |
| @@ -49,11 +55,46 @@ class CONTENT_EXPORT IndexedDBConnection { |
| return weak_factory_.GetWeakPtr(); |
| } |
| + // Creates a transaction for this connection. |
| + IndexedDBTransaction* CreateTransaction( |
| + int64_t id, |
| + const std::set<int64_t>& scope, |
| + blink::WebIDBTransactionMode mode, |
| + IndexedDBBackingStore::Transaction* backing_store_transaction); |
| + |
| + void AbortTransaction(IndexedDBTransaction* transaction); |
| + void AbortTransaction(IndexedDBTransaction* transaction, |
| + const IndexedDBDatabaseError& error); |
| + |
| + void AbortAllTransactions(const IndexedDBDatabaseError& error); |
| + |
| + IndexedDBTransaction* GetTransaction(int64_t id); |
| + |
| + base::WeakPtr<IndexedDBTransaction> StoreTransactionForTesting( |
|
jsbell
2016/11/30 21:30:13
AddTransactionForTesting ?
dmurph
2016/11/30 23:13:07
Done.
|
| + std::unique_ptr<IndexedDBTransaction> transaction); |
| + |
| + // We ignore calls where the id doesn't exist to facilitate our AbortAll call |
| + // below. |
| + // TODO(dmurph): Change the abort behavior so we don't have to ignore ids. |
| + void EraseTransaction(int64_t id); |
|
jsbell
2016/11/30 21:30:13
RemoveTransaction ?
dmurph
2016/11/30 23:13:07
Done.
|
| + |
| + const std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>>& |
|
jsbell
2016/11/30 21:30:14
Since this complex type appears twice, add a using
|
| + transactions() const { |
|
jsbell
2016/11/30 21:30:14
nit: single line? (but whatever clang format prefe
dmurph
2016/11/30 23:13:07
Done.
|
| + return transactions_; |
| + } |
| + |
| private: |
| const int32_t id_; |
| + // The process id of the child process this connection is associated with. |
| + // Tracked for IndexedDBContextImpl::GetAllOriginsDetails and debugging. |
| + const int child_process_id_; |
| + |
| // NULL in some unit tests, and after the connection is closed. |
| scoped_refptr<IndexedDBDatabase> database_; |
| + // The connection owns transactions created on this connection. |
|
jsbell
2016/11/30 21:30:14
nit: blank line before
dmurph
2016/11/30 23:13:07
Done.
|
| + std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>> |
| + transactions_; |
| // The callbacks_ member is cleared when the connection is closed. |
| // May be NULL in unit tests. |