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

Unified Diff: Source/modules/webdatabase/DatabaseContext.cpp

Issue 212133002: Remove manual ref()-deref() in DatabaseContext. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/modules/webdatabase/DatabaseContext.h ('k') | Source/modules/webdatabase/DatabaseManager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webdatabase/DatabaseContext.cpp
diff --git a/Source/modules/webdatabase/DatabaseContext.cpp b/Source/modules/webdatabase/DatabaseContext.cpp
index e42cf4a89193efdc4de30cd8a90bd8a10c272264..4a63b9c78518ea8291cb556da0bb08332dd7f9f8 100644
--- a/Source/modules/webdatabase/DatabaseContext.cpp
+++ b/Source/modules/webdatabase/DatabaseContext.cpp
@@ -90,14 +90,13 @@ namespace WebCore {
PassRefPtr<DatabaseContext> DatabaseContext::create(ExecutionContext* context)
{
RefPtr<DatabaseContext> self = adoptRef(new DatabaseContext(context));
- self->ref(); // Is deref()-ed on contextDestroyed().
+ DatabaseManager::manager().registerDatabaseContext(self.get());
return self.release();
}
DatabaseContext::DatabaseContext(ExecutionContext* context)
: ActiveDOMObject(context)
, m_hasOpenDatabases(false)
- , m_isRegistered(true) // will register on construction below.
, m_hasRequestedTermination(false)
{
// ActiveDOMObject expects this to be called to set internal flags.
@@ -106,8 +105,6 @@ DatabaseContext::DatabaseContext(ExecutionContext* context)
// For debug accounting only. We must do this before we register the
// instance. The assertions assume this.
DatabaseManager::manager().didConstructDatabaseContext();
-
- DatabaseManager::manager().registerDatabaseContext(this);
}
DatabaseContext::~DatabaseContext()
@@ -126,9 +123,10 @@ DatabaseContext::~DatabaseContext()
// It is not safe to just delete the context here.
void DatabaseContext::contextDestroyed()
{
+ RefPtr<DatabaseContext> protector(this);
stopDatabases();
+ DatabaseManager::manager().unregisterDatabaseContext(this);
ActiveDOMObject::contextDestroyed();
- deref(); // paired with the ref() call on create().
}
void DatabaseContext::willStop()
@@ -203,10 +201,6 @@ void DatabaseContext::stopSyncDatabases()
void DatabaseContext::stopDatabases()
{
stopSyncDatabases();
- if (m_isRegistered) {
- DatabaseManager::manager().unregisterDatabaseContext(this);
- m_isRegistered = false;
- }
// Though we initiate termination of the DatabaseThread here in
// stopDatabases(), we can't clear the m_databaseThread ref till we get to
« no previous file with comments | « Source/modules/webdatabase/DatabaseContext.h ('k') | Source/modules/webdatabase/DatabaseManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698