Change DatabaseContext lookup to be thread-safe.
https://bugs.webkit.org/show_bug.cgi?id=107784.

Reviewed by Geoffrey Garen.

DatabaseContext will no longer be a Supplement of ScriptExecutionContext.
Instead we will maintain a mutex guarded contextMap in the DatabaseManager
which maps ScriptExecutionContexts to DatabaseContexts.

Also cleaned up the shutdown mechanism of the DatabaseContext,
DatabaseThread, and Databases when their owner ScriptExecutionContext
destructs.

No new tests.

* Modules/webdatabase/AbstractDatabase.cpp:
(WebCore::AbstractDatabase::AbstractDatabase):
* Modules/webdatabase/AbstractDatabase.h:
(WebCore::AbstractDatabase::databaseContext):
(AbstractDatabase):
* Modules/webdatabase/Database.cpp:
(WebCore::Database::Database):
* Modules/webdatabase/Database.h:
(WebCore):
(Database):
* Modules/webdatabase/DatabaseContext.cpp:
(WebCore):
(WebCore::DatabaseContext::DatabaseContext):
(WebCore::DatabaseContext::~DatabaseContext):
(WebCore::DatabaseContext::contextDestroyed):
(WebCore::DatabaseContext::stop):
(WebCore::DatabaseContext::databaseThread):
(WebCore::DatabaseContext::stopDatabases):
* Modules/webdatabase/DatabaseContext.h:
(DatabaseContext):
(WebCore::DatabaseContext::scriptExecutionContext):
(WebCore::DatabaseContext::hasOpenDatabases):
(WebCore::DatabaseContext::stopDatabases):
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::manager):
(WebCore::DatabaseManager::DatabaseManager):
(WebCore::DatabaseManager::getExistingDatabaseContext):
(WebCore):
(WebCore::DatabaseManager::getDatabaseContext):
(WebCore::DatabaseManager::registerDatabaseContext):
(WebCore::DatabaseManager::unregisterDatabaseContext):
(WebCore::DatabaseManager::notifyDatabaseContextConstructed):
(WebCore::DatabaseManager::notifyDatabaseContextDestructed):
(WebCore::DatabaseManager::openDatabase):
(WebCore::DatabaseManager::openDatabaseSync):
(WebCore::DatabaseManager::hasOpenDatabases):
(WebCore::DatabaseManager::stopDatabases):
(WebCore::DatabaseManager::interruptAllDatabasesForContext):
* Modules/webdatabase/DatabaseManager.h:
(WebCore):
(DatabaseManager):
(WebCore::DatabaseManager::notifyDatabaseContextConstructed):
(WebCore::DatabaseManager::notifyDatabaseContextDestructed):
* Modules/webdatabase/DatabaseSync.cpp:
(WebCore::DatabaseSync::DatabaseSync):
* Modules/webdatabase/DatabaseSync.h:
(WebCore):
(DatabaseSync):
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::~DatabaseThread):
(WebCore::DatabaseThread::requestTermination):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::canEstablishDatabase):
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::~ActiveDOMObject):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141166 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add support for enabling process suppression in WebProcesses with no visible pages
https://bugs.webkit.org/show_bug.cgi?id=108054

Patch by Kiran Muppala <cmuppala@apple.com> on 2013-01-29
Reviewed by Anders Carlsson.

Provide a preference to enable process suppression in WebProcesses with
no visible pages even if the application is not completely occluded.
This provides more opportunities for process suppression to take effect.

Replace the messaging of application occlusion status from UI process to
ChildProcesses with messages that indicate the current required process
suppression state.  WebProcessProxy should determine if the process is
eligible for process suppression based on both application occlusion
and page visibility.  When either of these parameters changes,
the proxy should message the child process of the updated process
suppression state.

