Commit 455ac1e6 authored by weinig@apple.com's avatar weinig@apple.com

WebPageGroups should keep track of what processes they are being used by

https://bugs.webkit.org/show_bug.cgi?id=124556

Reviewed by Anders Carlsson.

* UIProcess/WebContextUserMessageCoders.h:
(WebKit::WebContextUserMessageEncoder::encode):
(WebKit::WebContextUserMessageDecoder::decode):
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::addProcess):
(WebKit::WebPageGroup::disconnectProcess):
* UIProcess/WebPageGroup.h:
(WebKit::WebPageGroup::sendToAllProcessesInGroup):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::initializeWebPage):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::disconnect):
(WebKit::WebProcessProxy::webPageGroup):
(WebKit::WebProcessProxy::addWebPageGroup):
* UIProcess/WebProcessProxy.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::webPageGroup):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dcc738b3
2013-12-02 Sam Weinig <sam@webkit.org>
WebPageGroups should keep track of what processes they are being used by
https://bugs.webkit.org/show_bug.cgi?id=124556
Reviewed by Anders Carlsson.
* UIProcess/WebContextUserMessageCoders.h:
(WebKit::WebContextUserMessageEncoder::encode):
(WebKit::WebContextUserMessageDecoder::decode):
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::addProcess):
(WebKit::WebPageGroup::disconnectProcess):
* UIProcess/WebPageGroup.h:
(WebKit::WebPageGroup::sendToAllProcessesInGroup):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::initializeWebPage):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::disconnect):
(WebKit::WebProcessProxy::webPageGroup):
(WebKit::WebProcessProxy::addWebPageGroup):
* UIProcess/WebProcessProxy.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::webPageGroup):
2013-12-02 Anders Carlsson <andersca@apple.com>
Add versioned structs for all clients except the ones in WKContext.h
......
......@@ -76,6 +76,8 @@ public:
}
case API::Object::Type::PageGroup: {
WebPageGroup* pageGroup = static_cast<WebPageGroup*>(m_root);
if (pageGroup->addProcess(m_process))
m_process.addWebPageGroup(*pageGroup);
encoder << pageGroup->data();
break;
}
......@@ -145,7 +147,7 @@ public:
uint64_t pageGroupID;
if (!decoder.decode(pageGroupID))
return false;
coder.m_root = WebPageGroup::get(pageGroupID);
coder.m_root = coder.m_process.webPageGroup(pageGroupID);
break;
}
#if PLATFORM(MAC)
......
......@@ -194,4 +194,14 @@ void WebPageGroup::removeAllUserContent()
sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserContent(), m_data.pageGroupID);
}
bool WebPageGroup::addProcess(WebProcessProxy& process)
{
return m_processes.add(&process).isNewEntry;
}
void WebPageGroup::disconnectProcess(WebProcessProxy& process)
{
m_processes.remove(&process);
}
} // namespace WebKit
......@@ -65,26 +65,24 @@ public:
void removeAllUserScripts();
void removeAllUserContent();
bool addProcess(WebProcessProxy&);
void disconnectProcess(WebProcessProxy&);
private:
template<typename T> void sendToAllProcessesInGroup(const T&, uint64_t destinationID);
WebPageGroupData m_data;
mutable RefPtr<WebPreferences> m_preferences;
HashSet<WebPageProxy*> m_pages;
HashSet<WebProcessProxy*> m_processes;
};
template<typename T>
void WebPageGroup::sendToAllProcessesInGroup(const T& message, uint64_t destinationID)
{
HashSet<WebProcessProxy*> processesSeen;
for (WebPageProxy* webPageProxy : m_pages) {
WebProcessProxy& webProcessProxy = webPageProxy->process();
if (!processesSeen.add(&webProcessProxy).isNewEntry)
continue;
if (webProcessProxy.canSendMessage())
webProcessProxy.send(T(message), destinationID);
for (auto webProcessProxy : m_processes) {
if (webProcessProxy->canSendMessage())
webProcessProxy->send(T(message), destinationID);
}
}
......
......@@ -514,21 +514,24 @@ void WebPageProxy::initializeWebPage()
ASSERT(m_drawingArea);
#if ENABLE(INSPECTOR_SERVER)
if (m_pageGroup->preferences()->developerExtrasEnabled())
if (pageGroup().preferences()->developerExtrasEnabled())
inspector()->enableRemoteInspection();
#endif
if (pageGroup().addProcess(process()))
process().addWebPageGroup(pageGroup());
initializeCreationParameters();
m_process->send(Messages::WebProcess::CreateWebPage(m_pageID, m_creationParameters), 0);
process().send(Messages::WebProcess::CreateWebPage(m_pageID, m_creationParameters), 0);
#if ENABLE(PAGE_VISIBILITY_API)
m_process->send(Messages::WebPage::SetVisibilityState(m_visibilityState, /* isInitialState */ true), m_pageID);
process().send(Messages::WebPage::SetVisibilityState(m_visibilityState, /* isInitialState */ true), m_pageID);
#elif ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
m_process->send(Messages::WebPage::SetVisibilityState(isViewVisible() ? PageVisibilityStateVisible : PageVisibilityStateHidden, /* isInitialState */ true), m_pageID);
process().send(Messages::WebPage::SetVisibilityState(isViewVisible() ? PageVisibilityStateVisible : PageVisibilityStateHidden, /* isInitialState */ true), m_pageID);
#endif
#if PLATFORM(MAC)
m_process->send(Messages::WebPage::SetSmartInsertDeleteEnabled(m_isSmartInsertDeleteEnabled), m_pageID);
process().send(Messages::WebPage::SetSmartInsertDeleteEnabled(m_isSmartInsertDeleteEnabled), m_pageID);
#endif
}
......
......@@ -37,6 +37,7 @@
#include "WebContext.h"
#include "WebNavigationDataStore.h"
#include "WebNotificationManagerProxy.h"
#include "WebPageGroup.h"
#include "WebPageProxy.h"
#include "WebPluginSiteDataManager.h"
#include "WebProcessMessages.h"
......@@ -144,11 +145,16 @@ void WebProcessProxy::disconnect()
Vector<RefPtr<WebFrameProxy>> frames;
copyValuesToVector(m_frameMap, frames);
for (size_t i = 0, size = frames.size(); i < size; ++i)
frames[i]->disconnect();
for (auto frame : frames)
frame->disconnect();
m_frameMap.clear();
Vector<WebPageGroup*> pageGroups;
copyValuesToVector(m_pageGroups, pageGroups);
for (auto pageGroup : pageGroups)
pageGroup->disconnectProcess(*this);
m_pageGroups.clear();
if (m_downloadProxyMap)
m_downloadProxyMap->processDidClose();
......@@ -209,6 +215,19 @@ Vector<WebPageProxy*> WebProcessProxy::pages() const
return result;
}
WebPageGroup* WebProcessProxy::webPageGroup(uint64_t pageGroupID)
{
if (!HashMap<uint64_t, WebPageGroup*>::isValidKey(pageGroupID))
return nullptr;
return m_pageGroups.get(pageGroupID);
}
void WebProcessProxy::addWebPageGroup(WebPageGroup& pageGroup)
{
m_pageGroups.add(pageGroup.pageGroupID(), &pageGroup);
}
WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) const
{
return m_backForwardListItemMap.get(itemID);
......
......@@ -82,6 +82,9 @@ public:
void removeWebPage(uint64_t pageID);
Vector<WebPageProxy*> pages() const;
WebPageGroup* webPageGroup(uint64_t pageGroupID);
void addWebPageGroup(WebPageGroup&);
WebBackForwardListItem* webBackForwardItem(uint64_t itemID) const;
ResponsivenessTimer* responsivenessTimer() { return &m_responsivenessTimer; }
......@@ -194,6 +197,7 @@ private:
WebPageProxyMap m_pageMap;
WebFrameProxyMap m_frameMap;
WebBackForwardListItemMap m_backForwardListItemMap;
HashMap<uint64_t, WebPageGroup*> m_pageGroups;
OwnPtr<DownloadProxyMap> m_downloadProxyMap;
......
......@@ -721,7 +721,7 @@ WebPageGroupProxy* WebProcess::webPageGroup(uint64_t pageGroupID)
WebPageGroupProxy* WebProcess::webPageGroup(const WebPageGroupData& pageGroupData)
{
HashMap<uint64_t, RefPtr<WebPageGroupProxy>>::AddResult result = m_pageGroupMap.add(pageGroupData.pageGroupID, nullptr);
auto result = m_pageGroupMap.add(pageGroupData.pageGroupID, nullptr);
if (result.isNewEntry) {
ASSERT(!result.iterator->value);
result.iterator->value = WebPageGroupProxy::create(pageGroupData);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment