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

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

Issue 2472213003: [IndexedDB] Refactoring to remove ref ptrs and host transaction ids. (Closed)
Patch Set: comments & rebase 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_transaction.h
diff --git a/content/browser/indexed_db/indexed_db_transaction.h b/content/browser/indexed_db/indexed_db_transaction.h
index ad5c03e79102e99a48dd11d08be61be749d8bd5e..d90daa4008cd32afbc209cec844b3063e851ec8c 100644
--- a/content/browser/indexed_db/indexed_db_transaction.h
+++ b/content/browser/indexed_db/indexed_db_transaction.h
@@ -15,6 +15,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "content/browser/indexed_db/indexed_db_backing_store.h"
@@ -23,6 +24,7 @@
#include "content/browser/indexed_db/indexed_db_database_error.h"
#include "content/browser/indexed_db/indexed_db_observer.h"
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
+#include "url/origin.h"
namespace content {
@@ -32,8 +34,7 @@ class IndexedDBDatabaseCallbacks;
class IndexedDBObservation;
class IndexedDBObserverChanges;
-class CONTENT_EXPORT IndexedDBTransaction
- : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) {
+class CONTENT_EXPORT IndexedDBTransaction {
public:
typedef base::Callback<void(IndexedDBTransaction*)> Operation;
@@ -45,8 +46,12 @@ class CONTENT_EXPORT IndexedDBTransaction
FINISHED, // Either aborted or committed.
};
- virtual void Abort();
+ virtual ~IndexedDBTransaction();
+
leveldb::Status Commit();
+
+ // This object is destroyed by these method calls.
+ virtual void Abort();
void Abort(const IndexedDBDatabaseError& error);
// Called by the transaction coordinator when this transaction is unblocked.
@@ -87,7 +92,7 @@ class CONTENT_EXPORT IndexedDBTransaction
IndexedDBDatabase* database() const { return database_.get(); }
IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); }
- IndexedDBConnection* connection() const { return connection_.get(); }
+ IndexedDBConnection* connection() const { return connection_; }
State state() const { return state_; }
bool IsTimeoutTimerRunning() const { return timeout_timer_.IsRunning(); }
@@ -101,23 +106,17 @@ class CONTENT_EXPORT IndexedDBTransaction
const Diagnostics& diagnostics() const { return diagnostics_; }
- protected:
- // Test classes may derive, but most creation should be done via
- // IndexedDBClassFactory.
- IndexedDBTransaction(
- int64_t id,
- base::WeakPtr<IndexedDBConnection> connection,
- const std::set<int64_t>& object_store_ids,
- blink::WebIDBTransactionMode mode,
- IndexedDBBackingStore::Transaction* backing_store_transaction);
- virtual ~IndexedDBTransaction();
+ void set_size(uint64_t size) { size_ = size; }
+ uint64_t size() const { return size_; }
+ protected:
// May be overridden in tests.
virtual base::TimeDelta GetInactivityTimeout() const;
private:
friend class BlobWriteCallbackImpl;
friend class IndexedDBClassFactory;
+ friend class IndexedDBConnection;
friend class base::RefCounted<IndexedDBTransaction>;
FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTestMode, AbortPreemptive);
@@ -130,6 +129,13 @@ class CONTENT_EXPORT IndexedDBTransaction
FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTest, Timeout);
FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTest, IndexedDBObserver);
+ IndexedDBTransaction(
+ int64_t id,
+ IndexedDBConnection* connection,
+ const std::set<int64_t>& object_store_ids,
+ blink::WebIDBTransactionMode mode,
+ IndexedDBBackingStore::Transaction* backing_store_transaction);
+
void RunTasksIfStarted();
bool IsTaskQueueEmpty() const;
@@ -148,7 +154,8 @@ class CONTENT_EXPORT IndexedDBTransaction
bool used_;
State state_;
bool commit_pending_;
- base::WeakPtr<IndexedDBConnection> connection_;
+ // We are owned by the connection object.
+ IndexedDBConnection* connection_;
scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_;
scoped_refptr<IndexedDBDatabase> database_;
@@ -157,6 +164,9 @@ class CONTENT_EXPORT IndexedDBTransaction
std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>>
connection_changes_map_;
+ // Metrics for quota.
+ uint64_t size_;
+
class TaskQueue {
public:
TaskQueue();
@@ -205,6 +215,8 @@ class CONTENT_EXPORT IndexedDBTransaction
base::OneShotTimer timeout_timer_;
Diagnostics diagnostics_;
+
+ base::WeakPtrFactory<IndexedDBTransaction> ptr_factory_;
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698