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

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: 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_transaction.h
diff --git a/content/browser/indexed_db/indexed_db_transaction.h b/content/browser/indexed_db/indexed_db_transaction.h
index ad5c03e79102e99a48dd11d08be61be749d8bd5e..3ea7f932ba51cc47eb87df464a506ef3e12075dd 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,6 +46,14 @@ class CONTENT_EXPORT IndexedDBTransaction
FINISHED, // Either aborted or committed.
};
+ IndexedDBTransaction(
cmumford 2016/11/04 23:33:13 The only reason this is public is so that base::Wr
dmurph 2016/11/07 20:05:23 Done.
+ int64_t id,
+ IndexedDBConnection* connection,
+ const std::set<int64_t>& object_store_ids,
+ blink::WebIDBTransactionMode mode,
+ IndexedDBBackingStore::Transaction* backing_store_transaction);
+ virtual ~IndexedDBTransaction();
+
virtual void Abort();
leveldb::Status Commit();
void Abort(const IndexedDBDatabaseError& error);
@@ -87,7 +96,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 +110,20 @@ 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_; }
+ void set_origin(url::Origin origin) { origin_ = std::move(origin); }
+ const url::Origin& origin() const { return origin_; }
+
+ 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);
@@ -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,10 @@ class CONTENT_EXPORT IndexedDBTransaction
std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>>
connection_changes_map_;
+ // Metrics for quota.
+ uint64_t size_;
+ url::Origin origin_;
jsbell 2016/11/04 17:48:19 Can we replace origin_ with connection_->origin()
dmurph 2016/11/04 22:52:25 Done.
+
class TaskQueue {
public:
TaskQueue();
@@ -205,6 +216,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