haikuwebkit/Source/WebCore/page/ProcessWarming.h

42 lines
1.6 KiB
C
Raw Permalink Normal View History

/*
* Copyright (C) 2018 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
Prewarm FontDatabase on process swap https://bugs.webkit.org/show_bug.cgi?id=190312 Reviewed by Chris Dumez. Source/WebCore: Implement basic prewarming of FontDatabase. When the domain of the first page load on a new process is known we pass the list of font families previous used by that domain to the process. This is used to prewarm CoreText font database. Initialization (which involves lots of blocking IPC) happens outside the main thread so the fonts are ready to use when needed. * WebCore.xcodeproj/project.pbxproj: * page/PrewarmInformation.h: Added. (WebCore::PrewarmInformation::encode const): (WebCore::PrewarmInformation::decode): Add data structure for prewarm information with encode/decode support. * page/ProcessWarming.cpp: (WebCore::ProcessWarming::collectPrewarmInformation): (WebCore::ProcessWarming::prewarmWithInformation): Prewarming interface to be used from WebKit. * page/ProcessWarming.h: * platform/graphics/FontCache.cpp: (WebCore::FontCache::collectPrewarmInformation const): (WebCore::FontCache::prewarm): * platform/graphics/FontCache.h: * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontDatabase::collectionForFamily): (WebCore::FontDatabase::fontForPostScriptName): (WebCore::FontDatabase::clear): Add mutex for thread safe access. (WebCore::FontCache::createFontPlatformData): (WebCore::FontCache::collectPrewarmInformation const): Collect font families seen by this process. (WebCore::FontCache::prewarm): Prewarm FontDatabase in a dispatch queue. Source/WebKit: Add mechanism for caching prewarm information per domain on UI process side. This information is then passed to newly initialized web processes that are being used for the same domain. * UIProcess/WebPageProxy.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processForNavigationInternal): Pass prewarm information on process swap to the new process. (WebKit::WebProcessPool::didCollectPrewarmInformation): UI process side cache. * UIProcess/WebProcessPool.h: * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::didCollectPrewarmInformation): * UIProcess/WebProcessProxy.h: * UIProcess/WebProcessProxy.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::close): (WebKit::WebPage::didReceivePolicyDecision): Collect and cache prewarm information for the previous process on process swap. * WebProcess/WebProcess.cpp: (WebKit::WebProcess::prewarmGlobally): Renamed for clarity. (WebKit::WebProcess::prewarmWithDomainInformation): (WebKit::WebProcess::sendPrewarmInformation): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Canonical link: https://commits.webkit.org/205342@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-09 09:14:37 +00:00
#include "PrewarmInformation.h"
namespace WebCore {
class WEBCORE_EXPORT ProcessWarming {
public:
static void initializeNames();
Prewarm FontDatabase on process swap https://bugs.webkit.org/show_bug.cgi?id=190312 Reviewed by Chris Dumez. Source/WebCore: Implement basic prewarming of FontDatabase. When the domain of the first page load on a new process is known we pass the list of font families previous used by that domain to the process. This is used to prewarm CoreText font database. Initialization (which involves lots of blocking IPC) happens outside the main thread so the fonts are ready to use when needed. * WebCore.xcodeproj/project.pbxproj: * page/PrewarmInformation.h: Added. (WebCore::PrewarmInformation::encode const): (WebCore::PrewarmInformation::decode): Add data structure for prewarm information with encode/decode support. * page/ProcessWarming.cpp: (WebCore::ProcessWarming::collectPrewarmInformation): (WebCore::ProcessWarming::prewarmWithInformation): Prewarming interface to be used from WebKit. * page/ProcessWarming.h: * platform/graphics/FontCache.cpp: (WebCore::FontCache::collectPrewarmInformation const): (WebCore::FontCache::prewarm): * platform/graphics/FontCache.h: * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontDatabase::collectionForFamily): (WebCore::FontDatabase::fontForPostScriptName): (WebCore::FontDatabase::clear): Add mutex for thread safe access. (WebCore::FontCache::createFontPlatformData): (WebCore::FontCache::collectPrewarmInformation const): Collect font families seen by this process. (WebCore::FontCache::prewarm): Prewarm FontDatabase in a dispatch queue. Source/WebKit: Add mechanism for caching prewarm information per domain on UI process side. This information is then passed to newly initialized web processes that are being used for the same domain. * UIProcess/WebPageProxy.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processForNavigationInternal): Pass prewarm information on process swap to the new process. (WebKit::WebProcessPool::didCollectPrewarmInformation): UI process side cache. * UIProcess/WebProcessPool.h: * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::didCollectPrewarmInformation): * UIProcess/WebProcessProxy.h: * UIProcess/WebProcessProxy.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::close): (WebKit::WebPage::didReceivePolicyDecision): Collect and cache prewarm information for the previous process on process swap. * WebProcess/WebProcess.cpp: (WebKit::WebProcess::prewarmGlobally): Renamed for clarity. (WebKit::WebProcess::prewarmWithDomainInformation): (WebKit::WebProcess::sendPrewarmInformation): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Canonical link: https://commits.webkit.org/205342@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-09 09:14:37 +00:00
static void prewarmGlobally();
static PrewarmInformation collectPrewarmInformation();
static void prewarmWithInformation(const PrewarmInformation&);
};
}