Skip to content

Commit

Permalink
Clean up site isolation process selection logic
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270045
rdar://116202371

Reviewed by Charlie Wolfe.

This pulls the process selection and RemotePageProxy management logic from various places into BrowsingContextGroup.
I introduce a new abstraction, FrameProcess, that represents a frame's use of a particular process.
The WebFrameProxy retains a reference to a FrameProcess instead of a RemotePageProxy.  When a FrameProcess is created
or destroyed, the BrowsingContextGroup updates the containers of RemotePageProxy objects.
This change allows us to keep track of opened pages using structures that are more elegant and robust to handle
all possible combinations of window.open and iframe creation or destruction.

Two small changes are observable in site isolation API tests, but they are both progressions because of processes
and frames being managed more correctly in some cases.

* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::allowsFirstPartyForCookies):
* Source/WebKit/Shared/AuxiliaryProcess.cpp:
(WebKit::AuxiliaryProcess::allowsFirstPartyForCookies):
* Source/WebKit/Sources.txt:
* Source/WebKit/UIProcess/AuxiliaryProcessProxy.h:
* Source/WebKit/UIProcess/BrowsingContextGroup.cpp:
(WebKit::BrowsingContextGroup::ensureProcessForDomain):
(WebKit::BrowsingContextGroup::processForDomain):
(WebKit::BrowsingContextGroup::addFrameProcess):
(WebKit::BrowsingContextGroup::removeFrameProcess):
(WebKit::BrowsingContextGroup::addPage):
(WebKit::BrowsingContextGroup::removePage):
(WebKit::BrowsingContextGroup::forEachRemotePage):
(WebKit::BrowsingContextGroup::remotePageInProcess):
(WebKit::BrowsingContextGroup::takeRemotePageInProcessForProvisionalPage):
(WebKit::BrowsingContextGroup::transitionPageToRemotePage):
(WebKit::BrowsingContextGroup::addProcessForDomain): Deleted.
* Source/WebKit/UIProcess/BrowsingContextGroup.h:
* Source/WebKit/UIProcess/FrameProcess.cpp: Renamed from Source/WebKit/UIProcess/RemotePageProxyState.h.
(WebKit::FrameProcess::FrameProcess):
(WebKit::FrameProcess::~FrameProcess):
* Source/WebKit/UIProcess/FrameProcess.h: Copied from Source/WebKit/UIProcess/BrowsingContextGroup.h.
(WebKit::FrameProcess::domain const):
(WebKit::FrameProcess::process const):
(WebKit::FrameProcess::process):
(WebKit::FrameProcess::create):
* Source/WebKit/UIProcess/ProvisionalFrameProxy.cpp:
(WebKit::ProvisionalFrameProxy::ProvisionalFrameProxy):
(WebKit::ProvisionalFrameProxy::takeFrameProcess):
(WebKit::ProvisionalFrameProxy::process const):
(WebKit::ProvisionalFrameProxy::takeRemotePageProxy): Deleted.
* Source/WebKit/UIProcess/ProvisionalFrameProxy.h:
(WebKit::ProvisionalFrameProxy::process const): Deleted.
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
(WebKit::ProvisionalPageProxy::~ProvisionalPageProxy):
(WebKit::ProvisionalPageProxy::process):
(WebKit::ProvisionalPageProxy::setNavigation):
(WebKit::ProvisionalPageProxy::cancel):
(WebKit::ProvisionalPageProxy::initializeWebPage):
(WebKit::ProvisionalPageProxy::loadData):
(WebKit::ProvisionalPageProxy::loadRequest):
(WebKit::ProvisionalPageProxy::goToBackForwardItem):
(WebKit::ProvisionalPageProxy::didCreateMainFrame):
(WebKit::ProvisionalPageProxy::didPerformClientRedirect):
(WebKit::ProvisionalPageProxy::didStartProvisionalLoadForFrame):
(WebKit::ProvisionalPageProxy::didFailProvisionalLoadForFrame):
(WebKit::ProvisionalPageProxy::didCommitLoadForFrame):
(WebKit::ProvisionalPageProxy::didNavigateWithNavigationData):
(WebKit::ProvisionalPageProxy::didChangeProvisionalURLForFrame):
(WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionAsync):
(WebKit::ProvisionalPageProxy::decidePolicyForResponse):
(WebKit::ProvisionalPageProxy::didPerformServerRedirect):
(WebKit::ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame):
(WebKit::ProvisionalPageProxy::startURLSchemeTask):
(WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionSync):
(WebKit::ProvisionalPageProxy::logDiagnosticMessageFromWebProcess):
(WebKit::ProvisionalPageProxy::logDiagnosticMessageWithEnhancedPrivacyFromWebProcess):
(WebKit::ProvisionalPageProxy::logDiagnosticMessageWithValueDictionaryFromWebProcess):
(WebKit::ProvisionalPageProxy::backForwardAddItem):
(WebKit::ProvisionalPageProxy::didDestroyNavigation):
(WebKit::ProvisionalPageProxy::contentFilterDidBlockLoadForFrame):
(WebKit::ProvisionalPageProxy::messageSenderConnection const):
(WebKit::ProvisionalPageProxy::sendMessage):
(WebKit::ProvisionalPageProxy::sendMessageWithAsyncReply):
* Source/WebKit/UIProcess/ProvisionalPageProxy.h:
(WebKit::ProvisionalPageProxy::browsingContextGroup):
(WebKit::ProvisionalPageProxy::takeRemotePageProxyState): Deleted.
(WebKit::ProvisionalPageProxy::process): Deleted.
* Source/WebKit/UIProcess/RemotePageProxy.cpp:
(WebKit::RemotePageProxy::RemotePageProxy):
(WebKit::RemotePageProxy::injectPageIntoNewProcess):
(WebKit::RemotePageProxy::~RemotePageProxy):
* Source/WebKit/UIProcess/RemotePageProxy.h:
(WebKit::RemotePageProxy::create): Deleted.
* Source/WebKit/UIProcess/SuspendedPageProxy.cpp:
(WebKit::SuspendedPageProxy::SuspendedPageProxy):
(WebKit::SuspendedPageProxy::sendToAllProcesses):
* Source/WebKit/UIProcess/SuspendedPageProxy.h:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::WebFrameProxy):
(WebKit::WebFrameProxy::process const):
(WebKit::WebFrameProxy::processID const):
(WebKit::WebFrameProxy::didCreateSubframe):
(WebKit::WebFrameProxy::prepareForProvisionalNavigationInProcess):
(WebKit::WebFrameProxy::commitProvisionalFrame):
(WebKit::WebFrameProxy::setProcess):
(WebKit::WebFrameProxy::webPageIDInCurrentProcess):
(WebKit::WebFrameProxy::rootFrame):
(WebKit::WebFrameProxy::remotePageProxy const): Deleted.
* Source/WebKit/UIProcess/WebFrameProxy.h:
(WebKit::WebFrameProxy::create):
(WebKit::WebFrameProxy::process const): Deleted.
(WebKit::WebFrameProxy::setProcess): Deleted.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::suspendCurrentPageIfPossible):
(WebKit::WebPageProxy::swapToProvisionalPage):
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::loadRequestWithNavigationShared):
(WebKit::WebPageProxy::loadFile):
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision):
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::getAllFrameTrees):
(WebKit::WebPageProxy::forceRepaint):
(WebKit::WebPageProxy::didCreateMainFrame):
(WebKit::WebPageProxy::updateRemoteFrameSize):
(WebKit::WebPageProxy::forEachWebContentProcess):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::callAfterNextPresentationUpdate):
(WebKit::WebPageProxy::processForRegistrableDomain):
(WebKit::WebPageProxy::webPageIDInProcessForDomain const):
(WebKit::WebPageProxy::sendToWebPage):
(WebKit::WebPageProxy::addRemotePageProxy): Deleted.
(WebKit::WebPageProxy::removeRemotePageProxy): Deleted.
(WebKit::WebPageProxy::remotePageProxyForRegistrableDomain const): Deleted.
(WebKit::WebPageProxy::setRemotePageProxyInOpenerProcess): Deleted.
(WebKit::WebPageProxy::takeRemotePageProxyInOpenerProcessIfDomainEquals): Deleted.
(WebKit::WebPageProxy::removeOpenedRemotePageProxy): Deleted.
(WebKit::WebPageProxy::takeOpenedRemotePageProxyIfDomainEquals): Deleted.
(WebKit::WebPageProxy::addOpenedRemotePageProxy): Deleted.
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxyInternals.h:
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigation):
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addVisitedLinkStoreUser):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::WebFrame):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::m_unifiedTextReplacementController):
(WebKit::WebPage::~WebPage):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::indentation):
(TestWebKitAPI::printTree):
(TestWebKitAPI::checkFrameTreesInProcesses):
(TestWebKitAPI::findFramePID):
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/275551@main
  • Loading branch information
