diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebKit2/UIProcess/WebProcessProxy.cpp | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit2/UIProcess/WebProcessProxy.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/WebProcessProxy.cpp | 456 |
1 files changed, 211 insertions, 245 deletions
diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.cpp b/Source/WebKit2/UIProcess/WebProcessProxy.cpp index 6ca003ab3..88659844a 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.cpp +++ b/Source/WebKit2/UIProcess/WebProcessProxy.cpp @@ -27,6 +27,7 @@ #include "WebProcessProxy.h" #include "DataReference.h" +#include "DownloadProxyMap.h" #include "PluginInfoStore.h" #include "PluginProcessManager.h" #include "TextChecker.h" @@ -40,15 +41,12 @@ #include "WebProcessMessages.h" #include "WebProcessProxyMessages.h" #include <WebCore/KURL.h> +#include <WebCore/SuddenTermination.h> #include <stdio.h> #include <wtf/MainThread.h> #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> -#if ENABLE(NETWORK_PROCESS) -#include "NetworkProcessManager.h" -#endif - #if PLATFORM(MAC) #include "SimplePDFPlugin.h" #if ENABLE(PDFKIT_PLUGIN) @@ -56,33 +54,33 @@ #endif #endif +#if ENABLE(CUSTOM_PROTOCOLS) +#include "CustomProtocolManagerProxyMessages.h" +#endif + +#if USE(SECURITY_FRAMEWORK) +#include "SecItemShimProxy.h" +#endif + using namespace WebCore; -using namespace std; #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, connection()) #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(checkURLReceivedFromWebProcess(url), connection()) namespace WebKit { -template<typename HashMap> -static inline bool isGoodKey(const typename HashMap::KeyType& key) -{ - return key != HashTraits<typename HashMap::KeyType>::emptyValue() && !HashTraits<typename HashMap::KeyType>::isDeletedValue(key); -} - static uint64_t generatePageID() { - static uint64_t uniquePageID = 1; - return uniquePageID++; + static uint64_t uniquePageID; + return ++uniquePageID; } -#if ENABLE(NETSCAPE_PLUGIN_API) -static WorkQueue& pluginWorkQueue() +static WebProcessProxy::WebPageProxyMap& globalPageMap() { - DEFINE_STATIC_LOCAL(WorkQueue, queue, ("com.apple.CoreIPC.PluginQueue")); - return queue; + ASSERT(isMainThread()); + DEFINE_STATIC_LOCAL(WebProcessProxy::WebPageProxyMap, pageMap, ()); + return pageMap; } -#endif // ENABLE(NETSCAPE_PLUGIN_API) PassRefPtr<WebProcessProxy> WebProcessProxy::create(PassRefPtr<WebContext> context) { @@ -96,121 +94,76 @@ WebProcessProxy::WebProcessProxy(PassRefPtr<WebContext> context) #if ENABLE(CUSTOM_PROTOCOLS) , m_customProtocolManagerProxy(this) #endif +#if PLATFORM(MAC) + , m_processSuppressionEnabled(false) +#endif { connect(); } WebProcessProxy::~WebProcessProxy() { - if (m_connection) - m_connection->invalidate(); - if (m_webConnection) m_webConnection->invalidate(); +} - for (size_t i = 0; i < m_pendingMessages.size(); ++i) - m_pendingMessages[i].first.releaseArguments(); - - if (m_processLauncher) { - m_processLauncher->invalidate(); - m_processLauncher = 0; - } +void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions) +{ + launchOptions.processType = ProcessLauncher::WebProcess; + platformGetLaunchOptions(launchOptions); } -WebProcessProxy* WebProcessProxy::fromConnection(CoreIPC::Connection* connection) +void WebProcessProxy::connectionWillOpen(CoreIPC::Connection* connection) { - ASSERT(connection); + ASSERT(this->connection() == connection); + +#if USE(SECURITY_FRAMEWORK) + SecItemShimProxy::shared().initializeConnection(connection); +#endif - WebProcessProxy* webProcessProxy = static_cast<WebProcessProxy*>(connection->client()); - ASSERT(webProcessProxy->connection() == connection); + for (WebPageProxyMap::iterator it = m_pageMap.begin(), end = m_pageMap.end(); it != end; ++it) + it->value->connectionWillOpen(connection); - return webProcessProxy; + m_context->processWillOpenConnection(this); } -void WebProcessProxy::connect() +void WebProcessProxy::connectionWillClose(CoreIPC::Connection* connection) { - ASSERT(!m_processLauncher); + ASSERT(this->connection() == connection); - ProcessLauncher::LaunchOptions launchOptions; - launchOptions.processType = ProcessLauncher::WebProcess; - platformConnect(launchOptions); - - m_processLauncher = ProcessLauncher::create(this, launchOptions); + for (WebPageProxyMap::iterator it = m_pageMap.begin(), end = m_pageMap.end(); it != end; ++it) + it->value->connectionWillClose(connection); + + m_context->processWillCloseConnection(this); } void WebProcessProxy::disconnect() { - if (m_connection) { - m_connection->removeQueueClient(this); - m_connection->invalidate(); - m_connection = nullptr; - } + clearConnection(); if (m_webConnection) { m_webConnection->invalidate(); m_webConnection = nullptr; } - m_responsivenessTimer.stop(); + m_responsivenessTimer.invalidate(); - Vector<RefPtr<WebFrameProxy> > frames; + Vector<RefPtr<WebFrameProxy>> frames; copyValuesToVector(m_frameMap, frames); for (size_t i = 0, size = frames.size(); i < size; ++i) frames[i]->disconnect(); m_frameMap.clear(); - m_context->disconnectProcess(this); -} - -bool WebProcessProxy::sendMessage(CoreIPC::MessageID messageID, PassOwnPtr<CoreIPC::MessageEncoder> encoder, unsigned messageSendFlags) -{ - // If we're waiting for the web process to launch, we need to stash away the messages so we can send them once we have - // a CoreIPC connection. - if (isLaunching()) { - m_pendingMessages.append(make_pair(CoreIPC::Connection::OutgoingMessage(messageID, encoder), messageSendFlags)); - return true; - } - - // If the web process has exited, m_connection will be null here. - if (!m_connection) - return false; - - return connection()->sendMessage(messageID, encoder, messageSendFlags); -} - -bool WebProcessProxy::isLaunching() const -{ - if (m_processLauncher) - return m_processLauncher->isLaunching(); - - return false; -} - -void WebProcessProxy::terminate() -{ - if (m_processLauncher) - m_processLauncher->terminateProcess(); -} + if (m_downloadProxyMap) + m_downloadProxyMap->processDidClose(); -void WebProcessProxy::addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver* messageReceiver) -{ - m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver); -} - -void WebProcessProxy::addMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID, CoreIPC::MessageReceiver* messageReceiver) -{ - m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver); -} - -void WebProcessProxy::removeMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID) -{ - m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID); + m_context->disconnectProcess(this); } -WebPageProxy* WebProcessProxy::webPage(uint64_t pageID) const +WebPageProxy* WebProcessProxy::webPage(uint64_t pageID) { - return m_pageMap.get(pageID); + return globalPageMap().get(pageID); } PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient* pageClient, WebContext*, WebPageGroup* pageGroup) @@ -218,17 +171,41 @@ PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient* pageClient, uint64_t pageID = generatePageID(); RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, this, pageGroup, pageID); m_pageMap.set(pageID, webPage.get()); + globalPageMap().set(pageID, webPage.get()); +#if PLATFORM(MAC) + if (pageIsProcessSuppressible(webPage.get())) + m_processSuppressiblePages.add(pageID); + updateProcessSuppressionState(); +#endif return webPage.release(); } void WebProcessProxy::addExistingWebPage(WebPageProxy* webPage, uint64_t pageID) { m_pageMap.set(pageID, webPage); + globalPageMap().set(pageID, webPage); +#if PLATFORM(MAC) + if (pageIsProcessSuppressible(webPage)) + m_processSuppressiblePages.add(pageID); + updateProcessSuppressionState(); +#endif } void WebProcessProxy::removeWebPage(uint64_t pageID) { m_pageMap.remove(pageID); + globalPageMap().remove(pageID); +#if PLATFORM(MAC) + m_processSuppressiblePages.remove(pageID); + updateProcessSuppressionState(); +#endif + + // If this was the last WebPage open in that web process, and we have no other reason to keep it alive, let it go. + // We only allow this when using a network process, as otherwise the WebProcess needs to preserve its session state. + if (m_context->usesNetworkProcess() && canTerminateChildProcess()) { + abortProcessLaunchIfNeeded(); + disconnect(); + } } Vector<WebPageProxy*> WebProcessProxy::pages() const @@ -238,19 +215,9 @@ Vector<WebPageProxy*> WebProcessProxy::pages() const return result; } -#if ENABLE(WEB_INTENTS) -void WebProcessProxy::removeMessagePortChannel(uint64_t channelID) -{ - if (!isValid()) - return; - - send(Messages::WebProcess::RemoveMessagePortChannel(channelID), /* destinationID */ 0); -} -#endif - WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) const { - return m_backForwardListItemMap.get(itemID).get(); + return m_backForwardListItemMap.get(itemID); } void WebProcessProxy::registerNewWebBackForwardListItem(WebBackForwardListItem* item) @@ -342,73 +309,31 @@ void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& original } #if ENABLE(NETSCAPE_PLUGIN_API) -void WebProcessProxy::sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<PluginInfo> > pluginInfos) +void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins) { - ASSERT(isMainThread()); + if (refresh) + m_context->pluginInfoStore().refresh(); - OwnPtr<Vector<PluginInfo> > plugins(pluginInfos); + Vector<PluginModuleInfo> pluginModules = m_context->pluginInfoStore().plugins(); + for (size_t i = 0; i < pluginModules.size(); ++i) + plugins.append(pluginModules[i].info); #if PLATFORM(MAC) // Add built-in PDF last, so that it's not used when a real plug-in is installed. - // NOTE: This has to be done on the main thread as it calls localizedString(). if (!m_context->omitPDFSupport()) { #if ENABLE(PDFKIT_PLUGIN) - plugins->append(PDFPlugin::pluginInfo()); + plugins.append(PDFPlugin::pluginInfo()); #endif - plugins->append(SimplePDFPlugin::pluginInfo()); + plugins.append(SimplePDFPlugin::pluginInfo()); } #endif - - send(Messages::WebProcess::DidGetPlugins(requestID, *plugins), 0); -} - -void WebProcessProxy::handleGetPlugins(uint64_t requestID, bool refresh) -{ - if (refresh) - m_context->pluginInfoStore().refresh(); - - OwnPtr<Vector<PluginInfo> > pluginInfos = adoptPtr(new Vector<PluginInfo>); - - { - Vector<PluginModuleInfo> plugins = m_context->pluginInfoStore().plugins(); - for (size_t i = 0; i < plugins.size(); ++i) - pluginInfos->append(plugins[i].info); - } - - // NOTE: We have to pass the PluginInfo vector to the secondary thread via a pointer as otherwise - // we'd end up with a deref() race on all the WTF::Strings it contains. - RunLoop::main()->dispatch(bind(&WebProcessProxy::sendDidGetPlugins, this, requestID, pluginInfos.release())); -} - -void WebProcessProxy::getPlugins(CoreIPC::Connection*, uint64_t requestID, bool refresh) -{ - pluginWorkQueue().dispatch(bind(&WebProcessProxy::handleGetPlugins, this, requestID, refresh)); -} - -void WebProcessProxy::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy) -{ - MESSAGE_CHECK_URL(urlString); - - String newMimeType = mimeType.lower(); - - pluginLoadPolicy = PluginModuleLoadNormally; - PluginModuleInfo plugin = m_context->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString)); - if (!plugin.path) - return; - - pluginLoadPolicy = PluginInfoStore::policyForPlugin(plugin); - if (pluginLoadPolicy != PluginModuleLoadNormally) - return; - - pluginPath = plugin.path; } #endif // ENABLE(NETSCAPE_PLUGIN_API) #if ENABLE(PLUGIN_PROCESS) - -void WebProcessProxy::getPluginProcessConnection(const String& pluginPath, uint32_t processType, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply) +void WebProcessProxy::getPluginProcessConnection(uint64_t pluginProcessToken, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply) { - PluginProcessManager::shared().getPluginProcessConnection(m_context->pluginInfoStore(), pluginPath, static_cast<PluginProcess::Type>(processType), reply); + PluginProcessManager::shared().getPluginProcessConnection(pluginProcessToken, reply); } #elif ENABLE(NETSCAPE_PLUGIN_API) @@ -435,69 +360,40 @@ void WebProcessProxy::getSharedWorkerProcessConnection(const String& /* url */, #if ENABLE(NETWORK_PROCESS) void WebProcessProxy::getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply) { - NetworkProcessManager::shared().getNetworkProcessConnection(reply); + m_context->getNetworkProcessConnection(reply); } #endif // ENABLE(NETWORK_PROCESS) -void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder) +void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder) { - if (m_messageReceiverMap.dispatchMessage(connection, messageID, decoder)) - return; - - if (m_context->dispatchMessage(connection, messageID, decoder)) + if (dispatchMessage(connection, decoder)) return; - if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) { - didReceiveWebProcessProxyMessage(connection, messageID, decoder); + if (m_context->dispatchMessage(connection, decoder)) return; - } -#if ENABLE(CUSTOM_PROTOCOLS) - if (messageID.is<CoreIPC::MessageClassCustomProtocolManagerProxy>()) { - m_customProtocolManagerProxy.didReceiveMessage(connection, messageID, decoder); + if (decoder.messageReceiverName() == Messages::WebProcessProxy::messageReceiverName()) { + didReceiveWebProcessProxyMessage(connection, decoder); return; } -#endif - uint64_t pageID = decoder.destinationID(); - if (!pageID) - return; - - WebPageProxy* pageProxy = webPage(pageID); - if (!pageProxy) - return; - - pageProxy->didReceiveMessage(connection, messageID, decoder); + // FIXME: Add unhandled message logging. } -void WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder) +void WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder) { - if (m_messageReceiverMap.dispatchSyncMessage(connection, messageID, decoder, replyEncoder)) + if (dispatchSyncMessage(connection, decoder, replyEncoder)) return; - if (m_context->dispatchSyncMessage(connection, messageID, decoder, replyEncoder)) + if (m_context->dispatchSyncMessage(connection, decoder, replyEncoder)) return; - if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) { - didReceiveSyncWebProcessProxyMessage(connection, messageID, decoder, replyEncoder); + if (decoder.messageReceiverName() == Messages::WebProcessProxy::messageReceiverName()) { + didReceiveSyncWebProcessProxyMessage(connection, decoder, replyEncoder); return; } - uint64_t pageID = decoder.destinationID(); - if (!pageID) - return; - - WebPageProxy* pageProxy = webPage(pageID); - if (!pageProxy) - return; - - pageProxy->didReceiveSyncMessage(connection, messageID, decoder, replyEncoder); -} - -void WebProcessProxy::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, bool& didHandleMessage) -{ - if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) - didReceiveWebProcessProxyMessageOnConnectionWorkQueue(connection, messageID, decoder, didHandleMessage); + // FIXME: Add unhandled message logging. } void WebProcessProxy::didClose(CoreIPC::Connection*) @@ -508,7 +404,7 @@ void WebProcessProxy::didClose(CoreIPC::Connection*) webConnection()->didClose(); - Vector<RefPtr<WebPageProxy> > pages; + Vector<RefPtr<WebPageProxy>> pages; copyValuesToVector(m_pageMap, pages); disconnect(); @@ -522,7 +418,9 @@ void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection* connection, { WTFLogAlways("Received an invalid message \"%s.%s\" from the web process.\n", messageReceiverName.toString().data(), messageName.toString().data()); - // Terminate the WebProcesses. + WebContext::didReceiveInvalidMessage(messageReceiverName, messageName); + + // Terminate the WebProcess. terminate(); // Since we've invalidated the connection we'll never get a CoreIPC::Connection::Client::didClose @@ -532,7 +430,7 @@ void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection* connection, void WebProcessProxy::didBecomeUnresponsive(ResponsivenessTimer*) { - Vector<RefPtr<WebPageProxy> > pages; + Vector<RefPtr<WebPageProxy>> pages; copyValuesToVector(m_pageMap, pages); for (size_t i = 0, size = pages.size(); i < size; ++i) pages[i]->processDidBecomeUnresponsive(); @@ -540,7 +438,7 @@ void WebProcessProxy::didBecomeUnresponsive(ResponsivenessTimer*) void WebProcessProxy::interactionOccurredWhileUnresponsive(ResponsivenessTimer*) { - Vector<RefPtr<WebPageProxy> > pages; + Vector<RefPtr<WebPageProxy>> pages; copyValuesToVector(m_pageMap, pages); for (size_t i = 0, size = pages.size(); i < size; ++i) pages[i]->interactionOccurredWhileProcessUnresponsive(); @@ -548,58 +446,36 @@ void WebProcessProxy::interactionOccurredWhileUnresponsive(ResponsivenessTimer*) void WebProcessProxy::didBecomeResponsive(ResponsivenessTimer*) { - Vector<RefPtr<WebPageProxy> > pages; + Vector<RefPtr<WebPageProxy>> pages; copyValuesToVector(m_pageMap, pages); for (size_t i = 0, size = pages.size(); i < size; ++i) pages[i]->processDidBecomeResponsive(); } -void WebProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier) -{ - didFinishLaunching(connectionIdentifier); -} - -void WebProcessProxy::didFinishLaunching(CoreIPC::Connection::Identifier connectionIdentifier) +void WebProcessProxy::didFinishLaunching(ProcessLauncher* launcher, CoreIPC::Connection::Identifier connectionIdentifier) { - ASSERT(!m_connection); - - m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main()); -#if OS(DARWIN) - m_connection->setShouldCloseConnectionOnMachExceptions(); -#elif PLATFORM(QT) && !OS(WINDOWS) - m_connection->setShouldCloseConnectionOnProcessTermination(processIdentifier()); -#endif - - m_connection->addQueueClient(this); - m_connection->open(); + ChildProcessProxy::didFinishLaunching(launcher, connectionIdentifier); m_webConnection = WebConnectionToWebProcess::create(this); - for (size_t i = 0; i < m_pendingMessages.size(); ++i) { - CoreIPC::Connection::OutgoingMessage& outgoingMessage = m_pendingMessages[i].first; - unsigned messageSendFlags = m_pendingMessages[i].second; - connection()->sendMessage(outgoingMessage.messageID(), adoptPtr(outgoingMessage.arguments()), messageSendFlags); - } - - m_pendingMessages.clear(); - - // Tell the context that we finished launching. m_context->processDidFinishLaunching(this); #if PLATFORM(MAC) - if (WebContext::applicationIsOccluded()) - connection()->send(Messages::WebProcess::SetApplicationIsOccluded(true), 0); + updateProcessSuppressionState(); #endif } WebFrameProxy* WebProcessProxy::webFrame(uint64_t frameID) const { - return isGoodKey<WebFrameProxyMap>(frameID) ? m_frameMap.get(frameID).get() : 0; + if (!WebFrameProxyMap::isValidKey(frameID)) + return 0; + + return m_frameMap.get(frameID); } bool WebProcessProxy::canCreateFrame(uint64_t frameID) const { - return isGoodKey<WebFrameProxyMap>(frameID) && !m_frameMap.contains(frameID); + return WebFrameProxyMap::isValidKey(frameID) && !m_frameMap.contains(frameID); } void WebProcessProxy::frameCreated(uint64_t frameID, WebFrameProxy* frameProxy) @@ -613,13 +489,13 @@ void WebProcessProxy::didDestroyFrame(uint64_t frameID) // If the page is closed before it has had the chance to send the DidCreateMainFrame message // back to the UIProcess, then the frameDestroyed message will still be received because it // gets sent directly to the WebProcessProxy. - ASSERT(isGoodKey<WebFrameProxyMap>(frameID)); + ASSERT(WebFrameProxyMap::isValidKey(frameID)); m_frameMap.remove(frameID); } void WebProcessProxy::disconnectFramesFromPage(WebPageProxy* page) { - Vector<RefPtr<WebFrameProxy> > frames; + Vector<RefPtr<WebFrameProxy>> frames; copyValuesToVector(m_frameMap, frames); for (size_t i = 0, size = frames.size(); i < size; ++i) { if (frames[i]->page() == page) @@ -630,24 +506,34 @@ void WebProcessProxy::disconnectFramesFromPage(WebPageProxy* page) size_t WebProcessProxy::frameCountInPage(WebPageProxy* page) const { size_t result = 0; - for (HashMap<uint64_t, RefPtr<WebFrameProxy> >::const_iterator iter = m_frameMap.begin(); iter != m_frameMap.end(); ++iter) { + for (HashMap<uint64_t, RefPtr<WebFrameProxy>>::const_iterator iter = m_frameMap.begin(); iter != m_frameMap.end(); ++iter) { if (iter->value->page() == page) ++result; } return result; } -void WebProcessProxy::shouldTerminate(bool& shouldTerminate) +bool WebProcessProxy::canTerminateChildProcess() { - if (!m_pageMap.isEmpty() || !m_context->shouldTerminate(this)) { - shouldTerminate = false; - return; - } + if (!m_pageMap.isEmpty()) + return false; - shouldTerminate = true; + if (m_downloadProxyMap && !m_downloadProxyMap->isEmpty()) + return false; - // We know that the web process is going to terminate so disconnect it from the context. - disconnect(); + if (!m_context->shouldTerminate(this)) + return false; + + return true; +} + +void WebProcessProxy::shouldTerminate(bool& shouldTerminate) +{ + shouldTerminate = canTerminateChildProcess(); + if (shouldTerminate) { + // We know that the web process is going to terminate so disconnect it from the context. + disconnect(); + } } void WebProcessProxy::updateTextCheckerState() @@ -656,6 +542,18 @@ void WebProcessProxy::updateTextCheckerState() send(Messages::WebProcess::SetTextCheckerState(TextChecker::state()), 0); } +DownloadProxy* WebProcessProxy::createDownloadProxy() +{ +#if ENABLE(NETWORK_PROCESS) + ASSERT(!m_context->usesNetworkProcess()); +#endif + + if (!m_downloadProxyMap) + m_downloadProxyMap = adoptPtr(new DownloadProxyMap(this)); + + return m_downloadProxyMap->createDownloadProxy(m_context.get()); +} + void WebProcessProxy::didNavigateWithNavigationData(uint64_t pageID, const WebNavigationDataStore& store, uint64_t frameID) { WebPageProxy* page = webPage(pageID); @@ -719,4 +617,72 @@ void WebProcessProxy::didUpdateHistoryTitle(uint64_t pageID, const String& title m_context->historyClient().didUpdateHistoryTitle(m_context.get(), page, title, url, frame); } +void WebProcessProxy::pageVisibilityChanged(WebKit::WebPageProxy *page) +{ +#if PLATFORM(MAC) + if (pageIsProcessSuppressible(page)) + m_processSuppressiblePages.add(page->pageID()); + else + m_processSuppressiblePages.remove(page->pageID()); + updateProcessSuppressionState(); +#else + UNUSED_PARAM(page); +#endif +} + +void WebProcessProxy::pagePreferencesChanged(WebKit::WebPageProxy *page) +{ +#if PLATFORM(MAC) + if (pageIsProcessSuppressible(page)) + m_processSuppressiblePages.add(page->pageID()); + else + m_processSuppressiblePages.remove(page->pageID()); + updateProcessSuppressionState(); +#else + UNUSED_PARAM(page); +#endif +} + +void WebProcessProxy::didSaveToPageCache() +{ + m_context->processDidCachePage(this); +} + +void WebProcessProxy::releasePageCache() +{ + if (canSendMessage()) + send(Messages::WebProcess::ReleasePageCache(), 0); +} + + +void WebProcessProxy::requestTermination() +{ + if (!isValid()) + return; + + ChildProcessProxy::terminate(); + + if (webConnection()) + webConnection()->didClose(); + + disconnect(); +} + + +void WebProcessProxy::enableSuddenTermination() +{ + if (!isValid()) + return; + + WebCore::enableSuddenTermination(); +} + +void WebProcessProxy::disableSuddenTermination() +{ + if (!isValid()) + return; + + WebCore::disableSuddenTermination(); +} + } // namespace WebKit |