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

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

Issue 2472213003: [IndexedDB] Refactoring to remove ref ptrs and host transaction ids. (Closed)
Patch Set: updated unittests Created 4 years, 1 month 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_connection.h
diff --git a/content/browser/indexed_db/indexed_db_connection.h b/content/browser/indexed_db/indexed_db_connection.h
index 7c4f5160a9b32d063bc2cee27110438da4309464..6299380cb4365efe0942fd41eb7a4a6cf7cc0147 100644
--- a/content/browser/indexed_db/indexed_db_connection.h
+++ b/content/browser/indexed_db/indexed_db_connection.h
@@ -6,21 +6,24 @@
#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"
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();
@@ -39,6 +42,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(); }
@@ -50,11 +54,38 @@ 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);
+
+ IndexedDBTransaction* GetTransaction(int64_t id);
+
+ IndexedDBTransaction* StoreTransactionForTesting(
+ std::unique_ptr<IndexedDBTransaction> transaction);
+
+ // We ignore calls where the id doesn't exist to facilitate our AbortAll call
+ // below.
+ // TODO(dmurph): Change this to make aborting more robust.
+ void EraseTransaction(int64_t id);
+
+ void AbortAllTransactions(const IndexedDBDatabaseError& error);
+
+ const std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>>&
+ transactions() {
cmumford 2016/11/04 23:33:12 make method const.
dmurph 2016/11/07 20:05:22 Done.
+ return transactions_;
+ }
+
private:
const int32_t id_;
+ const int child_process_id_;
jsbell 2016/11/04 17:48:19 Can this be base::ProcessId rather than int?
jsbell 2016/11/04 17:48:19 Can you add a comment about why we track the proce
dmurph 2016/11/04 22:52:24 Well, we're given an 'int' down the whole stack, s
dmurph 2016/11/04 22:52:24 Done.
jsbell 2016/11/05 00:01:48 If it's given to us as an `int` that's fine (I did
// NULL in some unit tests, and after the connection is closed.
scoped_refptr<IndexedDBDatabase> database_;
+ std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>>
jsbell 2016/11/04 17:48:19 Is there a good reason to use unordered_map vs. ma
jsbell 2016/11/04 17:48:19 Can you add comments to members as you touch them?
dmurph 2016/11/04 22:52:24 Done.
dmurph 2016/11/04 22:52:24 Huh. I don't know. I don't think so.
+ transactions_;
// The callbacks_ member is cleared when the connection is closed.
// May be NULL in unit tests.

Powered by Google App Engine
This is Rietveld 408576698