achristensen07 committed Mar 1, 2024
1 parent fcdb5d4 commit 4993196
Show file tree
Hide file tree
Showing 23 changed files with 520 additions and 351 deletions.
1 change: 1 addition & 0 deletions Source/WebKit/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ UIProcess/DisplayLinkProcessProxyClient.cpp
UIProcess/DrawingAreaProxy.cpp
UIProcess/FindStringCallbackAggregator.cpp
UIProcess/FrameLoadState.cpp
UIProcess/FrameProcess.cpp
UIProcess/GeolocationPermissionRequestManagerProxy.cpp
UIProcess/GeolocationPermissionRequestProxy.cpp
UIProcess/LegacyGlobalSettings.cpp
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class AuxiliaryProcessProxy
IPC::MessageReceiverMap m_messageReceiverMap;
bool m_alwaysRunsAtBackgroundPriority { false };
bool m_didBeginResponsivenessChecks { false };
WebCore::ProcessIdentifier m_processIdentifier { WebCore::ProcessIdentifier::generate() };
const WebCore::ProcessIdentifier m_processIdentifier { WebCore::ProcessIdentifier::generate() };
std::optional<UseLazyStop> m_delayedResponsivenessCheck;
MonotonicTime m_processStart;
ProcessThrottler m_throttler;
Expand Down
152 changes: 147 additions & 5 deletions Source/WebKit/UIProcess/BrowsingContextGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,169 @@
#include "config.h"
#include "BrowsingContextGroup.h"

