Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (125601 => 125602)
--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2012-08-14 21:02:24 UTC (rev 125601)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2012-08-14 21:06:41 UTC (rev 125602)
@@ -98,7 +98,8 @@
if (!m_webContext)
return;
- RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_webContext->process());
+ // FIXME (Multi-WebProcess): Get rid of deprecatedSharedProcess.
+ RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_webContext->deprecatedSharedProcess());
m_webContext->downloadClient().didReceiveAuthenticationChallenge(m_webContext, this, authenticationChallengeProxy.get());
}
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (125601 => 125602)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-08-14 21:02:24 UTC (rev 125601)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-08-14 21:06:41 UTC (rev 125602)
@@ -254,7 +254,15 @@
{
m_downloadClient.initialize(client);
}
-
+
+WebProcessProxy* WebContext::deprecatedSharedProcess()
+{
+ ASSERT(m_processModel == ProcessModelSharedSecondaryProcess);
+ if (m_processes.isEmpty())
+ return 0;
+ return m_processes[0].get();
+}
+
void WebContext::languageChanged(void* context)
{
static_cast<WebContext*>(context)->languageChanged();
@@ -270,13 +278,21 @@
sendToAllProcesses(Messages::WebProcess::FullKeyboardAccessModeChanged(fullKeyboardAccessEnabled));
}
-void WebContext::ensureWebProcess()
+void WebContext::textCheckerStateChanged()
{
- if (m_process)
- return;
+ sendToAllProcesses(Messages::WebProcess::SetTextCheckerState(TextChecker::state()));
+}
- m_process = WebProcessProxy::create(this);
+void WebContext::ensureSharedWebProcess()
+{
+ if (m_processes.isEmpty())
+ m_processes.append(createNewWebProcess());
+}
+PassRefPtr<WebProcessProxy> WebContext::createNewWebProcess()
+{
+ RefPtr<WebProcessProxy> process = WebProcessProxy::create(this);
+
WebProcessCreationParameters parameters;
if (!injectedBundlePath().isEmpty()) {
@@ -320,31 +336,37 @@
RefPtr<APIObject> injectedBundleInitializationUserData = m_injectedBundleClient.getInjectedBundleInitializationUserData(this);
if (!injectedBundleInitializationUserData)
injectedBundleInitializationUserData = m_injectedBundleInitializationUserData;
- m_process->send(Messages::WebProcess::InitializeWebProcess(parameters, WebContextUserMessageEncoder(injectedBundleInitializationUserData.get())), 0);
+ process->send(Messages::WebProcess::InitializeWebProcess(parameters, WebContextUserMessageEncoder(injectedBundleInitializationUserData.get())), 0);
for (size_t i = 0; i != m_pendingMessagesToPostToInjectedBundle.size(); ++i) {
pair<String, RefPtr<APIObject> >& message = m_pendingMessagesToPostToInjectedBundle[i];
- m_process->deprecatedSend(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message.first, WebContextUserMessageEncoder(message.second.get())));
+ process->deprecatedSend(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message.first, WebContextUserMessageEncoder(message.second.get())));
}
+ // FIXME (Multi-WebProcess): What does this mean in the brave new world?
m_pendingMessagesToPostToInjectedBundle.clear();
+
+ return process.release();
}
void WebContext::warmInitialProcess()
{
- ensureWebProcess();
+ ASSERT(m_processes.isEmpty());
+ m_processes.append(createNewWebProcess());
}
void WebContext::enableProcessTermination()
{
m_processTerminationEnabled = true;
- if (shouldTerminate(m_process.get()))
- m_process->terminate();
+ Vector<RefPtr<WebProcessProxy> > processes = m_processes;
+ for (size_t i = 0; i < processes.size(); ++i) {
+ if (shouldTerminate(processes[i].get()))
+ processes[i]->terminate();
+ }
}
bool WebContext::shouldTerminate(WebProcessProxy* process)
{
- // FIXME: Once we support multiple processes per context, this assertion won't hold.
- ASSERT(process == m_process);
+ ASSERT(m_processes.contains(process));
if (!m_processTerminationEnabled)
return false;
@@ -374,8 +396,7 @@
void WebContext::processDidFinishLaunching(WebProcessProxy* process)
{
- // FIXME: Once we support multiple processes per context, this assertion won't hold.
- ASSERT_UNUSED(process, process == m_process);
+ ASSERT(m_processes.contains(process));
m_visitedLinkProvider.processDidFinishLaunching();
@@ -387,7 +408,7 @@
String sampleLogFilePath = String::format("WebProcess%llu", static_cast<unsigned long long>(now));
sampleLogFilePath = SandboxExtension::createHandleForTemporaryFile(sampleLogFilePath, SandboxExtension::WriteOnly, sampleLogSandboxHandle);
- m_process->send(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, m_memorySamplerInterval), 0);
+ process->send(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, m_memorySamplerInterval), 0);
}
m_connectionClient.didCreateConnection(this, process->webConnection());
@@ -395,8 +416,7 @@
void WebContext::disconnectProcess(WebProcessProxy* process)
{
- // FIXME: Once we support multiple processes per context, this assertion won't hold.
- ASSERT_UNUSED(process, process == m_process);
+ ASSERT(m_processes.contains(process));
m_visitedLinkProvider.processDidClose();
@@ -438,53 +458,74 @@
#endif
// This can cause the web context to be destroyed.
- m_process = 0;
+ m_processes.remove(m_processes.find(process));
}
PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient* pageClient, WebPageGroup* pageGroup)
{
- ensureWebProcess();
+ RefPtr<WebProcessProxy> process;
+ if (m_processModel == ProcessModelSharedSecondaryProcess) {
+ ensureSharedWebProcess();
+ process = m_processes[0];
+ } else {
+ // FIXME (Multi-WebProcess): Add logic for sharing a process.
+ process = createNewWebProcess();
+ m_processes.append(process);
+ }
if (!pageGroup)
pageGroup = m_defaultPageGroup.get();
- return m_process->createWebPage(pageClient, this, pageGroup);
+ return process->createWebPage(pageClient, this, pageGroup);
}
WebProcessProxy* WebContext::relaunchProcessIfNecessary()
{
- ensureWebProcess();
-
- ASSERT(m_process);
- return m_process.get();
+ if (m_processModel == ProcessModelSharedSecondaryProcess) {
+ ensureSharedWebProcess();
+ return m_processes[0].get();
+ } else {
+ // FIXME (Multi-WebProcess): What should this do in this model?
+ return 0;
+ }
}
DownloadProxy* WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request)
{
- ensureWebProcess();
+ if (m_processModel == ProcessModelSharedSecondaryProcess) {
+ ensureSharedWebProcess();
- DownloadProxy* download = createDownloadProxy();
- uint64_t initiatingPageID = initiatingPage ? initiatingPage->pageID() : 0;
+ DownloadProxy* download = createDownloadProxy();
+ uint64_t initiatingPageID = initiatingPage ? initiatingPage->pageID() : 0;
#if PLATFORM(QT)
- ASSERT(initiatingPage); // Our design does not suppport downloads without a WebPage.
- initiatingPage->handleDownloadRequest(download);
+ ASSERT(initiatingPage); // Our design does not suppport downloads without a WebPage.
+ initiatingPage->handleDownloadRequest(download);
#endif
- process()->send(Messages::WebProcess::DownloadRequest(download->downloadID(), initiatingPageID, request), 0);
- return download;
+ m_processes[0]->send(Messages::WebProcess::DownloadRequest(download->downloadID(), initiatingPageID, request), 0);
+ return download;
+
+ } else {
+ // FIXME: (Multi-WebProcess): Implement.
+ return 0;
+ }
}
void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
{
- if (!m_process || !m_process->canSendMessage()) {
- m_pendingMessagesToPostToInjectedBundle.append(std::make_pair(messageName, messageBody));
- return;
+ if (m_processModel == ProcessModelSharedSecondaryProcess) {
+ if (m_processes.isEmpty() || !m_processes[0]->canSendMessage()) {
+ m_pendingMessagesToPostToInjectedBundle.append(std::make_pair(messageName, messageBody));
+ return;
+ }
+
+ // FIXME: We should consider returning false from this function if the messageBody cannot
+ // be encoded.
+ m_processes[0]->deprecatedSend(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody)));
+ } else {
+ // FIXME (Multi-WebProcess): Implement.
}
-
- // FIXME: We should consider returning false from this function if the messageBody cannot
- // be encoded.
- m_process->deprecatedSend(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody)));
}
// InjectedBundle client
@@ -720,7 +761,7 @@
downloadProxy->didReceiveSyncDownloadProxyMessage(process->connection(), messageID, arguments, reply);
return;
}
-
+
if (messageID.is<CoreIPC::MessageClassWebIconDatabase>()) {
m_iconDatabase->didReceiveSyncMessage(process->connection(), messageID, arguments, reply);
return;
@@ -839,14 +880,20 @@
void WebContext::getWebCoreStatistics(PassRefPtr<DictionaryCallback> callback)
{
- if (!m_process) {
+ if (m_processModel == ProcessModelSharedSecondaryProcess) {
+ if (m_processes.isEmpty()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_dictionaryCallbacks.set(callbackID, callback.get());
+ m_processes[0]->send(Messages::WebProcess::GetWebCoreStatistics(callbackID), 0);
+
+ } else {
+ // FIXME (Multi-WebProcess): Implement.
callback->invalidate();
- return;
}
-
- uint64_t callbackID = callback->callbackID();
- m_dictionaryCallbacks.set(callbackID, callback.get());
- process()->send(Messages::WebProcess::GetWebCoreStatistics(callbackID), 0);
}
static PassRefPtr<MutableDictionary> createDictionaryFromHashMap(const HashMap<String, uint64_t>& map)
Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (125601 => 125602)
--- trunk/Source/WebKit2/UIProcess/WebContext.h 2012-08-14 21:02:24 UTC (rev 125601)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h 2012-08-14 21:06:41 UTC (rev 125602)
@@ -90,10 +90,12 @@
void initializeDownloadClient(const WKContextDownloadClient*);
ProcessModel processModel() const { return m_processModel; }
- WebProcessProxy* process() const { return m_process.get(); }
- template<typename U> bool sendToAllProcesses(const U& message);
- template<typename U> bool sendToAllProcessesRelaunchingThemIfNecessary(const U& message);
+ // FIXME (Multi-WebProcess): Remove. No code should assume that there is a shared process.
+ WebProcessProxy* deprecatedSharedProcess();
+
+ template<typename U> void sendToAllProcesses(const U& message);
+ template<typename U> void sendToAllProcessesRelaunchingThemIfNecessary(const U& message);
void processDidFinishLaunching(WebProcessProxy*);
@@ -198,7 +200,8 @@
String iconDatabasePath() const;
void setLocalStorageDirectory(const String& dir) { m_overrideLocalStorageDirectory = dir; }
- void ensureWebProcess();
+ void ensureSharedWebProcess();
+ PassRefPtr<WebProcessProxy> createNewWebProcess();
void warmInitialProcess();
bool shouldTerminate(WebProcessProxy*);
@@ -220,6 +223,8 @@
void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled);
+ void textCheckerStateChanged();
+
private:
WebContext(ProcessModel, const String& injectedBundlePath);
@@ -270,8 +275,7 @@
ProcessModel m_processModel;
- // FIXME: In the future, this should be one or more WebProcessProxies.
- RefPtr<WebProcessProxy> m_process;
+ Vector<RefPtr<WebProcessProxy> > m_processes;
RefPtr<WebPageGroup> m_defaultPageGroup;
@@ -346,19 +350,20 @@
HashMap<uint64_t, RefPtr<DictionaryCallback> > m_dictionaryCallbacks;
};
-template<typename U> inline bool WebContext::sendToAllProcesses(const U& message)
+template<typename U> inline void WebContext::sendToAllProcesses(const U& message)
{
- if (!m_process || !m_process->canSendMessage())
- return false;
-
- return m_process->send(message, 0);
+ size_t processCount = m_processes.size();
+ for (size_t i = 0; i < processCount; ++i) {
+ WebProcessProxy* process = m_processes[i].get();
+ if (process->canSendMessage())
+ process->send(message, 0);
+ }
}
-template<typename U> bool WebContext::sendToAllProcessesRelaunchingThemIfNecessary(const U& message)
+template<typename U> void WebContext::sendToAllProcessesRelaunchingThemIfNecessary(const U& message)
{
relaunchProcessIfNecessary();
-
- return m_process->send(message, 0);
+ sendToAllProcesses(message);
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (125601 => 125602)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2012-08-14 21:02:24 UTC (rev 125601)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2012-08-14 21:06:41 UTC (rev 125602)
@@ -183,8 +183,6 @@
PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup)
{
- ASSERT(context->process() == this);
-
uint64_t pageID = generatePageID();
RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, this, pageGroup, pageID);
m_pageMap.set(pageID, webPage.get());