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

Side by Side Diff: Source/modules/webdatabase/DatabaseContext.cpp

Issue 248523003: Remove ActiveDOMObject::willStop, and introduce WorkerGlobalScope::TerminationObserver. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2011 Google, Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 : ActiveDOMObject(context) 98 : ActiveDOMObject(context)
99 , m_hasOpenDatabases(false) 99 , m_hasOpenDatabases(false)
100 , m_hasRequestedTermination(false) 100 , m_hasRequestedTermination(false)
101 { 101 {
102 // ActiveDOMObject expects this to be called to set internal flags. 102 // ActiveDOMObject expects this to be called to set internal flags.
103 suspendIfNeeded(); 103 suspendIfNeeded();
104 104
105 // For debug accounting only. We must do this before we register the 105 // For debug accounting only. We must do this before we register the
106 // instance. The assertions assume this. 106 // instance. The assertions assume this.
107 DatabaseManager::manager().didConstructDatabaseContext(); 107 DatabaseManager::manager().didConstructDatabaseContext();
108 if (context->isWorkerGlobalScope())
109 toWorkerGlobalScope(context)->registerTerminationObserver(this);
108 } 110 }
109 111
110 DatabaseContext::~DatabaseContext() 112 DatabaseContext::~DatabaseContext()
111 { 113 {
112 // For debug accounting only. We must call this last. The assertions assume 114 // For debug accounting only. We must call this last. The assertions assume
113 // this. 115 // this.
114 DatabaseManager::manager().didDestructDatabaseContext(); 116 DatabaseManager::manager().didDestructDatabaseContext();
115 } 117 }
116 118
117 void DatabaseContext::trace(Visitor* visitor) 119 void DatabaseContext::trace(Visitor* visitor)
118 { 120 {
119 visitor->trace(m_databaseThread); 121 visitor->trace(m_databaseThread);
120 visitor->trace(m_openSyncDatabases); 122 visitor->trace(m_openSyncDatabases);
121 } 123 }
122 124
123 // This is called if the associated ExecutionContext is destructing while 125 // This is called if the associated ExecutionContext is destructing while
124 // we're still associated with it. That's our cue to disassociate and shutdown. 126 // we're still associated with it. That's our cue to disassociate and shutdown.
125 // To do this, we stop the database and let everything shutdown naturally 127 // To do this, we stop the database and let everything shutdown naturally
126 // because the database closing process may still make use of this context. 128 // because the database closing process may still make use of this context.
127 // It is not safe to just delete the context here. 129 // It is not safe to just delete the context here.
128 void DatabaseContext::contextDestroyed() 130 void DatabaseContext::contextDestroyed()
129 { 131 {
130 RefPtrWillBeRawPtr<DatabaseContext> protector(this); 132 RefPtrWillBeRawPtr<DatabaseContext> protector(this);
131 stopDatabases(); 133 stopDatabases();
134 if (executionContext()->isWorkerGlobalScope())
sof 2014/04/23 09:04:26 Clarifying question: is this access of the WorkerG
tkent 2014/04/23 09:13:35 Yes, it's safe.
135 toWorkerGlobalScope(executionContext())->unregisterTerminationObserver(t his);
132 DatabaseManager::manager().unregisterDatabaseContext(this); 136 DatabaseManager::manager().unregisterDatabaseContext(this);
133 ActiveDOMObject::contextDestroyed(); 137 ActiveDOMObject::contextDestroyed();
134 } 138 }
135 139
136 void DatabaseContext::willStop() 140 void DatabaseContext::wasRequestedToTerminate()
137 { 141 {
138 DatabaseManager::manager().interruptAllDatabasesForContext(this); 142 DatabaseManager::manager().interruptAllDatabasesForContext(this);
139 } 143 }
140 144
141 // stop() is from stopActiveDOMObjects() which indicates that the owner LocalFra me 145 // stop() is from stopActiveDOMObjects() which indicates that the owner LocalFra me
142 // or WorkerThread is shutting down. Initiate the orderly shutdown by stopping 146 // or WorkerThread is shutting down. Initiate the orderly shutdown by stopping
143 // the associated databases. 147 // the associated databases.
144 void DatabaseContext::stop() 148 void DatabaseContext::stop()
145 { 149 {
146 stopDatabases(); 150 stopDatabases();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 { 258 {
255 return executionContext()->securityOrigin(); 259 return executionContext()->securityOrigin();
256 } 260 }
257 261
258 bool DatabaseContext::isContextThread() const 262 bool DatabaseContext::isContextThread() const
259 { 263 {
260 return executionContext()->isContextThread(); 264 return executionContext()->isContextThread();
261 } 265 }
262 266
263 } // namespace WebCore 267 } // namespace WebCore
OLDNEW
« Source/core/workers/WorkerGlobalScope.cpp ('K') | « Source/modules/webdatabase/DatabaseContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698