#include "FrameProcess.h"
#include "PageLoadState.h"
#include "RemotePageProxy.h"
#include "WebFrameProxy.h"
#include "WebProcessProxy.h"

namespace WebKit {

BrowsingContextGroup::BrowsingContextGroup() = default;

WebProcessProxy* BrowsingContextGroup::processForDomain(const WebCore::RegistrableDomain& domain)
BrowsingContextGroup::~BrowsingContextGroup() = default;

Ref<FrameProcess> BrowsingContextGroup::ensureProcessForDomain(const WebCore::RegistrableDomain& domain, WebProcessProxy& process, const WebPreferences& preferences)
{
if (preferences.siteIsolationEnabled() || preferences.processSwapOnCrossSiteWindowOpenEnabled()) {
if (auto* existingProcess = processForDomain(domain)) {
ASSERT(existingProcess->process().coreProcessIdentifier() == process.coreProcessIdentifier());
return *existingProcess;
}
}
return FrameProcess::create(process, *this, domain, preferences);
}

FrameProcess* BrowsingContextGroup::processForDomain(const WebCore::RegistrableDomain& domain)
{
auto process = m_processMap.get(domain);
if (!process)
return nullptr;
if (process->state() == WebProcessProxy::State::Terminated)
if (process->process().state() == WebProcessProxy::State::Terminated)
return nullptr;
return process.get();
}

// FIXME: This needs a corresponding remove call when a process terminates. <rdar://116202371>
void BrowsingContextGroup::addProcessForDomain(const WebCore::RegistrableDomain& domain, WebProcessProxy& process)
void BrowsingContextGroup::addFrameProcess(FrameProcess& process)
{
ASSERT(!m_processMap.get(domain) || m_processMap.get(domain)->state() == WebProcessProxy::State::Terminated || m_processMap.get(domain) == &process);
auto& domain = process.domain();
ASSERT(!m_processMap.get(domain) || m_processMap.get(domain)->process().state() == WebProcessProxy::State::Terminated || m_processMap.get(domain) == &process);
m_processMap.set(domain, process);
for (auto& page : m_pages) {
if (domain == WebCore::RegistrableDomain(URL(page.currentURL())))
return;
auto& set = m_remotePages.ensure(page, [] {
return HashSet<std::unique_ptr<RemotePageProxy>> { };
}).iterator->value;
auto newRemotePage = makeUnique<RemotePageProxy>(page, process.process(), domain);
newRemotePage->injectPageIntoNewProcess();
#if ASSERT_ENABLED
for (auto& existingPage : set) {
ASSERT(existingPage->process().coreProcessIdentifier() != newRemotePage->process().coreProcessIdentifier() || existingPage->domain() != newRemotePage->domain());
ASSERT(existingPage->page() == newRemotePage->page());
}
#endif
set.add(WTFMove(newRemotePage));
}
}

void BrowsingContextGroup::removeFrameProcess(FrameProcess& process)
{
ASSERT(process.domain().isEmpty() || m_processMap.get(process.domain()).get() == &process);
m_processMap.remove(process.domain());

m_remotePages.removeIf([&] (auto& pair) {
auto& set = pair.value;
set.removeIf([&] (auto& remotePage) {
return remotePage->process().coreProcessIdentifier() == process.process().coreProcessIdentifier();
});
return set.isEmpty();
});
}

void BrowsingContextGroup::addPage(WebPageProxy& page)
{
ASSERT(!m_pages.contains(page));
m_pages.add(page);
auto& set = m_remotePages.ensure(page, [] {
return HashSet<std::unique_ptr<RemotePageProxy>> { };
}).iterator->value;
m_processMap.removeIf([&] (auto& pair) {
auto& domain = pair.key;
auto& process = pair.value;
if (!process) {
ASSERT_NOT_REACHED_WITH_MESSAGE("FrameProcess should remove itself in the destructor so we should never find a null WeakPtr");
return true;
}

if (domain == page.mainFrameOrOpenerDomain())
return false;
auto newRemotePage = makeUnique<RemotePageProxy>(page, process->process(), domain);
newRemotePage->injectPageIntoNewProcess();
#if ASSERT_ENABLED
for (auto& existingPage : set) {
ASSERT(existingPage->process().coreProcessIdentifier() != newRemotePage->process().coreProcessIdentifier() || existingPage->domain() != newRemotePage->domain());
ASSERT(existingPage->page() == newRemotePage->page());
}
#endif
set.add(WTFMove(newRemotePage));
return false;
});
}

void BrowsingContextGroup::removePage(WebPageProxy& page)
{
ASSERT(m_pages.contains(page));
m_pages.remove(page);

m_remotePages.take(page);
}

void BrowsingContextGroup::forEachRemotePage(const WebPageProxy& page, Function<void(RemotePageProxy&)>&& function)
{
auto it = m_remotePages.find(page);
if (it == m_remotePages.end())
return;
for (auto& remotePage : it->value) {
if (remotePage)
function(*remotePage);
}
}

RemotePageProxy* BrowsingContextGroup::remotePageInProcess(const WebPageProxy& page, const WebCore::RegistrableDomain& domain)
{
if (auto frameProcess = m_processMap.get(domain))
return remotePageInProcess(page, frameProcess->process());
return nullptr;
}

RemotePageProxy* BrowsingContextGroup::remotePageInProcess(const WebPageProxy& page, const WebProcessProxy& process)
{
auto it = m_remotePages.find(page);
if (it == m_remotePages.end())
return nullptr;
for (auto& remotePage : it->value) {
if (remotePage->process().coreProcessIdentifier() == process.coreProcessIdentifier())
return remotePage.get();
}
return nullptr;
}

std::unique_ptr<RemotePageProxy> BrowsingContextGroup::takeRemotePageInProcessForProvisionalPage(const WebPageProxy& page, const WebCore::RegistrableDomain& domain)
{
auto it = m_remotePages.find(page);
if (it == m_remotePages.end())
return nullptr;
auto* remotePage = remotePageInProcess(page, domain);
if (!remotePage)
return nullptr;
return it->value.take(remotePage);
}

void BrowsingContextGroup::transitionPageToRemotePage(WebPageProxy& page, const WebCore::RegistrableDomain& openerDomain)
{
auto& set = m_remotePages.ensure(page, [] {
return HashSet<std::unique_ptr<RemotePageProxy>> { };
}).iterator->value;

auto newRemotePage = makeUnique<RemotePageProxy>(page, page.process(), openerDomain, &page.messageReceiverRegistration());
#if ASSERT_ENABLED
for (auto& existingPage : set) {
ASSERT(existingPage->process().coreProcessIdentifier() != newRemotePage->process().coreProcessIdentifier() || existingPage->domain() != newRemotePage->domain());
ASSERT(existingPage->page() == newRemotePage->page());
}
#endif
set.add(WTFMove(newRemotePage));
}

} // namespace WebKit
30 changes: 26 additions & 4 deletions Source/WebKit/UIProcess/BrowsingContextGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,43 @@