* NetworkProcess/NetworkProcess.messages.in: Rename
SetApplicationIsOccluded to SetProcessSuppressionEnabled.
* PluginProcess/PluginProcess.messages.in: Ditto.
* Shared/ChildProcess.h:
(WebKit::ChildProcess::processSuppressionEnabled): Rename
applicationIsOccluded.
* Shared/WebPreferencesStore.h: Add a new preference
pageVisibilityBasedProcessSuppressionEnabled, to enabled/disable
process suppression of WebProcesses when all pages are hidden.
* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::setProcessSuppressionEnabled): Rename
setApplicationIsOccluded.
(WebKit::ChildProcess::platformInitialize): Replace call to
setApplicationIsOccluded with setProcessSuppressionEnabled.
* SharedWorkerProcess/SharedWorkerProcess.messages.in: Rename
SetApplicationIsOccluded to SetProcessSuppressionEnabled.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled):
(WKPreferencesGetPageVisibilityBasedProcessSuppressionEnabled):
* UIProcess/API/C/WKPreferencesPrivate.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didFinishLaunching): Use setter
to update process suppression state instead of messaging directly.
Use WebContext::canEnableProcessSuppressionForNetworkProcess() helper
method to determine if process suppression should be enabled.
* UIProcess/Network/NetworkProcessProxy.h: Rename
setApplicationIsOccluded to setProcessSuppresionEnabled.
* UIProcess/Network/mac/NetworkProcessProxyMac.mm:
(WebKit::NetworkProcessProxy::setProcessSuppressionEnabled): Ditto.
* UIProcess/Plugins/PluginProcessManager.h: Ditto.
* UIProcess/Plugins/PluginProcessProxy.cpp:
(WebKit::PluginProcessProxy::didFinishLaunching): Use setter
to update process suppression state instead of messaging directly.
Use WebContext::canEnableProcessSuppressionForGlobalChildProcesses()
helper method to determine if process suppression should be enabled.
* UIProcess/Plugins/PluginProcessProxy.h: Rename
setApplicationIsOccluded to setProcessSuppresionEnabled.
* UIProcess/Plugins/mac/PluginProcessManagerMac.mm:
(WebKit::PluginProcessManager::setProcessSuppressionEnabled): Ditto.
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::setProcessSuppressionEnabled): Ditto.
* UIProcess/SharedWorkers/SharedWorkerProcessManager.h: Ditto.
* UIProcess/SharedWorkers/SharedWorkerProcessProxy.cpp:
(WebKit::SharedWorkerProcessProxy::didFinishLaunching): Use setter
to update process suppression state instead of messaging directly.
Use WebContext::canEnableProcessSuppressionForGlobalChildProcesses()
helper method to determine if process suppression should be enabled.
* UIProcess/SharedWorkers/SharedWorkerProcessProxy.h: Rename
setApplicationIsOccluded to setProcessSuppresionEnabled.
* UIProcess/SharedWorkers/mac/SharedWorkerProcessManagerMac.mm:
(WebKit::SharedWorkerProcessManager::setProcessSuppressionEnabled):
Ditto.
* UIProcess/SharedWorkers/mac/SharedWorkerProcessProxyMac.mm:
(WebKit::SharedWorkerProcessProxy::setProcessSuppressionEnabled): Ditto.
* UIProcess/WebContext.h: Replace applicationIsOccluded() getter with
helper methods to determine if a child process can have process
suppression enabled.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::viewStateDidChange): Notify WebProcessProxy of
page visibility change.
(WebKit::WebPageProxy::preferencesDidChange): Notify WebProcessProxy of
change in preferences.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::WebProcessProxy): Initialize member variable
tracking process suppression state to false.
(WebKit::WebProcessProxy::createWebPage): Update set of pages which can
be process suppressed and the resulting process suppression state for
the child process.
(WebKit::WebProcessProxy::addExistingWebPage): Ditto.
(WebKit::WebProcessProxy::removeWebPage): Ditto.
(WebKit::WebProcessProxy::pageVisibilityChanged): Ditto.
(WebKit::WebProcessProxy::pagePreferencesChanged): Ditto.
(WebKit::WebProcessProxy::didFinishLaunching): Call
updateProcessSuppressionState().
* UIProcess/WebProcessProxy.h:
* UIProcess/mac/WebContextMac.mm:
(WebKit::updateProcessSuppressionStateOfGlobalChildProcesses): Use new
helper method canEnableProcessSuppressionForGlobalChildProcesses() to
determine if process suppression should be enabled.
(WebKit::applicationOcclusionStateChanged): Update renamed methods
and variables.
(WebKit::enableOcclusionNotifications): Move OmitProcessSuppression
user default check into canEnableProcessSuppression methods.
(WebKit::omitProcessSuppression):
(WebKit::WebContext::updateProcessSuppressionStateOfChildProcesses):
Use new helper method canEnableProcessSuppressionForNetworkProcess() to
determine if process suppression should be enabled for NetworkProcess.
Let WebProcess update process suppression state based on application
occlusion state and page visibility.
(WebKit::WebContext::canEnableProcessSuppressionForNetworkProcess):
(WebKit::WebContext::canEnableProcessSuppressionForWebProcess):
(WebKit::WebContext::canEnableProcessSuppressionForGlobalChildProcesses):
(WebKit::WebContext::processSuppressionEnabledChanged): Reevaluate if
process suppression is enabled for all contexts and update process
suppression state of global child processes.
* UIProcess/mac/WebProcessProxyMac.mm:
(WebKit::WebProcessProxy::pageIsProcessSuppressible):
(WebKit::WebProcessProxy::allPagesAreProcessSuppressible):
(WebKit::WebProcessProxy::updateProcessSuppressionState):
* WebProcess/WebProcess.messages.in:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141167 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (r140594): RELEASE_ASSERT_NOT_REACHED in JSC::Interpreter::execute
https://bugs.webkit.org/show_bug.cgi?id=108097

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

LiteralParser was accepting a bogus 'var a.b = c' statement

* runtime/LiteralParser.cpp:
(JSC::::tryJSONPParse):

LayoutTests:

Add parser test for invalid var a.b syntax

* fast/js/parser-syntax-check-expected.txt:
* fast/js/script-tests/parser-syntax-check.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141168 268f45cc-cd09-0410-ab3c-d52691b4dbfc