#include <WebCore/RegistrableDomain.h>
#include <wtf/RefCounted.h>
#include <wtf/WeakHashMap.h>
#include <wtf/WeakListHashSet.h>

namespace WebKit {

class FrameProcess;
class RemotePageProxy;
class WebPageProxy;
class WebPreferences;
class WebProcessProxy;

class BrowsingContextGroup : public RefCounted<BrowsingContextGroup> {
class BrowsingContextGroup : public RefCounted<BrowsingContextGroup>, public CanMakeWeakPtr<BrowsingContextGroup> {
public:
static Ref<BrowsingContextGroup> create() { return adoptRef(*new BrowsingContextGroup()); }
~BrowsingContextGroup();

Ref<FrameProcess> ensureProcessForDomain(const WebCore::RegistrableDomain&, WebProcessProxy&, const WebPreferences&);
FrameProcess* processForDomain(const WebCore::RegistrableDomain&);
void addFrameProcess(FrameProcess&);
void removeFrameProcess(FrameProcess&);

void addPage(WebPageProxy&);
void removePage(WebPageProxy&);
void forEachRemotePage(const WebPageProxy&, Function<void(RemotePageProxy&)>&&);

RemotePageProxy* remotePageInProcess(const WebPageProxy&, const WebCore::RegistrableDomain&);
RemotePageProxy* remotePageInProcess(const WebPageProxy&, const WebProcessProxy&);

std::unique_ptr<RemotePageProxy> takeRemotePageInProcessForProvisionalPage(const WebPageProxy&, const WebCore::RegistrableDomain&);
void transitionPageToRemotePage(WebPageProxy&, const WebCore::RegistrableDomain& openerDomain);

WebProcessProxy* processForDomain(const WebCore::RegistrableDomain&);
void addProcessForDomain(const WebCore::RegistrableDomain&, WebProcessProxy&);
private:
BrowsingContextGroup();

HashMap<WebCore::RegistrableDomain, WeakPtr<WebProcessProxy>> m_processMap;
HashMap<WebCore::RegistrableDomain, WeakPtr<FrameProcess>> m_processMap;
WeakListHashSet<WebPageProxy> m_pages;
WeakHashMap<WebPageProxy, HashSet<std::unique_ptr<RemotePageProxy>>> m_remotePages;
};

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Apple Inc. All rights reserved.
* Copyright (C) 2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand All @@ -23,18 +23,30 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once
#include "config.h"
#include "FrameProcess.h"

#include "RemotePageProxy.h"
#include <WebCore/RegistrableDomain.h>
#include <wtf/HashMap.h>
#include "BrowsingContextGroup.h"
#include "WebPageProxy.h"
#include "WebPreferences.h"

namespace WebKit {

struct RemotePageProxyState {
HashMap<WebCore::RegistrableDomain, WeakPtr<RemotePageProxy>> domainToRemotePageProxyMap;
RefPtr<RemotePageProxy> remotePageProxyInOpenerProcess;
HashMap<WebPageProxyIdentifier, Ref<RemotePageProxy>> openedRemotePageProxies;
};
FrameProcess::FrameProcess(WebProcessProxy& process, BrowsingContextGroup& group, const WebCore::RegistrableDomain& domain, const WebPreferences& preferences)
: m_process(process)
, m_browsingContextGroup(group)
, m_domain(domain)
{
if (preferences.siteIsolationEnabled() || preferences.processSwapOnCrossSiteWindowOpenEnabled())
group.addFrameProcess(*this);
else
m_browsingContextGroup = nullptr;
}

FrameProcess::~FrameProcess()
{
if (m_browsingContextGroup)
m_browsingContextGroup->removeFrameProcess(*this);
}

}
57 changes: 57 additions & 0 deletions Source/WebKit/UIProcess/FrameProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2024 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include <WebCore/RegistrableDomain.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
#include <wtf/WeakPtr.h>

namespace WebKit {

class BrowsingContextGroup;
class WebPreferences;
class WebProcessProxy;

class FrameProcess : public RefCounted<FrameProcess>, public CanMakeWeakPtr<FrameProcess> {
public:
~FrameProcess();

const WebCore::RegistrableDomain& domain() const { return m_domain; }
const WebProcessProxy& process() const { return m_process.get(); }
WebProcessProxy& process() { return m_process.get(); }

private:
friend class BrowsingContextGroup; // FrameProcess should not be created except by BrowsingContextGroup.
static Ref<FrameProcess> create(WebProcessProxy& process, BrowsingContextGroup& group, const WebCore::RegistrableDomain& domain, const WebPreferences& preferences) { return adoptRef(*new FrameProcess(process, group, domain, preferences)); }
FrameProcess(WebProcessProxy&, BrowsingContextGroup&, const WebCore::RegistrableDomain&, const WebPreferences&);

Ref<WebProcessProxy> m_process;
WeakPtr<BrowsingContextGroup> m_browsingContextGroup;
const WebCore::RegistrableDomain m_domain;
};

}
21 changes: 11 additions & 10 deletions Source/WebKit/UIProcess/ProvisionalFrameProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,32 @@
#include "config.h"
#include "ProvisionalFrameProxy.h"

#include "RemotePageProxy.h"
#include "FrameProcess.h"
#include "VisitedLinkStore.h"
#include "WebFrameProxy.h"
#include "WebPageProxy.h"

namespace WebKit {

ProvisionalFrameProxy::ProvisionalFrameProxy(WebFrameProxy& frame, WebProcessProxy& process, RefPtr<RemotePageProxy>&& remotePageProxy)
ProvisionalFrameProxy::ProvisionalFrameProxy(WebFrameProxy& frame, Ref<FrameProcess>&& frameProcess)
: m_frame(frame)
, m_process(process)
, m_remotePageProxy(WTFMove(remotePageProxy))
, m_frameProcess(WTFMove(frameProcess))
, m_visitedLinkStore(frame.page()->visitedLinkStore())
, m_pageID(frame.page()->webPageID())
, m_webPageID(frame.page()->identifier())
, m_layerHostingContextIdentifier(WebCore::LayerHostingContextIdentifier::generate())
{
ASSERT(!m_remotePageProxy || m_remotePageProxy->process().coreProcessIdentifier() == process.coreProcessIdentifier());
m_process->markProcessAsRecentlyUsed();
process().markProcessAsRecentlyUsed();
}

ProvisionalFrameProxy::~ProvisionalFrameProxy() = default;

RefPtr<RemotePageProxy> ProvisionalFrameProxy::takeRemotePageProxy()
Ref<FrameProcess> ProvisionalFrameProxy::takeFrameProcess()
{
return std::exchange(m_remotePageProxy, nullptr);
return WTFMove(m_frameProcess);
}

WebProcessProxy& ProvisionalFrameProxy::process() const
{
return m_frameProcess->process();
}

Ref<WebProcessProxy> ProvisionalFrameProxy::protectedProcess() const
Expand Down
Loading

0 comments on commit 4993196

Please sign in to comment.