<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213214] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213214">213214</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2017-03-01 01:38:44 -0800 (Wed, 01 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move MemoryPressureHandler to WTF
&lt;https://webkit.org/b/168908&gt;

Reviewed by Sam Weinig.

Source/WebCore:

* CMakeLists.txt:
* PlatformMac.cmake:
* PlatformWin.cmake:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/ScriptController.cpp:
* history/PageCache.cpp:
* html/HTMLMediaElement.cpp:
* inspector/InspectorInstrumentation.h:
* inspector/InspectorMemoryAgent.h:
* page/FrameView.cpp:
* page/MemoryRelease.h:
* page/linux/ResourceUsageThreadLinux.cpp:
* platform/Linux.cmake:
* platform/graphics/FontCache.cpp:
* platform/graphics/WidthCache.h:
* platform/graphics/ca/TileController.cpp:
* platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
* platform/ios/LegacyTileCache.mm:
* platform/ios/LegacyTileGrid.mm:
* platform/ios/LegacyTileLayerPool.mm:
* platform/ios/TileControllerMemoryHandlerIOS.cpp:
* testing/Internals.cpp:

Source/WebKit2:

* NetworkProcess/NetworkProcess.h:
* NetworkProcess/mac/NetworkProcessMac.mm:
* PluginProcess/PluginProcess.cpp:
* Shared/linux/WebMemorySamplerLinux.cpp:
* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
* WebProcess/WebPage/ios/WebPageIOS.mm:

Source/WTF:

Move MemoryPressureHandler down to WTF so it can be used from JavaScriptCore.

I had to do a blind rewrite of the Windows memory checking timer since it can
no longer use WebCore::Timer. I also moved the Win32Handle helper class to WTF.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MemoryPressureHandler.cpp: Renamed from Source/WebCore/platform/MemoryPressureHandler.cpp.
(WTF::MemoryPressureHandler::singleton):
(WTF::MemoryPressureHandler::MemoryPressureHandler):
(WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
(WTF::toString):
(WTF::thresholdForPolicy):
(WTF::policyForFootprint):
(WTF::MemoryPressureHandler::measurementTimerFired):
(WTF::MemoryPressureHandler::beginSimulatedMemoryPressure):
(WTF::MemoryPressureHandler::endSimulatedMemoryPressure):
(WTF::MemoryPressureHandler::releaseMemory):
(WTF::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange):
(WTF::MemoryPressureHandler::install):
(WTF::MemoryPressureHandler::uninstall):
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
(WTF::MemoryPressureHandler::platformReleaseMemory):
(WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
(WTF::MemoryPressureHandler::platformInitialize):
* wtf/MemoryPressureHandler.h: Renamed from Source/WebCore/platform/MemoryPressureHandler.h.
(WTF::MemoryPressureHandler::setMemoryKillCallback):
(WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback):
(WTF::MemoryPressureHandler::setLowMemoryHandler):
(WTF::MemoryPressureHandler::isUnderMemoryPressure):
(WTF::MemoryPressureHandler::setUnderMemoryPressure):
(WTF::MemoryPressureHandler::ReliefLogger::ReliefLogger):
(WTF::MemoryPressureHandler::ReliefLogger::~ReliefLogger):
(WTF::MemoryPressureHandler::ReliefLogger::logString):
(WTF::MemoryPressureHandler::ReliefLogger::setLoggingEnabled):
(WTF::MemoryPressureHandler::ReliefLogger::loggingEnabled):
(WTF::MemoryPressureHandler::ReliefLogger::MemoryUsage::MemoryUsage):
* wtf/PlatformEfl.cmake:
* wtf/PlatformGTK.cmake:
* wtf/PlatformMac.cmake:
* wtf/PlatformWin.cmake:
* wtf/cocoa/MemoryPressureHandlerCocoa.mm: Renamed from Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm.
(WTF::MemoryPressureHandler::platformReleaseMemory):
(WTF::MemoryPressureHandler::install):
(WTF::MemoryPressureHandler::uninstall):
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
(WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
* wtf/linux/CurrentProcessMemoryStatus.cpp: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.cpp.
(WTF::systemPageSize):
(WTF::currentProcessMemoryStatus):
* wtf/linux/CurrentProcessMemoryStatus.h: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.h.
* wtf/linux/MemoryPressureHandlerLinux.cpp: Renamed from Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp.
(WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
* wtf/win/MemoryPressureHandlerWin.cpp: Renamed from Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp.
(WTF::MemoryPressureHandler::platformInitialize):
(WTF::MemoryPressureHandler::windowsMeasurementTimerFired):
(WTF::MemoryPressureHandler::platformReleaseMemory):
(WTF::MemoryPressureHandler::install):
(WTF::MemoryPressureHandler::uninstall):
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
(WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
* wtf/win/Win32Handle.h: Renamed from Source/WebCore/platform/win/Win32Handle.h.
(WTF::Win32Handle::Win32Handle):
(WTF::Win32Handle::~Win32Handle):
(WTF::Win32Handle::clear):
(WTF::Win32Handle::isValid):
(WTF::Win32Handle::get):
(WTF::Win32Handle::release):
(WTF::Win32Handle::operator=):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfCMakeListstxt">trunk/Source/WTF/wtf/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWTFwtfPlatformEflcmake">trunk/Source/WTF/wtf/PlatformEfl.cmake</a></li>
<li><a href="#trunkSourceWTFwtfPlatformGTKcmake">trunk/Source/WTF/wtf/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWTFwtfPlatformMaccmake">trunk/Source/WTF/wtf/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWTFwtfPlatformWincmake">trunk/Source/WTF/wtf/PlatformWin.cmake</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformMaccmake">trunk/Source/WebCore/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformWincmake">trunk/Source/WebCore/PlatformWin.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptControllercpp">trunk/Source/WebCore/bindings/js/ScriptController.cpp</a></li>
<li><a href="#trunkSourceWebCorehistoryPageCachecpp">trunk/Source/WebCore/history/PageCache.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorInstrumentationh">trunk/Source/WebCore/inspector/InspectorInstrumentation.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorMemoryAgenth">trunk/Source/WebCore/inspector/InspectorMemoryAgent.h</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepageMemoryReleaseh">trunk/Source/WebCore/page/MemoryRelease.h</a></li>
<li><a href="#trunkSourceWebCorepagelinuxResourceUsageThreadLinuxcpp">trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformLinuxcmake">trunk/Source/WebCore/platform/Linux.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCachecpp">trunk/Source/WebCore/platform/graphics/FontCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsWidthCacheh">trunk/Source/WebCore/platform/graphics/WidthCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileControllercpp">trunk/Source/WebCore/platform/graphics/ca/TileController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinMediaPlayerPrivateMediaFoundationh">trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileCachemm">trunk/Source/WebCore/platform/ios/LegacyTileCache.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileGridmm">trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileLayerPoolmm">trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileControllerMemoryHandlerIOScpp">trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcessh">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessmacNetworkProcessMacmm">trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessPluginProcesscpp">trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedlinuxWebMemorySamplerLinuxcpp">trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCompositingCoordinatorcpp">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfMemoryPressureHandlercpp">trunk/Source/WTF/wtf/MemoryPressureHandler.cpp</a></li>
<li><a href="#trunkSourceWTFwtfMemoryPressureHandlerh">trunk/Source/WTF/wtf/MemoryPressureHandler.h</a></li>
<li><a href="#trunkSourceWTFwtfcocoaMemoryPressureHandlerCocoamm">trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm</a></li>
<li>trunk/Source/WTF/wtf/linux/</li>
<li><a href="#trunkSourceWTFwtflinuxCurrentProcessMemoryStatuscpp">trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp</a></li>
<li><a href="#trunkSourceWTFwtflinuxCurrentProcessMemoryStatush">trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h</a></li>
<li><a href="#trunkSourceWTFwtflinuxMemoryPressureHandlerLinuxcpp">trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp</a></li>
<li><a href="#trunkSourceWTFwtfwinMemoryPressureHandlerWincpp">trunk/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp</a></li>
<li><a href="#trunkSourceWTFwtfwinWin32Handleh">trunk/Source/WTF/wtf/win/Win32Handle.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformMemoryPressureHandlercpp">trunk/Source/WebCore/platform/MemoryPressureHandler.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMemoryPressureHandlerh">trunk/Source/WebCore/platform/MemoryPressureHandler.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaMemoryPressureHandlerCocoamm">trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm</a></li>
<li>trunk/Source/WebCore/platform/linux/</li>
<li><a href="#trunkSourceWebCoreplatformwinMemoryPressureHandlerWincpp">trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformwinWin32Handleh">trunk/Source/WebCore/platform/win/Win32Handle.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WTF/ChangeLog        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,3 +1,83 @@
</span><ins>+2017-03-01  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Move MemoryPressureHandler to WTF
+        &lt;https://webkit.org/b/168908&gt;
+
+        Reviewed by Sam Weinig.
+
+        Move MemoryPressureHandler down to WTF so it can be used from JavaScriptCore.
+
+        I had to do a blind rewrite of the Windows memory checking timer since it can
+        no longer use WebCore::Timer. I also moved the Win32Handle helper class to WTF.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/MemoryPressureHandler.cpp: Renamed from Source/WebCore/platform/MemoryPressureHandler.cpp.
+        (WTF::MemoryPressureHandler::singleton):
+        (WTF::MemoryPressureHandler::MemoryPressureHandler):
+        (WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
+        (WTF::toString):
+        (WTF::thresholdForPolicy):
+        (WTF::policyForFootprint):
+        (WTF::MemoryPressureHandler::measurementTimerFired):
+        (WTF::MemoryPressureHandler::beginSimulatedMemoryPressure):
+        (WTF::MemoryPressureHandler::endSimulatedMemoryPressure):
+        (WTF::MemoryPressureHandler::releaseMemory):
+        (WTF::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange):
+        (WTF::MemoryPressureHandler::install):
+        (WTF::MemoryPressureHandler::uninstall):
+        (WTF::MemoryPressureHandler::holdOff):
+        (WTF::MemoryPressureHandler::respondToMemoryPressure):
+        (WTF::MemoryPressureHandler::platformReleaseMemory):
+        (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
+        (WTF::MemoryPressureHandler::platformInitialize):
+        * wtf/MemoryPressureHandler.h: Renamed from Source/WebCore/platform/MemoryPressureHandler.h.
+        (WTF::MemoryPressureHandler::setMemoryKillCallback):
+        (WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback):
+        (WTF::MemoryPressureHandler::setLowMemoryHandler):
+        (WTF::MemoryPressureHandler::isUnderMemoryPressure):
+        (WTF::MemoryPressureHandler::setUnderMemoryPressure):
+        (WTF::MemoryPressureHandler::ReliefLogger::ReliefLogger):
+        (WTF::MemoryPressureHandler::ReliefLogger::~ReliefLogger):
+        (WTF::MemoryPressureHandler::ReliefLogger::logString):
+        (WTF::MemoryPressureHandler::ReliefLogger::setLoggingEnabled):
+        (WTF::MemoryPressureHandler::ReliefLogger::loggingEnabled):
+        (WTF::MemoryPressureHandler::ReliefLogger::MemoryUsage::MemoryUsage):
+        * wtf/PlatformEfl.cmake:
+        * wtf/PlatformGTK.cmake:
+        * wtf/PlatformMac.cmake:
+        * wtf/PlatformWin.cmake:
+        * wtf/cocoa/MemoryPressureHandlerCocoa.mm: Renamed from Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm.
+        (WTF::MemoryPressureHandler::platformReleaseMemory):
+        (WTF::MemoryPressureHandler::install):
+        (WTF::MemoryPressureHandler::uninstall):
+        (WTF::MemoryPressureHandler::holdOff):
+        (WTF::MemoryPressureHandler::respondToMemoryPressure):
+        (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
+        * wtf/linux/CurrentProcessMemoryStatus.cpp: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.cpp.
+        (WTF::systemPageSize):
+        (WTF::currentProcessMemoryStatus):
+        * wtf/linux/CurrentProcessMemoryStatus.h: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.h.
+        * wtf/linux/MemoryPressureHandlerLinux.cpp: Renamed from Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp.
+        (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
+        * wtf/win/MemoryPressureHandlerWin.cpp: Renamed from Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp.
+        (WTF::MemoryPressureHandler::platformInitialize):
+        (WTF::MemoryPressureHandler::windowsMeasurementTimerFired):
+        (WTF::MemoryPressureHandler::platformReleaseMemory):
+        (WTF::MemoryPressureHandler::install):
+        (WTF::MemoryPressureHandler::uninstall):
+        (WTF::MemoryPressureHandler::holdOff):
+        (WTF::MemoryPressureHandler::respondToMemoryPressure):
+        (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
+        * wtf/win/Win32Handle.h: Renamed from Source/WebCore/platform/win/Win32Handle.h.
+        (WTF::Win32Handle::Win32Handle):
+        (WTF::Win32Handle::~Win32Handle):
+        (WTF::Win32Handle::clear):
+        (WTF::Win32Handle::isValid):
+        (WTF::Win32Handle::get):
+        (WTF::Win32Handle::release):
+        (WTF::Win32Handle::operator=):
+
</ins><span class="cx"> 2017-02-28  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Throttle requestAnimationFrame to 30fps in low power mode
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -340,6 +340,9 @@
</span><span class="cx">                 A8A47487151A825B004123FF /* WTFThreadData.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4737B151A825B004123FF /* WTFThreadData.h */; };
</span><span class="cx">                 A8A4748C151A8264004123FF /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4748B151A8264004123FF /* config.h */; };
</span><span class="cx">                 AD7C434B1DD2A4A70026888B /* Expected.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7C434A1DD2A4A70026888B /* Expected.h */; };
</span><ins>+                AD89B6B71E6415080090707F /* MemoryPressureHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD89B6B51E6415080090707F /* MemoryPressureHandler.cpp */; };
+                AD89B6B81E6415080090707F /* MemoryPressureHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = AD89B6B61E6415080090707F /* MemoryPressureHandler.h */; };
+                AD89B6BA1E64150F0090707F /* MemoryPressureHandlerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = AD89B6B91E64150F0090707F /* MemoryPressureHandlerCocoa.mm */; };
</ins><span class="cx">                 ADF2CE661E39F106006889DB /* MemoryFootprint.h in Headers */ = {isa = PBXBuildFile; fileRef = ADF2CE641E39F106006889DB /* MemoryFootprint.h */; };
</span><span class="cx">                 ADF2CE671E39F106006889DB /* MemoryFootprint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */; };
</span><span class="cx">                 B38FD7BD168953E80065C969 /* FeatureDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = B38FD7BC168953E80065C969 /* FeatureDefines.h */; };
</span><span class="lines">@@ -728,6 +731,9 @@
</span><span class="cx">                 A8A4737B151A825B004123FF /* WTFThreadData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFThreadData.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8A4748B151A8264004123FF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD7C434A1DD2A4A70026888B /* Expected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Expected.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                AD89B6B51E6415080090707F /* MemoryPressureHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryPressureHandler.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                AD89B6B61E6415080090707F /* MemoryPressureHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryPressureHandler.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                AD89B6B91E64150F0090707F /* MemoryPressureHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandlerCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 ADF2CE641E39F106006889DB /* MemoryFootprint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryFootprint.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryFootprint.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B38FD7BC168953E80065C969 /* FeatureDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeatureDefines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1022,6 +1028,8 @@
</span><span class="cx">                                 CD5497AB15857D0300B5BC30 /* MediaTime.h */,
</span><span class="cx">                                 ADF2CE641E39F106006889DB /* MemoryFootprint.h */,
</span><span class="cx">                                 ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */,
</span><ins>+                                AD89B6B51E6415080090707F /* MemoryPressureHandler.cpp */,
+                                AD89B6B61E6415080090707F /* MemoryPressureHandler.h */,
</ins><span class="cx">                                 A8A472CC151A825B004123FF /* MessageQueue.h */,
</span><span class="cx">                                 A8A472CD151A825B004123FF /* MetaAllocator.cpp */,
</span><span class="cx">                                 A8A472CE151A825B004123FF /* MetaAllocator.h */,
</span><span class="lines">@@ -1330,6 +1338,7 @@
</span><span class="cx">                 E4A0AD3B1A96251900536DF6 /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                AD89B6B91E64150F0090707F /* MemoryPressureHandlerCocoa.mm */,
</ins><span class="cx">                                 E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */,
</span><span class="cx">                         );
</span><span class="cx">                         path = cocoa;
</span><span class="lines">@@ -1578,6 +1587,7 @@
</span><span class="cx">                                 1C181C901D307AB800F5FA16 /* UTextProvider.h in Headers */,
</span><span class="cx">                                 1C181C921D307AB800F5FA16 /* UTextProviderLatin1.h in Headers */,
</span><span class="cx">                                 1C181C941D307AB800F5FA16 /* UTextProviderUTF16.h in Headers */,
</span><ins>+                                AD89B6B81E6415080090707F /* MemoryPressureHandler.h in Headers */,
</ins><span class="cx">                                 A8A4746A151A825B004123FF /* UTF8.h in Headers */,
</span><span class="cx">                                 A8A473B9151A825B004123FF /* utils.h in Headers */,
</span><span class="cx">                                 A8A4747D151A825B004123FF /* ValueCheck.h in Headers */,
</span><span class="lines">@@ -1713,6 +1723,7 @@
</span><span class="cx">                                 A8A47460151A825B004123FF /* CollatorDefault.cpp in Sources */,
</span><span class="cx">                                 A8A47463151A825B004123FF /* CollatorICU.cpp in Sources */,
</span><span class="cx">                                 0F8F2B92172E0103007DBDA5 /* CompilationThread.cpp in Sources */,
</span><ins>+                                AD89B6B71E6415080090707F /* MemoryPressureHandler.cpp in Sources */,
</ins><span class="cx">                                 515F794E1CFC9F4A00CCED93 /* CrossThreadCopier.cpp in Sources */,
</span><span class="cx">                                 A8A4739A151A825B004123FF /* CryptographicallyRandomNumber.cpp in Sources */,
</span><span class="cx">                                 E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */,
</span><span class="lines">@@ -1776,6 +1787,7 @@
</span><span class="cx">                                 0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */,
</span><span class="cx">                                 A8A47443151A825B004123FF /* StringStatics.cpp in Sources */,
</span><span class="cx">                                 93F1993E19D7958D00C2390B /* StringView.cpp in Sources */,
</span><ins>+                                AD89B6BA1E64150F0090707F /* MemoryPressureHandlerCocoa.mm in Sources */,
</ins><span class="cx">                                 93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */,
</span><span class="cx">                                 93934BD318A1E8C300D0D6A1 /* StringViewObjC.mm in Sources */,
</span><span class="cx">                                 A8A473B7151A825B004123FF /* strtod.cc in Sources */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/CMakeLists.txt (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CMakeLists.txt        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WTF/wtf/CMakeLists.txt        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx">     MathExtras.h
</span><span class="cx">     MediaTime.h
</span><span class="cx">     MemoryFootprint.h
</span><ins>+    MemoryPressureHandler.h
</ins><span class="cx">     MessageQueue.h
</span><span class="cx">     MetaAllocator.h
</span><span class="cx">     MetaAllocatorHandle.h
</span><span class="lines">@@ -206,6 +207,7 @@
</span><span class="cx">     MainThread.cpp
</span><span class="cx">     MediaTime.cpp
</span><span class="cx">     MemoryFootprint.cpp
</span><ins>+    MemoryPressureHandler.cpp
</ins><span class="cx">     MetaAllocator.cpp
</span><span class="cx">     MonotonicTime.cpp
</span><span class="cx">     NumberOfCores.cpp
</span></span></pre></div>
<a id="trunkSourceWTFwtfMemoryPressureHandlercppfromrev213211trunkSourceWebCoreplatformMemoryPressureHandlercpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/MemoryPressureHandler.cpp (from rev 213211, trunk/Source/WebCore/platform/MemoryPressureHandler.cpp) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MemoryPressureHandler.cpp                                (rev 0)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,228 @@
</span><ins>+/*
+ * Copyright (C) 2011-2017 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. ``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
+ * 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;MemoryPressureHandler.h&quot;
+
+#include &lt;wtf/MemoryFootprint.h&gt;
+
+#define LOG_CHANNEL_PREFIX Log
+
+namespace WTF {
+
+#if RELEASE_LOG_DISABLED
+WTFLogChannel LogMemoryPressure = { WTFLogChannelOn, &quot;MemoryPressure&quot; };
+#else
+WTFLogChannel LogMemoryPressure = { WTFLogChannelOn, &quot;MemoryPressure&quot;, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
+#endif
+
+WTF_EXPORT_PRIVATE bool MemoryPressureHandler::ReliefLogger::s_loggingEnabled = false;
+
+MemoryPressureHandler&amp; MemoryPressureHandler::singleton()
+{
+    static NeverDestroyed&lt;MemoryPressureHandler&gt; memoryPressureHandler;
+    return memoryPressureHandler;
+}
+
+MemoryPressureHandler::MemoryPressureHandler()
+#if OS(LINUX)
+    : m_holdOffTimer(RunLoop::main(), this, &amp;MemoryPressureHandler::holdOffTimerFired)
+#elif OS(WINDOWS)
+    : m_windowsMeasurementTimer(RunLoop::main(), this, &amp;MemoryPressureHandler::windowsMeasurementTimerFired)
+#endif
+{
+}
+
+void MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor(bool use)
+{
+    if (use) {
+        m_measurementTimer = std::make_unique&lt;RunLoop::Timer&lt;MemoryPressureHandler&gt;&gt;(RunLoop::main(), this, &amp;MemoryPressureHandler::measurementTimerFired);
+        m_measurementTimer-&gt;startRepeating(30);
+    } else
+        m_measurementTimer = nullptr;
+}
+
+#if !RELEASE_LOG_DISABLED
+static const char* toString(MemoryUsagePolicy policy)
+{
+    switch (policy) {
+    case MemoryUsagePolicy::Unrestricted: return &quot;Unrestricted&quot;;
+    case MemoryUsagePolicy::Conservative: return &quot;Conservative&quot;;
+    case MemoryUsagePolicy::Strict: return &quot;Strict&quot;;
+    case MemoryUsagePolicy::Panic: return &quot;Panic&quot;;
+    }
+}
+#endif
+
+static size_t thresholdForPolicy(MemoryUsagePolicy policy)
+{
+    switch (policy) {
+    case MemoryUsagePolicy::Conservative:
+        return 1 * GB;
+    case MemoryUsagePolicy::Strict:
+        return 2 * GB;
+    case MemoryUsagePolicy::Panic:
+#if CPU(X86_64) || CPU(ARM64)
+        return 4 * GB;
+#else
+        return 3 * GB;
+#endif
+    case MemoryUsagePolicy::Unrestricted:
+    default:
+        ASSERT_NOT_REACHED();
+        return 0;
+    }
+}
+
+static MemoryUsagePolicy policyForFootprint(size_t footprint)
+{
+    if (footprint &gt;= thresholdForPolicy(MemoryUsagePolicy::Panic))
+        return MemoryUsagePolicy::Panic;
+    if (footprint &gt;= thresholdForPolicy(MemoryUsagePolicy::Strict))
+        return MemoryUsagePolicy::Strict;
+    if (footprint &gt;= thresholdForPolicy(MemoryUsagePolicy::Conservative))
+        return MemoryUsagePolicy::Conservative;
+    return MemoryUsagePolicy::Unrestricted;
+}
+
+void MemoryPressureHandler::measurementTimerFired()
+{
+    auto footprint = memoryFootprint();
+    if (!footprint)
+        return;
+
+    RELEASE_LOG(MemoryPressure, &quot;Current memory footprint: %lu MB&quot;, footprint.value() / MB);
+
+    auto newPolicy = policyForFootprint(footprint.value());
+    if (newPolicy == m_memoryUsagePolicy) {
+        if (m_memoryUsagePolicy != MemoryUsagePolicy::Panic)
+            return;
+        RELEASE_LOG(MemoryPressure, &quot;Memory usage still above panic threshold&quot;);
+    } else
+        RELEASE_LOG(MemoryPressure, &quot;Memory usage policy changed: %s -&gt; %s&quot;, toString(m_memoryUsagePolicy), toString(newPolicy));
+
+    m_memoryUsagePolicy = newPolicy;
+
+    if (newPolicy == MemoryUsagePolicy::Unrestricted)
+        return;
+
+    if (newPolicy == MemoryUsagePolicy::Conservative) {
+        // FIXME: Implement this policy by choosing which caches should respect it, and hooking them up.
+        return;
+    }
+
+    if (newPolicy == MemoryUsagePolicy::Strict) {
+        RELEASE_LOG(MemoryPressure, &quot;Attempting to reduce memory footprint by freeing less important objects.&quot;);
+        releaseMemory(Critical::No, Synchronous::No);
+        return;
+    }
+
+    RELEASE_ASSERT(newPolicy == MemoryUsagePolicy::Panic);
+
+    RELEASE_LOG(MemoryPressure, &quot;Attempting to reduce memory footprint by freeing more important objects.&quot;);
+    if (m_processIsEligibleForMemoryKillCallback) {
+        if (!m_processIsEligibleForMemoryKillCallback()) {
+            releaseMemory(Critical::Yes, Synchronous::No);
+            return;
+        }
+    }
+
+    releaseMemory(Critical::Yes, Synchronous::Yes);
+
+    // Remeasure footprint to see how well the pressure handler did.
+    footprint = memoryFootprint();
+    RELEASE_ASSERT(footprint);
+
+    RELEASE_LOG(MemoryPressure, &quot;New memory footprint: %lu MB&quot;, footprint.value() / MB);
+    if (footprint.value() &lt; thresholdForPolicy(MemoryUsagePolicy::Panic)) {
+        m_memoryUsagePolicy = policyForFootprint(footprint.value());
+        RELEASE_LOG(MemoryPressure, &quot;Pressure reduced below panic threshold. New memory usage policy: %s&quot;, toString(m_memoryUsagePolicy));
+        return;
+    }
+
+    if (m_memoryKillCallback)
+        m_memoryKillCallback();
+}
+
+void MemoryPressureHandler::beginSimulatedMemoryPressure()
+{
+    m_isSimulatingMemoryPressure = true;
+    respondToMemoryPressure(Critical::Yes, Synchronous::Yes);
+}
+
+void MemoryPressureHandler::endSimulatedMemoryPressure()
+{
+    m_isSimulatingMemoryPressure = false;
+}
+
+void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous)
+{
+    if (!m_lowMemoryHandler)
+        return;
+
+    ReliefLogger log(&quot;Total&quot;);
+    m_lowMemoryHandler(critical, synchronous);
+    platformReleaseMemory(critical);
+}
+
+void MemoryPressureHandler::ReliefLogger::logMemoryUsageChange()
+{
+#if !RELEASE_LOG_DISABLED
+#define STRING_SPECIFICATION &quot;%{public}s&quot;
+#define MEMORYPRESSURE_LOG(...) RELEASE_LOG(MemoryPressure, __VA_ARGS__)
+#else
+#define STRING_SPECIFICATION &quot;%s&quot;
+#define MEMORYPRESSURE_LOG(...) WTFLogAlways(__VA_ARGS__)
+#endif
+
+    auto currentMemory = platformMemoryUsage();
+    if (!currentMemory || !m_initialMemory) {
+        MEMORYPRESSURE_LOG(&quot;Memory pressure relief: &quot; STRING_SPECIFICATION &quot;: (Unable to get dirty memory information for process)&quot;, m_logString);
+        return;
+    }
+
+    long residentDiff = currentMemory-&gt;resident - m_initialMemory-&gt;resident;
+    long physicalDiff = currentMemory-&gt;physical - m_initialMemory-&gt;physical;
+
+    MEMORYPRESSURE_LOG(&quot;Memory pressure relief: &quot; STRING_SPECIFICATION &quot;: res = %zu/%zu/%ld, res+swap = %zu/%zu/%ld&quot;,
+        m_logString,
+        m_initialMemory-&gt;resident, currentMemory-&gt;resident, residentDiff,
+        m_initialMemory-&gt;physical, currentMemory-&gt;physical, physicalDiff);
+}
+
+#if !PLATFORM(COCOA) &amp;&amp; !OS(LINUX) &amp;&amp; !PLATFORM(WIN)
+void MemoryPressureHandler::install() { }
+void MemoryPressureHandler::uninstall() { }
+void MemoryPressureHandler::holdOff(unsigned) { }
+void MemoryPressureHandler::respondToMemoryPressure(Critical, Synchronous) { }
+void MemoryPressureHandler::platformReleaseMemory(Critical) { }
+std::optional&lt;MemoryPressureHandler::ReliefLogger::MemoryUsage&gt; MemoryPressureHandler::ReliefLogger::platformMemoryUsage() { return std::nullopt; }
+#endif
+
+#if !PLATFORM(WIN)
+void MemoryPressureHandler::platformInitialize() { }
+#endif
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWTFwtfMemoryPressureHandlerhfromrev213211trunkSourceWebCoreplatformMemoryPressureHandlerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/MemoryPressureHandler.h (from rev 213211, trunk/Source/WebCore/platform/MemoryPressureHandler.h) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MemoryPressureHandler.h                                (rev 0)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,213 @@
</span><ins>+/*
+ * Copyright (C) 2011-2017 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2014 Raspberry Pi Foundation. 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. ``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
+ * 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 &lt;atomic&gt;
+#include &lt;ctime&gt;
+#include &lt;functional&gt;
+#include &lt;wtf/FastMalloc.h&gt;
+#include &lt;wtf/Forward.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+#include &lt;wtf/Optional.h&gt;
+#include &lt;wtf/RunLoop.h&gt;
+
+#if USE(GLIB)
+#include &lt;wtf/glib/GRefPtr.h&gt;
+#endif
+
+#if PLATFORM(WIN)
+#include &lt;wtf/win/Win32Handle.h&gt;
+#endif
+
+namespace WTF {
+
+enum class MemoryUsagePolicy {
+    Unrestricted, // Allocate as much as you want
+    Conservative, // Maybe you don't cache every single thing
+    Strict, // Time to start pinching pennies for real
+    Panic, // OH GOD WE'RE SINKING, THROW EVERYTHING OVERBOARD
+};
+
+enum class Critical { No, Yes };
+enum class Synchronous { No, Yes };
+
+typedef std::function&lt;void(Critical, Synchronous)&gt; LowMemoryHandler;
+
+class MemoryPressureHandler {
+    friend class WTF::NeverDestroyed&lt;MemoryPressureHandler&gt;;
+public:
+    WTF_EXPORT_PRIVATE static MemoryPressureHandler&amp; singleton();
+
+    WTF_EXPORT_PRIVATE void install();
+
+    WTF_EXPORT_PRIVATE void setShouldUsePeriodicMemoryMonitor(bool);
+
+    void setMemoryKillCallback(WTF::Function&lt;void()&gt; function) { m_memoryKillCallback = WTFMove(function); }
+    void setProcessIsEligibleForMemoryKillCallback(WTF::Function&lt;bool()&gt; function) { m_processIsEligibleForMemoryKillCallback = WTFMove(function); }
+
+    void setLowMemoryHandler(LowMemoryHandler&amp;&amp; handler)
+    {
+        m_lowMemoryHandler = WTFMove(handler);
+    }
+
+    bool isUnderMemoryPressure() const
+    {
+        return m_underMemoryPressure
+#if PLATFORM(MAC)
+            || m_memoryUsagePolicy &gt;= MemoryUsagePolicy::Strict
+#endif
+            || m_isSimulatingMemoryPressure;
+    }
+    void setUnderMemoryPressure(bool b) { m_underMemoryPressure = b; }
+
+#if OS(LINUX)
+    void setMemoryPressureMonitorHandle(int fd);
+#endif
+
+    class ReliefLogger {
+    public:
+        explicit ReliefLogger(const char *log)
+            : m_logString(log)
+            , m_initialMemory(loggingEnabled() ? platformMemoryUsage() : MemoryUsage { })
+        {
+        }
+
+        ~ReliefLogger()
+        {
+            if (loggingEnabled())
+                logMemoryUsageChange();
+        }
+
+
+        const char* logString() const { return m_logString; }
+        static void setLoggingEnabled(bool enabled) { s_loggingEnabled = enabled; }
+        static bool loggingEnabled()
+        {
+#if RELEASE_LOG_DISABLED
+            return s_loggingEnabled;
+#else
+            return true;
+#endif
+        }
+
+    private:
+        struct MemoryUsage {
+            MemoryUsage() = default;
+            MemoryUsage(size_t resident, size_t physical)
+                : resident(resident)
+                , physical(physical)
+            {
+            }
+            size_t resident { 0 };
+            size_t physical { 0 };
+        };
+        std::optional&lt;MemoryUsage&gt; platformMemoryUsage();
+        void logMemoryUsageChange();
+
+        const char* m_logString;
+        std::optional&lt;MemoryUsage&gt; m_initialMemory;
+
+        WTF_EXPORT_PRIVATE static bool s_loggingEnabled;
+    };
+
+    WTF_EXPORT_PRIVATE void releaseMemory(Critical, Synchronous = Synchronous::No);
+
+    WTF_EXPORT_PRIVATE void beginSimulatedMemoryPressure();
+    WTF_EXPORT_PRIVATE void endSimulatedMemoryPressure();
+
+private:
+    void uninstall();
+
+    void holdOff(unsigned);
+
+    MemoryPressureHandler();
+    ~MemoryPressureHandler() = delete;
+
+    void respondToMemoryPressure(Critical, Synchronous = Synchronous::No);
+    void platformReleaseMemory(Critical);
+    void platformInitialize();
+
+    NO_RETURN_DUE_TO_CRASH void didExceedMemoryLimitAndFailedToRecover();
+    void measurementTimerFired();
+
+#if OS(LINUX)
+    class EventFDPoller {
+        WTF_MAKE_NONCOPYABLE(EventFDPoller); WTF_MAKE_FAST_ALLOCATED;
+    public:
+        EventFDPoller(int fd, std::function&lt;void ()&gt;&amp;&amp; notifyHandler);
+        ~EventFDPoller();
+
+    private:
+        void readAndNotify() const;
+
+        std::optional&lt;int&gt; m_fd;
+        std::function&lt;void ()&gt; m_notifyHandler;
+#if USE(GLIB)
+        GRefPtr&lt;GSource&gt; m_source;
+#else
+        ThreadIdentifier m_threadID;
+#endif
+    };
+#endif
+
+    bool m_installed { false };
+    LowMemoryHandler m_lowMemoryHandler;
+
+    std::atomic&lt;bool&gt; m_underMemoryPressure;
+    bool m_isSimulatingMemoryPressure { false };
+
+    std::unique_ptr&lt;RunLoop::Timer&lt;MemoryPressureHandler&gt;&gt; m_measurementTimer;
+    MemoryUsagePolicy m_memoryUsagePolicy { MemoryUsagePolicy::Unrestricted };
+    WTF::Function&lt;void()&gt; m_memoryKillCallback;
+    WTF::Function&lt;bool()&gt; m_processIsEligibleForMemoryKillCallback;
+
+    WTFLogChannel m_logChannel;
+    
+#if OS(WINDOWS)
+    void windowsMeasurementTimerFired();
+    RunLoop::Timer&lt;MemoryPressureHandler&gt; m_windowsMeasurementTimer;
+    Win32Handle m_lowMemoryHandle;
+#endif
+
+#if OS(LINUX)
+    std::optional&lt;int&gt; m_eventFD;
+    std::optional&lt;int&gt; m_pressureLevelFD;
+    std::unique_ptr&lt;EventFDPoller&gt; m_eventFDPoller;
+    RunLoop::Timer&lt;MemoryPressureHandler&gt; m_holdOffTimer;
+    void holdOffTimerFired();
+    void logErrorAndCloseFDs(const char* error);
+    bool tryEnsureEventFD();
+#endif
+};
+
+extern WTFLogChannel LogMemoryPressure;
+
+} // namespace WTF
+
+using WTF::Critical;
+using WTF::MemoryPressureHandler;
+using WTF::Synchronous;
</ins></span></pre></div>
<a id="trunkSourceWTFwtfPlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformEfl.cmake (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformEfl.cmake        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WTF/wtf/PlatformEfl.cmake        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -10,6 +10,9 @@
</span><span class="cx">     efl/WorkQueueEfl.cpp
</span><span class="cx"> 
</span><span class="cx">     glib/GRefPtr.cpp
</span><ins>+
+    linux/CurrentProcessMemoryStatus.cpp
+    linux/MemoryPressureHandlerLinux.cpp
</ins><span class="cx"> )
</span><span class="cx"> 
</span><span class="cx"> list(APPEND WTF_LIBRARIES
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformGTK.cmake (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformGTK.cmake        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WTF/wtf/PlatformGTK.cmake        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -7,6 +7,10 @@
</span><span class="cx">     glib/GRefPtr.cpp
</span><span class="cx">     glib/MainThreadGLib.cpp
</span><span class="cx">     glib/RunLoopGLib.cpp
</span><ins>+
+    linux/CurrentProcessMemoryStatus.cpp
+    linux/MemoryPressureHandlerLinux.cpp
+
</ins><span class="cx">     PlatformUserPreferredLanguagesUnix.cpp
</span><span class="cx">     UniStdExtras.cpp
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformMac.cmake (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformMac.cmake        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WTF/wtf/PlatformMac.cmake        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx"> 
</span><span class="cx">     cf/RunLoopCF.cpp
</span><span class="cx"> 
</span><ins>+    cocoa/MemoryPressureHandlerCocoa.mm
</ins><span class="cx">     cocoa/WorkQueueCocoa.cpp
</span><span class="cx"> 
</span><span class="cx">     mac/DeprecatedSymbolsUsedBySafari.mm
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformWincmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformWin.cmake (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformWin.cmake        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WTF/wtf/PlatformWin.cmake        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -9,6 +9,7 @@
</span><span class="cx">     text/cf/StringViewCF.cpp
</span><span class="cx"> 
</span><span class="cx">     win/MainThreadWin.cpp
</span><ins>+    win/MemoryPressureHandlerWin.cpp
</ins><span class="cx">     win/RunLoopWin.cpp
</span><span class="cx">     win/WorkQueueWin.cpp
</span><span class="cx"> )
</span></span></pre></div>
<a id="trunkSourceWTFwtfcocoaMemoryPressureHandlerCocoammfromrev213211trunkSourceWebCoreplatformcocoaMemoryPressureHandlerCocoamm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm (from rev 213211, trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm                                (rev 0)
+++ trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,193 @@
</span><ins>+/*
+ * Copyright (C) 2011-2017 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. ``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
+ * 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.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;MemoryPressureHandler.h&quot;
+
+#import &lt;mach/mach.h&gt;
+#import &lt;mach/task_info.h&gt;
+#import &lt;malloc/malloc.h&gt;
+#import &lt;notify.h&gt;
+#import &lt;wtf/CurrentTime.h&gt;
+
+#define ENABLE_FMW_FOOTPRINT_COMPARISON 0
+
+extern &quot;C&quot; void cache_simulate_memory_warning_event(uint64_t);
+
+namespace WTF {
+
+void MemoryPressureHandler::platformReleaseMemory(Critical critical)
+{
+    if (critical == Critical::Yes &amp;&amp; (!isUnderMemoryPressure() || m_isSimulatingMemoryPressure)) {
+        // libcache listens to OS memory notifications, but for process suspension
+        // or memory pressure simulation, we need to prod it manually:
+        cache_simulate_memory_warning_event(DISPATCH_MEMORYPRESSURE_CRITICAL);
+    }
+}
+
+static dispatch_source_t _cache_event_source = 0;
+static dispatch_source_t _timer_event_source = 0;
+static int _notifyToken;
+
+// Disable memory event reception for a minimum of s_minimumHoldOffTime
+// seconds after receiving an event. Don't let events fire any sooner than
+// s_holdOffMultiplier times the last cleanup processing time. Effectively 
+// this is 1 / s_holdOffMultiplier percent of the time.
+// These value seems reasonable and testing verifies that it throttles frequent
+// low memory events, greatly reducing CPU usage.
+static const unsigned s_minimumHoldOffTime = 5;
+#if !PLATFORM(IOS)
+static const unsigned s_holdOffMultiplier = 20;
+#endif
+
+void MemoryPressureHandler::install()
+{
+    if (m_installed || _timer_event_source)
+        return;
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+#if PLATFORM(IOS)
+        _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_NORMAL | DISPATCH_MEMORYPRESSURE_WARN | DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
+#elif PLATFORM(MAC)
+        _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
+#endif
+
+        dispatch_set_context(_cache_event_source, this);
+        dispatch_source_set_event_handler(_cache_event_source, ^{
+            bool critical = true;
+#if PLATFORM(IOS)
+            unsigned long status = dispatch_source_get_data(_cache_event_source);
+            critical = status == DISPATCH_MEMORYPRESSURE_CRITICAL;
+            auto&amp; memoryPressureHandler = MemoryPressureHandler::singleton();
+            bool wasCritical = memoryPressureHandler.isUnderMemoryPressure();
+            memoryPressureHandler.setUnderMemoryPressure(critical);
+            if (status == DISPATCH_MEMORYPRESSURE_NORMAL) {
+                if (ReliefLogger::loggingEnabled())
+                    NSLog(@&quot;System is no longer under (%s) memory pressure.&quot;, wasCritical ? &quot;critical&quot; : &quot;non-critical&quot;);
+                return;
+            }
+
+            if (ReliefLogger::loggingEnabled())
+                NSLog(@&quot;Got memory pressure notification (%s)&quot;, critical ? &quot;critical&quot; : &quot;non-critical&quot;);
+#endif
+            MemoryPressureHandler::singleton().respondToMemoryPressure(critical ? Critical::Yes : Critical::No);
+        });
+        dispatch_resume(_cache_event_source);
+    });
+
+    // Allow simulation of memory pressure with &quot;notifyutil -p org.WebKit.lowMemory&quot;
+    notify_register_dispatch(&quot;org.WebKit.lowMemory&quot;, &amp;_notifyToken, dispatch_get_main_queue(), ^(int) {
+#if ENABLE(FMW_FOOTPRINT_COMPARISON)
+        auto footprintBefore = pagesPerVMTag();
+#endif
+        beginSimulatedMemoryPressure();
+
+        WTF::releaseFastMallocFreeMemory();
+        malloc_zone_pressure_relief(nullptr, 0);
+
+#if ENABLE(FMW_FOOTPRINT_COMPARISON)
+        auto footprintAfter = pagesPerVMTag();
+        logFootprintComparison(footprintBefore, footprintAfter);
+#endif
+
+        dispatch_async(dispatch_get_main_queue(), ^{
+            endSimulatedMemoryPressure();
+        });
+    });
+
+    m_installed = true;
+}
+
+void MemoryPressureHandler::uninstall()
+{
+    if (!m_installed)
+        return;
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        if (_cache_event_source) {
+            dispatch_source_cancel(_cache_event_source);
+            dispatch_release(_cache_event_source);
+            _cache_event_source = 0;
+        }
+
+        if (_timer_event_source) {
+            dispatch_source_cancel(_timer_event_source);
+            dispatch_release(_timer_event_source);
+            _timer_event_source = 0;
+        }
+    });
+
+    m_installed = false;
+    
+    notify_cancel(_notifyToken);
+}
+
+void MemoryPressureHandler::holdOff(unsigned seconds)
+{
+    dispatch_async(dispatch_get_main_queue(), ^{
+        _timer_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
+        if (_timer_event_source) {
+            dispatch_set_context(_timer_event_source, this);
+            dispatch_source_set_timer(_timer_event_source, dispatch_time(DISPATCH_TIME_NOW, seconds * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, 1 * s_minimumHoldOffTime);
+            dispatch_source_set_event_handler(_timer_event_source, ^{
+                if (_timer_event_source) {
+                    dispatch_source_cancel(_timer_event_source);
+                    dispatch_release(_timer_event_source);
+                    _timer_event_source = 0;
+                }
+                MemoryPressureHandler::singleton().install();
+            });
+            dispatch_resume(_timer_event_source);
+        }
+    });
+}
+
+void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchronous synchronous)
+{
+#if !PLATFORM(IOS)
+    uninstall();
+    double startTime = monotonicallyIncreasingTime();
+#endif
+
+    releaseMemory(critical, synchronous);
+
+#if !PLATFORM(IOS)
+    unsigned holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
+    holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
+#endif
+}
+
+std::optional&lt;MemoryPressureHandler::ReliefLogger::MemoryUsage&gt; MemoryPressureHandler::ReliefLogger::platformMemoryUsage()
+{
+    task_vm_info_data_t vmInfo;
+    mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
+    kern_return_t err = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &amp;vmInfo, &amp;count);
+    if (err != KERN_SUCCESS)
+        return std::nullopt;
+
+    return MemoryUsage {static_cast&lt;size_t&gt;(vmInfo.internal), static_cast&lt;size_t&gt;(vmInfo.phys_footprint)};
+}
+
+} // namespace WTF
</ins></span></pre></div>
<a id="trunkSourceWTFwtflinuxCurrentProcessMemoryStatuscppfromrev213211trunkSourceWebCoreplatformlinuxCurrentProcessMemoryStatuscpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp (from rev 213211, trunk/Source/WebCore/platform/linux/CurrentProcessMemoryStatus.cpp) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp                                (rev 0)
+++ trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+/*
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;CurrentProcessMemoryStatus.h&quot;
+
+#if OS(LINUX)
+
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;unistd.h&gt;
+
+namespace WTF {
+
+static inline size_t systemPageSize()
+{
+    static size_t pageSize = 0;
+    if (!pageSize)
+        pageSize = sysconf(_SC_PAGE_SIZE);
+    return pageSize;
+}
+
+void currentProcessMemoryStatus(ProcessMemoryStatus&amp; memoryStatus)
+{
+    FILE* file = fopen(&quot;/proc/self/statm&quot;, &quot;r&quot;);
+    if (!file)
+        return;
+
+    char buffer[128];
+    char* line = fgets(buffer, 128, file);
+    fclose(file);
+    if (!line)
+        return;
+
+    size_t pageSize = systemPageSize();
+    char* end = nullptr;
+    unsigned long long intValue = strtoull(line, &amp;end, 10);
+    memoryStatus.size = intValue * pageSize;
+    intValue = strtoull(end, &amp;end, 10);
+    memoryStatus.resident = intValue * pageSize;
+    intValue = strtoull(end, &amp;end, 10);
+    memoryStatus.shared = intValue * pageSize;
+    intValue = strtoull(end, &amp;end, 10);
+    memoryStatus.text = intValue * pageSize;
+    intValue = strtoull(end, &amp;end, 10);
+    memoryStatus.lib = intValue * pageSize;
+    intValue = strtoull(end, &amp;end, 10);
+    memoryStatus.data = intValue * pageSize;
+    intValue = strtoull(end, &amp;end, 10);
+    memoryStatus.dt = intValue * pageSize;
+}
+
+} // namespace WTF
+
+#endif // OS(LINUX)
</ins></span></pre></div>
<a id="trunkSourceWTFwtflinuxCurrentProcessMemoryStatushfromrev213211trunkSourceWebCoreplatformlinuxCurrentProcessMemoryStatush"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h (from rev 213211, trunk/Source/WebCore/platform/linux/CurrentProcessMemoryStatus.h) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h                                (rev 0)
+++ trunk/Source/WTF/wtf/linux/CurrentProcessMemoryStatus.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * 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. ``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
+ * 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
+
+#if OS(LINUX)
+
+namespace WTF {
+
+struct ProcessMemoryStatus {
+    size_t size { 0 };
+    size_t resident { 0 };
+    size_t shared { 0 };
+    size_t text { 0 };
+    size_t lib { 0 };
+    size_t data { 0 };
+    size_t dt { 0 };
+};
+
+void currentProcessMemoryStatus(ProcessMemoryStatus&amp;);
+
+} // namespace WTF
+
+using WTF::ProcessMemoryStatus;
+using WTF::currentProcessMemoryStatus;
+
+#endif // OS(LINUX)
</ins></span></pre></div>
<a id="trunkSourceWTFwtflinuxMemoryPressureHandlerLinuxcppfromrev213211trunkSourceWebCoreplatformlinuxMemoryPressureHandlerLinuxcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp (from rev 213211, trunk/Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp                                (rev 0)
+++ trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,320 @@
</span><ins>+/*
+ * Copyright (C) 2011, 2012 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2014 Raspberry Pi Foundation. 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. ``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
+ * 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;MemoryPressureHandler.h&quot;
+
+#if OS(LINUX)
+
+#include &lt;errno.h&gt;
+#include &lt;fcntl.h&gt;
+#include &lt;malloc.h&gt;
+#include &lt;sys/eventfd.h&gt;
+#include &lt;sys/stat.h&gt;
+#include &lt;sys/types.h&gt;
+#include &lt;unistd.h&gt;
+#include &lt;wtf/CurrentTime.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/linux/CurrentProcessMemoryStatus.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+#if USE(GLIB)
+#include &lt;glib-unix.h&gt;
+#endif
+
+#define LOG_CHANNEL_PREFIX Log
+
+namespace WTF {
+
+// Disable memory event reception for a minimum of s_minimumHoldOffTime
+// seconds after receiving an event. Don't let events fire any sooner than
+// s_holdOffMultiplier times the last cleanup processing time. Effectively
+// this is 1 / s_holdOffMultiplier percent of the time.
+// If after releasing the memory we don't free at least s_minimumBytesFreedToUseMinimumHoldOffTime,
+// we wait longer to try again (s_maximumHoldOffTime).
+// These value seems reasonable and testing verifies that it throttles frequent
+// low memory events, greatly reducing CPU usage.
+static const unsigned s_minimumHoldOffTime = 5;
+static const unsigned s_maximumHoldOffTime = 30;
+static const size_t s_minimumBytesFreedToUseMinimumHoldOffTime = 1 * MB;
+static const unsigned s_holdOffMultiplier = 20;
+
+static const char* s_cgroupMemoryPressureLevel = &quot;/sys/fs/cgroup/memory/memory.pressure_level&quot;;
+static const char* s_cgroupEventControl = &quot;/sys/fs/cgroup/memory/cgroup.event_control&quot;;
+
+#if USE(GLIB)
+typedef struct {
+    GSource source;
+    gpointer fdTag;
+    GIOCondition condition;
+} EventFDSource;
+
+static const unsigned eventFDSourceCondition = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+
+static GSourceFuncs eventFDSourceFunctions = {
+    nullptr, // prepare
+    nullptr, // check
+    // dispatch
+    [](GSource* source, GSourceFunc callback, gpointer userData) -&gt; gboolean
+    {
+        EventFDSource* eventFDSource = reinterpret_cast&lt;EventFDSource*&gt;(source);
+        unsigned events = g_source_query_unix_fd(source, eventFDSource-&gt;fdTag) &amp; eventFDSourceCondition;
+        if (events &amp; G_IO_HUP || events &amp; G_IO_ERR || events &amp; G_IO_NVAL)
+            return G_SOURCE_REMOVE;
+
+        gboolean returnValue = G_SOURCE_CONTINUE;
+        if (events &amp; G_IO_IN)
+            returnValue = callback(userData);
+        g_source_set_ready_time(source, -1);
+        return returnValue;
+    },
+    nullptr, // finalize
+    nullptr, // closure_callback
+    nullptr, // closure_marshall
+};
+#endif
+
+MemoryPressureHandler::EventFDPoller::EventFDPoller(int fd, std::function&lt;void ()&gt;&amp;&amp; notifyHandler)
+    : m_fd(fd)
+    , m_notifyHandler(WTFMove(notifyHandler))
+{
+#if USE(GLIB)
+    m_source = adoptGRef(g_source_new(&amp;eventFDSourceFunctions, sizeof(EventFDSource)));
+    g_source_set_name(m_source.get(), &quot;WTF: MemoryPressureHandler&quot;);
+    if (!g_unix_set_fd_nonblocking(m_fd.value(), TRUE, nullptr)) {
+        LOG(MemoryPressure, &quot;Failed to set eventfd nonblocking&quot;);
+        return;
+    }
+
+    EventFDSource* eventFDSource = reinterpret_cast&lt;EventFDSource*&gt;(m_source.get());
+    eventFDSource-&gt;fdTag = g_source_add_unix_fd(m_source.get(), m_fd.value(), static_cast&lt;GIOCondition&gt;(eventFDSourceCondition));
+    g_source_set_callback(m_source.get(), [](gpointer userData) -&gt; gboolean {
+        static_cast&lt;EventFDPoller*&gt;(userData)-&gt;readAndNotify();
+        return G_SOURCE_REMOVE;
+    }, this, nullptr);
+    g_source_attach(m_source.get(), nullptr);
+#else
+    m_threadID = createThread(&quot;WTF: MemoryPressureHandler&quot;, [this] { readAndNotify(); }
+#endif
+}
+
+MemoryPressureHandler::EventFDPoller::~EventFDPoller()
+{
+    m_fd = std::nullopt;
+#if USE(GLIB)
+    g_source_destroy(m_source.get());
+#else
+    detachThread(m_threadID);
+#endif
+}
+
+static inline bool isFatalReadError(int error)
+{
+#if USE(GLIB)
+    // We don't really need to read the buffer contents, if the poller
+    // notified us, but read would block or is no longer available, is
+    // enough to trigger the memory pressure handler.
+    return error != EAGAIN &amp;&amp; error != EWOULDBLOCK;
+#else
+    return true;
+#endif
+}
+
+void MemoryPressureHandler::EventFDPoller::readAndNotify() const
+{
+    if (!m_fd) {
+        LOG(MemoryPressure, &quot;Invalidate eventfd.&quot;);
+        return;
+    }
+
+    uint64_t buffer;
+    if (read(m_fd.value(), &amp;buffer, sizeof(buffer)) == -1) {
+        if (isFatalReadError(errno)) {
+            LOG(MemoryPressure, &quot;Failed to read eventfd.&quot;);
+            return;
+        }
+    }
+
+    m_notifyHandler();
+}
+
+inline void MemoryPressureHandler::logErrorAndCloseFDs(const char* log)
+{
+    if (log)
+        LOG(MemoryPressure, &quot;%s, error : %m&quot;, log);
+
+    if (m_eventFD) {
+        close(m_eventFD.value());
+        m_eventFD = std::nullopt;
+    }
+    if (m_pressureLevelFD) {
+        close(m_pressureLevelFD.value());
+        m_pressureLevelFD = std::nullopt;
+    }
+}
+
+bool MemoryPressureHandler::tryEnsureEventFD()
+{
+    if (m_eventFD)
+        return true;
+
+    // Try to use cgroups instead.
+    int fd = eventfd(0, EFD_CLOEXEC);
+    if (fd == -1) {
+        LOG(MemoryPressure, &quot;eventfd() failed: %m&quot;);
+        return false;
+    }
+    m_eventFD = fd;
+
+    fd = open(s_cgroupMemoryPressureLevel, O_CLOEXEC | O_RDONLY);
+    if (fd == -1) {
+        logErrorAndCloseFDs(&quot;Failed to open memory.pressure_level&quot;);
+        return false;
+    }
+    m_pressureLevelFD = fd;
+
+    fd = open(s_cgroupEventControl, O_CLOEXEC | O_WRONLY);
+    if (fd == -1) {
+        logErrorAndCloseFDs(&quot;Failed to open cgroup.event_control&quot;);
+        return false;
+    }
+
+    char line[128] = {0, };
+    if (snprintf(line, sizeof(line), &quot;%d %d low&quot;, m_eventFD.value(), m_pressureLevelFD.value()) &lt; 0
+        || write(fd, line, strlen(line) + 1) &lt; 0) {
+        logErrorAndCloseFDs(&quot;Failed to write cgroup.event_control&quot;);
+        close(fd);
+        return false;
+    }
+    close(fd);
+
+    return true;
+}
+
+void MemoryPressureHandler::install()
+{
+    if (m_installed || m_holdOffTimer.isActive())
+        return;
+
+    if (!tryEnsureEventFD())
+        return;
+
+    m_eventFDPoller = std::make_unique&lt;EventFDPoller&gt;(m_eventFD.value(), [this] {
+        // FIXME: Current memcg does not provide any way for users to know how serious the memory pressure is.
+        // So we assume all notifications from memcg are critical for now. If memcg had better inferfaces
+        // to get a detailed memory pressure level in the future, we should update here accordingly.
+        bool critical = true;
+        if (ReliefLogger::loggingEnabled())
+            LOG(MemoryPressure, &quot;Got memory pressure notification (%s)&quot;, critical ? &quot;critical&quot; : &quot;non-critical&quot;);
+
+        setUnderMemoryPressure(critical);
+        if (isMainThread())
+            respondToMemoryPressure(critical ? Critical::Yes : Critical::No);
+        else
+            RunLoop::main().dispatch([this, critical] { respondToMemoryPressure(critical ? Critical::Yes : Critical::No); });
+    });
+
+    if (ReliefLogger::loggingEnabled() &amp;&amp; isUnderMemoryPressure())
+        LOG(MemoryPressure, &quot;System is no longer under memory pressure.&quot;);
+
+    setUnderMemoryPressure(false);
+    m_installed = true;
+}
+
+void MemoryPressureHandler::uninstall()
+{
+    if (!m_installed)
+        return;
+
+    m_holdOffTimer.stop();
+    m_eventFDPoller = nullptr;
+
+    if (m_pressureLevelFD) {
+        close(m_pressureLevelFD.value());
+        m_pressureLevelFD = std::nullopt;
+
+        // Only close the eventFD used for cgroups.
+        if (m_eventFD) {
+            close(m_eventFD.value());
+            m_eventFD = std::nullopt;
+        }
+    }
+
+    m_installed = false;
+}
+
+void MemoryPressureHandler::holdOffTimerFired()
+{
+    install();
+}
+
+void MemoryPressureHandler::holdOff(unsigned seconds)
+{
+    m_holdOffTimer.startOneShot(seconds);
+}
+
+static size_t processMemoryUsage()
+{
+    ProcessMemoryStatus memoryStatus;
+    currentProcessMemoryStatus(memoryStatus);
+    return (memoryStatus.resident - memoryStatus.shared);
+}
+
+void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchronous synchronous)
+{
+    uninstall();
+
+    double startTime = monotonicallyIncreasingTime();
+    int64_t processMemory = processMemoryUsage();
+    releaseMemory(critical, synchronous);
+    int64_t bytesFreed = processMemory - processMemoryUsage();
+    unsigned holdOffTime = s_maximumHoldOffTime;
+    if (bytesFreed &gt; 0 &amp;&amp; static_cast&lt;size_t&gt;(bytesFreed) &gt;= s_minimumBytesFreedToUseMinimumHoldOffTime)
+        holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
+    holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
+}
+
+void MemoryPressureHandler::platformReleaseMemory(Critical)
+{
+#ifdef __GLIBC__
+    malloc_trim(0);
+#endif
+}
+
+std::optional&lt;MemoryPressureHandler::ReliefLogger::MemoryUsage&gt; MemoryPressureHandler::ReliefLogger::platformMemoryUsage()
+{
+    return MemoryUsage {processMemoryUsage(), 0};
+}
+
+void MemoryPressureHandler::setMemoryPressureMonitorHandle(int fd)
+{
+    ASSERT(!m_eventFD);
+    m_eventFD = fd;
+}
+
+} // namespace WTF
+
+#endif // OS(LINUX)
</ins></span></pre></div>
<a id="trunkSourceWTFwtfwinMemoryPressureHandlerWincppfromrev213211trunkSourceWebCoreplatformwinMemoryPressureHandlerWincpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp (from rev 213211, trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp                                (rev 0)
+++ trunk/Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,104 @@
</span><ins>+/*
+ * Copyright (C) 2015 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. ``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
+ * 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;MemoryPressureHandler.h&quot;
+
+#include &lt;psapi.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+namespace WTF {
+
+void MemoryPressureHandler::platformInitialize()
+{
+    m_lowMemoryHandle = CreateMemoryResourceNotification(LowMemoryResourceNotification);
+}
+
+void MemoryPressureHandler::windowsMeasurementTimerFired()
+{
+    setUnderMemoryPressure(false);
+
+    BOOL memoryLow;
+
+    if (QueryMemoryResourceNotification(m_lowMemoryHandle.get(), &amp;memoryLow) &amp;&amp; memoryLow) {
+        setUnderMemoryPressure(true);
+        releaseMemory(Critical::Yes);
+        return;
+    }
+
+#if CPU(X86)
+    PROCESS_MEMORY_COUNTERS_EX counters;
+
+    if (!GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast&lt;PROCESS_MEMORY_COUNTERS*&gt;(&amp;counters), sizeof(counters)))
+        return;
+
+    // On Windows, 32-bit processes have 2GB of memory available, where some is used by the system.
+    // Debugging has shown that allocations might fail and cause crashes when memory usage is &gt; ~1GB.
+    // We should start releasing memory before we reach 1GB.
+    const int maxMemoryUsageBytes = 0.9 * 1024 * 1024 * 1024;
+
+    if (counters.PrivateUsage &gt; maxMemoryUsageBytes) {
+        setUnderMemoryPressure(true);
+        releaseMemory(Critical::Yes);
+    }
+#endif
+}
+
+void MemoryPressureHandler::platformReleaseMemory(Critical)
+{
+}
+
+void MemoryPressureHandler::install()
+{
+    m_installed = true;
+    m_windowsMeasurementTimer.startRepeating(60.0);
+}
+
+void MemoryPressureHandler::uninstall()
+{
+    if (!m_installed)
+        return;
+
+    m_windowsMeasurementTimer.stop();
+    m_installed = false;
+}
+
+void MemoryPressureHandler::holdOff(unsigned seconds)
+{
+}
+
+void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchronous synchronous)
+{
+    uninstall();
+
+    releaseMemory(critical, synchronous);
+}
+
+std::optional&lt;MemoryPressureHandler::ReliefLogger::MemoryUsage&gt; MemoryPressureHandler::ReliefLogger::platformMemoryUsage()
+{
+    return std::nullopt;
+}
+
+} // namespace WTF
</ins></span></pre></div>
<a id="trunkSourceWTFwtfwinWin32Handlehfromrev213211trunkSourceWebCoreplatformwinWin32Handleh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/win/Win32Handle.h (from rev 213211, trunk/Source/WebCore/platform/win/Win32Handle.h) (0 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/win/Win32Handle.h                                (rev 0)
+++ trunk/Source/WTF/wtf/win/Win32Handle.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2011 Patrick Gansterer &lt;paroga@paroga.com&gt;
+ *
+ * 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 AND ITS CONTRIBUTORS &quot;AS IS&quot; 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 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 &lt;memory&gt;
+#include &lt;windows.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+
+namespace WTF {
+
+class Win32Handle {
+    WTF_MAKE_NONCOPYABLE(Win32Handle);
+public:
+    Win32Handle() : m_handle(INVALID_HANDLE_VALUE) { }
+    explicit Win32Handle(HANDLE handle) : m_handle(handle) { }
+
+    ~Win32Handle() { clear(); }
+
+    void clear()
+    {
+        if (!isValid())
+            return;
+        CloseHandle(m_handle);
+        m_handle = INVALID_HANDLE_VALUE;
+    }
+
+    bool isValid() const { return m_handle != INVALID_HANDLE_VALUE; }
+
+    HANDLE get() const { return m_handle; }
+    HANDLE release() { HANDLE ret = m_handle; m_handle = INVALID_HANDLE_VALUE; return ret; }
+
+    Win32Handle&amp; operator=(HANDLE handle)
+    {
+        clear();
+        m_handle = handle;
+        return *this;
+    }
+
+private:
+    HANDLE m_handle;
+};
+
+} // namespace WTF
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/CMakeLists.txt        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -2107,7 +2107,6 @@
</span><span class="cx">     platform/LowPowerModeNotifier.cpp
</span><span class="cx">     platform/MIMETypeRegistry.cpp
</span><span class="cx">     platform/MainThreadSharedTimer.cpp
</span><del>-    platform/MemoryPressureHandler.cpp
</del><span class="cx">     platform/NotImplemented.cpp
</span><span class="cx">     platform/PasteboardWriterData.cpp
</span><span class="cx">     platform/PlatformSpeechSynthesisUtterance.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/ChangeLog        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-03-01  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Move MemoryPressureHandler to WTF
+        &lt;https://webkit.org/b/168908&gt;
+
+        Reviewed by Sam Weinig.
+
+        * CMakeLists.txt:
+        * PlatformMac.cmake:
+        * PlatformWin.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/ScriptController.cpp:
+        * history/PageCache.cpp:
+        * html/HTMLMediaElement.cpp:
+        * inspector/InspectorInstrumentation.h:
+        * inspector/InspectorMemoryAgent.h:
+        * page/FrameView.cpp:
+        * page/MemoryRelease.h:
+        * page/linux/ResourceUsageThreadLinux.cpp:
+        * platform/Linux.cmake:
+        * platform/graphics/FontCache.cpp:
+        * platform/graphics/WidthCache.h:
+        * platform/graphics/ca/TileController.cpp:
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
+        * platform/ios/LegacyTileCache.mm:
+        * platform/ios/LegacyTileGrid.mm:
+        * platform/ios/LegacyTileLayerPool.mm:
+        * platform/ios/TileControllerMemoryHandlerIOS.cpp:
+        * testing/Internals.cpp:
+
</ins><span class="cx"> 2017-03-01  Per Arne Vollan  &lt;pvollan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Popup menus are too small in HiDPI mode.
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/PlatformMac.cmake        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -324,7 +324,6 @@
</span><span class="cx">     platform/cocoa/LocalizedStringsCocoa.mm
</span><span class="cx">     platform/cocoa/MIMETypeRegistryCocoa.mm
</span><span class="cx">     platform/cocoa/MachSendRight.cpp
</span><del>-    platform/cocoa/MemoryPressureHandlerCocoa.mm
</del><span class="cx">     platform/cocoa/NetworkExtensionContentFilter.mm
</span><span class="cx">     platform/cocoa/ParentalControlsContentFilter.mm
</span><span class="cx">     platform/cocoa/ScrollController.mm
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformWincmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformWin.cmake (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformWin.cmake        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/PlatformWin.cmake        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -128,7 +128,6 @@
</span><span class="cx">     platform/win/KeyEventWin.cpp
</span><span class="cx">     platform/win/LocalizedStringsWin.cpp
</span><span class="cx">     platform/win/LoggingWin.cpp
</span><del>-    platform/win/MemoryPressureHandlerWin.cpp
</del><span class="cx">     platform/win/MIMETypeRegistryWin.cpp
</span><span class="cx">     platform/win/MainThreadSharedTimerWin.cpp
</span><span class="cx">     platform/win/PasteboardWin.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -2595,8 +2595,6 @@
</span><span class="cx">                 656D373F0ADBA5DE00A4554D /* ResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37270ADBA5DE00A4554D /* ResourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 656D37430ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 656D37480ADBA5DE00A4554D /* SubresourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37300ADBA5DE00A4554D /* SubresourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                6571DCC81385E6A400702DD0 /* MemoryPressureHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 657EDA071385CB97004E0645 /* MemoryPressureHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
-                657EDA081385CB97004E0645 /* MemoryPressureHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */; };
</del><span class="cx">                 658436860AE01B7400E53753 /* FrameLoadRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 658436850AE01B7400E53753 /* FrameLoadRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 658F540319A1C9240088FC92 /* NSURLFileTypeMappingsSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 653EF83819A043AE0052202C /* NSURLFileTypeMappingsSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 6593923709AE4346002C531F /* URL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6593923509AE4346002C531F /* URL.cpp */; };
</span><span class="lines">@@ -4655,7 +4653,6 @@
</span><span class="cx">                 AD726FEE16DA11BC003A4E6D /* JSStyleSheetCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 AD726FEF16DA11F5003A4E6D /* JSCSSRuleCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 AD9FF6E11908391D003B61E0 /* IOSurfacePoolCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */; };
</span><del>-                ADB6B29818FB90240081963E /* MemoryPressureHandlerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */; };
</del><span class="cx">                 ADBAD6EE1BCDD95500381325 /* ResourceUsageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */; };
</span><span class="cx">                 ADBAD6EF1BCDD95700381325 /* ResourceUsageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */; };
</span><span class="cx">                 ADDA94C219687AA500453029 /* JSDocumentCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDA94BF19686F8000453029 /* JSDocumentCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -10050,8 +10047,6 @@
</span><span class="cx">                 656D37270ADBA5DE00A4554D /* ResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceLoader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NetscapePlugInStreamLoader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 656D37300ADBA5DE00A4554D /* SubresourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SubresourceLoader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryPressureHandler.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                657EDA071385CB97004E0645 /* MemoryPressureHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryPressureHandler.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 658436850AE01B7400E53753 /* FrameLoadRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoadRequest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 6593923509AE4346002C531F /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = URL.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 6593923609AE4346002C531F /* URL.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = URL.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -12573,7 +12568,6 @@
</span><span class="cx">                 AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleDeclarationCustom.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStyleSheetCustom.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IOSurfacePoolCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandlerCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageOverlay.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceUsageOverlay.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 ADDA94BF19686F8000453029 /* JSDocumentCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDocumentCustom.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -20289,7 +20283,6 @@
</span><span class="cx">                                 1A4832B21A953BA6008B4DFE /* LocalizedStringsCocoa.mm */,
</span><span class="cx">                                 1A0409F21A43675C009E47F3 /* MachSendRight.cpp */,
</span><span class="cx">                                 1A0409DB1A4360B5009E47F3 /* MachSendRight.h */,
</span><del>-                                ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */,
</del><span class="cx">                                 C53D39331C97892D007F3AE9 /* MIMETypeRegistryCocoa.mm */,
</span><span class="cx">                                 A19D93491AA11B1E00B46C24 /* NetworkExtensionContentFilter.h */,
</span><span class="cx">                                 A19D93481AA11B1E00B46C24 /* NetworkExtensionContentFilter.mm */,
</span><span class="lines">@@ -23110,8 +23103,6 @@
</span><span class="cx">                                 7AE6C93A1BE0C60100E19E03 /* MainThreadSharedTimer.h */,
</span><span class="cx">                                 CDF2B003181F059C00F2B424 /* MediaDescription.h */,
</span><span class="cx">                                 CD641EC7181ED60100EE4C41 /* MediaSample.h */,
</span><del>-                                657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */,
-                                657EDA071385CB97004E0645 /* MemoryPressureHandler.h */,
</del><span class="cx">                                 BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */,
</span><span class="cx">                                 BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */,
</span><span class="cx">                                 E1513D501677F08800149FCB /* NotImplemented.cpp */,
</span><span class="lines">@@ -27523,7 +27514,6 @@
</span><span class="cx">                                 519755FA1BFD7DC3003DE980 /* MemoryIndexCursor.h in Headers */,
</span><span class="cx">                                 51771DFF1BDB485000CAE8E4 /* MemoryObjectStore.h in Headers */,
</span><span class="cx">                                 517139061BF64DEC000D5F01 /* MemoryObjectStoreCursor.h in Headers */,
</span><del>-                                6571DCC81385E6A400702DD0 /* MemoryPressureHandler.h in Headers */,
</del><span class="cx">                                 413E00791DB0E4F2002341D2 /* MemoryRelease.h in Headers */,
</span><span class="cx">                                 93309DFA099E64920056E581 /* MergeIdenticalElementsCommand.h in Headers */,
</span><span class="cx">                                 E1ADECCE0E76AD8B004A1A5E /* MessageChannel.h in Headers */,
</span><span class="lines">@@ -31379,8 +31369,6 @@
</span><span class="cx">                                 519755F91BFD7DC3003DE980 /* MemoryIndexCursor.cpp in Sources */,
</span><span class="cx">                                 51771DFE1BDB485000CAE8E4 /* MemoryObjectStore.cpp in Sources */,
</span><span class="cx">                                 517139051BF64DEC000D5F01 /* MemoryObjectStoreCursor.cpp in Sources */,
</span><del>-                                657EDA081385CB97004E0645 /* MemoryPressureHandler.cpp in Sources */,
-                                ADB6B29818FB90240081963E /* MemoryPressureHandlerCocoa.mm in Sources */,
</del><span class="cx">                                 413E007A1DB0E4F9002341D2 /* MemoryRelease.cpp in Sources */,
</span><span class="cx">                                 413E007C1DB0E70A002341D2 /* MemoryReleaseCocoa.mm in Sources */,
</span><span class="cx">                                 93309DF9099E64920056E581 /* MergeIdenticalElementsCommand.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptController.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -39,7 +39,6 @@
</span><span class="cx"> #include &quot;JSMainThreadExecState.h&quot;
</span><span class="cx"> #include &quot;LoadableModuleScript.h&quot;
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;ModuleFetchFailureKind.h&quot;
</span><span class="cx"> #include &quot;NP_jsobject.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="lines">@@ -63,6 +62,7 @@
</span><span class="cx"> #include &lt;runtime/JSModuleRecord.h&gt;
</span><span class="cx"> #include &lt;runtime/JSNativeStdFunction.h&gt;
</span><span class="cx"> #include &lt;runtime/JSScriptFetcher.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/SetForScope.h&gt;
</span><span class="cx"> #include &lt;wtf/Threading.h&gt;
</span><span class="cx"> #include &lt;wtf/text/TextPosition.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorehistoryPageCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/history/PageCache.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/history/PageCache.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/history/PageCache.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -44,11 +44,11 @@
</span><span class="cx"> #include &quot;IgnoreOpensDuringUnloadCountIncrementer.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;NoEventDispatchAssertion.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;SubframeLoader.h&quot;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/SetForScope.h&gt;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -70,7 +70,6 @@
</span><span class="cx"> #include &quot;MediaPlayer.h&quot;
</span><span class="cx"> #include &quot;MediaQueryEvaluator.h&quot;
</span><span class="cx"> #include &quot;MediaResourceLoader.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;NetworkingContext.h&quot;
</span><span class="cx"> #include &quot;NoEventDispatchAssertion.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="lines">@@ -95,6 +94,7 @@
</span><span class="cx"> #include &lt;runtime/Uint8Array.h&gt;
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorInstrumentationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -39,12 +39,12 @@
</span><span class="cx"> #include &quot;HitTestResult.h&quot;
</span><span class="cx"> #include &quot;InspectorController.h&quot;
</span><span class="cx"> #include &quot;InspectorInstrumentationCookie.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;ScriptExecutionContext.h&quot;
</span><span class="cx"> #include &quot;StorageArea.h&quot;
</span><span class="cx"> #include &quot;WorkerGlobalScope.h&quot;
</span><span class="cx"> #include &quot;WorkerInspectorController.h&quot;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_REPLAY)
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorMemoryAgenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -28,10 +28,10 @@
</span><span class="cx"> #if ENABLE(RESOURCE_USAGE)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;InspectorWebAgentBase.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;ResourceUsageData.h&quot;
</span><span class="cx"> #include &lt;inspector/InspectorBackendDispatchers.h&gt;
</span><span class="cx"> #include &lt;inspector/InspectorFrontendDispatchers.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/page/FrameView.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -63,7 +63,6 @@
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><span class="cx"> #include &quot;MemoryCache.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;OverflowEvent.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageCache.h&quot;
</span><span class="lines">@@ -98,6 +97,7 @@
</span><span class="cx"> #include &quot;WheelEventTestTrigger.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="cx"> #include &lt;wtf/SetForScope.h&gt;
</span><span class="cx"> #include &lt;wtf/SystemTracing.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorepageMemoryReleaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/MemoryRelease.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/MemoryRelease.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/page/MemoryRelease.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepagelinuxResourceUsageThreadLinuxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(RESOURCE_USAGE) &amp;&amp; OS(LINUX)
</span><span class="cx"> 
</span><del>-#include &quot;CurrentProcessMemoryStatus.h&quot;
</del><span class="cx"> #include &lt;errno.h&gt;
</span><span class="cx"> #include &lt;fcntl.h&gt;
</span><span class="cx"> #include &lt;heap/GCActivityCallback.h&gt;
</span><span class="lines">@@ -38,6 +37,7 @@
</span><span class="cx"> #include &lt;sys/stat.h&gt;
</span><span class="cx"> #include &lt;sys/types.h&gt;
</span><span class="cx"> #include &lt;unistd.h&gt;
</span><ins>+#include &lt;wtf/linux/CurrentProcessMemoryStatus.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLinuxcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Linux.cmake (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Linux.cmake        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/Linux.cmake        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,11 +1,7 @@
</span><span class="cx"> list(APPEND WebCore_INCLUDE_DIRECTORIES
</span><del>-    &quot;${WEBCORE_DIR}/platform/linux&quot;
</del><span class="cx">     &quot;${WEBCORE_DIR}/platform/gamepad/linux&quot;
</span><span class="cx"> )
</span><span class="cx"> 
</span><span class="cx"> list(APPEND WebCore_SOURCES
</span><span class="cx">     platform/gamepad/linux/GamepadDeviceLinux.cpp
</span><del>-
-    platform/linux/CurrentProcessMemoryStatus.cpp
-    platform/linux/MemoryPressureHandlerLinux.cpp
</del><span class="cx"> )
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,215 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011-2017 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. ``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
- * 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.
- */
-
-#include &quot;config.h&quot;
-#include &quot;MemoryPressureHandler.h&quot;
-
-#include &quot;Logging.h&quot;
-#include &lt;wtf/MemoryFootprint.h&gt;
-
-namespace WebCore {
-
-WEBCORE_EXPORT bool MemoryPressureHandler::ReliefLogger::s_loggingEnabled = false;
-
-MemoryPressureHandler&amp; MemoryPressureHandler::singleton()
-{
-    static NeverDestroyed&lt;MemoryPressureHandler&gt; memoryPressureHandler;
-    return memoryPressureHandler;
-}
-
-MemoryPressureHandler::MemoryPressureHandler()
-#if OS(LINUX)
-    : m_holdOffTimer(RunLoop::main(), this, &amp;MemoryPressureHandler::holdOffTimerFired)
-#endif
-{
-}
-
-void MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor(bool use)
-{
-    if (use) {
-        m_measurementTimer = std::make_unique&lt;RunLoop::Timer&lt;MemoryPressureHandler&gt;&gt;(RunLoop::main(), this, &amp;MemoryPressureHandler::measurementTimerFired);
-        m_measurementTimer-&gt;startRepeating(30);
-    } else
-        m_measurementTimer = nullptr;
-}
-
-#if !RELEASE_LOG_DISABLED
-static const char* toString(MemoryUsagePolicy policy)
-{
-    switch (policy) {
-    case MemoryUsagePolicy::Unrestricted: return &quot;Unrestricted&quot;;
-    case MemoryUsagePolicy::Conservative: return &quot;Conservative&quot;;
-    case MemoryUsagePolicy::Strict: return &quot;Strict&quot;;
-    case MemoryUsagePolicy::Panic: return &quot;Panic&quot;;
-    }
-}
-#endif
-
-static size_t thresholdForPolicy(MemoryUsagePolicy policy)
-{
-    switch (policy) {
-    case MemoryUsagePolicy::Conservative:
-        return 1 * GB;
-    case MemoryUsagePolicy::Strict:
-        return 2 * GB;
-    case MemoryUsagePolicy::Panic:
-#if CPU(X86_64) || CPU(ARM64)
-        return 4 * GB;
-#else
-        return 3 * GB;
-#endif
-    case MemoryUsagePolicy::Unrestricted:
-    default:
-        ASSERT_NOT_REACHED();
-        return 0;
-    }
-}
-
-static MemoryUsagePolicy policyForFootprint(size_t footprint)
-{
-    if (footprint &gt;= thresholdForPolicy(MemoryUsagePolicy::Panic))
-        return MemoryUsagePolicy::Panic;
-    if (footprint &gt;= thresholdForPolicy(MemoryUsagePolicy::Strict))
-        return MemoryUsagePolicy::Strict;
-    if (footprint &gt;= thresholdForPolicy(MemoryUsagePolicy::Conservative))
-        return MemoryUsagePolicy::Conservative;
-    return MemoryUsagePolicy::Unrestricted;
-}
-
-void MemoryPressureHandler::measurementTimerFired()
-{
-    auto footprint = memoryFootprint();
-    if (!footprint)
-        return;
-
-    RELEASE_LOG(MemoryPressure, &quot;Current memory footprint: %lu MB&quot;, footprint.value() / MB);
-
-    auto newPolicy = policyForFootprint(footprint.value());
-    if (newPolicy == m_memoryUsagePolicy) {
-        if (m_memoryUsagePolicy != MemoryUsagePolicy::Panic)
-            return;
-        RELEASE_LOG(MemoryPressure, &quot;Memory usage still above panic threshold&quot;);
-    } else
-        RELEASE_LOG(MemoryPressure, &quot;Memory usage policy changed: %s -&gt; %s&quot;, toString(m_memoryUsagePolicy), toString(newPolicy));
-
-    m_memoryUsagePolicy = newPolicy;
-
-    if (newPolicy == MemoryUsagePolicy::Unrestricted)
-        return;
-
-    if (newPolicy == MemoryUsagePolicy::Conservative) {
-        // FIXME: Implement this policy by choosing which caches should respect it, and hooking them up.
-        return;
-    }
-
-    if (newPolicy == MemoryUsagePolicy::Strict) {
-        RELEASE_LOG(MemoryPressure, &quot;Attempting to reduce memory footprint by freeing less important objects.&quot;);
-        releaseMemory(Critical::No, Synchronous::No);
-        return;
-    }
-
-    RELEASE_ASSERT(newPolicy == MemoryUsagePolicy::Panic);
-
-    RELEASE_LOG(MemoryPressure, &quot;Attempting to reduce memory footprint by freeing more important objects.&quot;);
-    if (m_processIsEligibleForMemoryKillCallback) {
-        if (!m_processIsEligibleForMemoryKillCallback()) {
-            releaseMemory(Critical::Yes, Synchronous::No);
-            return;
-        }
-    }
-
-    releaseMemory(Critical::Yes, Synchronous::Yes);
-
-    // Remeasure footprint to see how well the pressure handler did.
-    footprint = memoryFootprint();
-    RELEASE_ASSERT(footprint);
-
-    RELEASE_LOG(MemoryPressure, &quot;New memory footprint: %lu MB&quot;, footprint.value() / MB);
-    if (footprint.value() &lt; thresholdForPolicy(MemoryUsagePolicy::Panic)) {
-        m_memoryUsagePolicy = policyForFootprint(footprint.value());
-        RELEASE_LOG(MemoryPressure, &quot;Pressure reduced below panic threshold. New memory usage policy: %s&quot;, toString(m_memoryUsagePolicy));
-        return;
-    }
-
-    if (m_memoryKillCallback)
-        m_memoryKillCallback();
-}
-
-void MemoryPressureHandler::beginSimulatedMemoryPressure()
-{
-    m_isSimulatingMemoryPressure = true;
-    respondToMemoryPressure(Critical::Yes, Synchronous::Yes);
-}
-
-void MemoryPressureHandler::endSimulatedMemoryPressure()
-{
-    m_isSimulatingMemoryPressure = false;
-}
-
-void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous)
-{
-    if (!m_lowMemoryHandler)
-        return;
-
-    ReliefLogger log(&quot;Total&quot;);
-    m_lowMemoryHandler(critical, synchronous);
-    platformReleaseMemory(critical);
-}
-
-void MemoryPressureHandler::ReliefLogger::logMemoryUsageChange()
-{
-#if !RELEASE_LOG_DISABLED
-#define STRING_SPECIFICATION &quot;%{public}s&quot;
-#define MEMORYPRESSURE_LOG(...) RELEASE_LOG(MemoryPressure, __VA_ARGS__)
-#else
-#define STRING_SPECIFICATION &quot;%s&quot;
-#define MEMORYPRESSURE_LOG(...) WTFLogAlways(__VA_ARGS__)
-#endif
-
-    auto currentMemory = platformMemoryUsage();
-    if (!currentMemory || !m_initialMemory) {
-        MEMORYPRESSURE_LOG(&quot;Memory pressure relief: &quot; STRING_SPECIFICATION &quot;: (Unable to get dirty memory information for process)&quot;, m_logString);
-        return;
-    }
-
-    long residentDiff = currentMemory-&gt;resident - m_initialMemory-&gt;resident;
-    long physicalDiff = currentMemory-&gt;physical - m_initialMemory-&gt;physical;
-
-    MEMORYPRESSURE_LOG(&quot;Memory pressure relief: &quot; STRING_SPECIFICATION &quot;: res = %zu/%zu/%ld, res+swap = %zu/%zu/%ld&quot;,
-        m_logString,
-        m_initialMemory-&gt;resident, currentMemory-&gt;resident, residentDiff,
-        m_initialMemory-&gt;physical, currentMemory-&gt;physical, physicalDiff);
-}
-
-#if !PLATFORM(COCOA) &amp;&amp; !OS(LINUX) &amp;&amp; !PLATFORM(WIN)
-void MemoryPressureHandler::install() { }
-void MemoryPressureHandler::uninstall() { }
-void MemoryPressureHandler::holdOff(unsigned) { }
-void MemoryPressureHandler::respondToMemoryPressure(Critical, Synchronous) { }
-void MemoryPressureHandler::platformReleaseMemory(Critical) { }
-std::optional&lt;MemoryPressureHandler::ReliefLogger::MemoryUsage&gt; MemoryPressureHandler::ReliefLogger::platformMemoryUsage() { return std::nullopt; }
-#endif
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlerh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/MemoryPressureHandler.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,198 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 Apple Inc. All Rights Reserved.
- * Copyright (C) 2014 Raspberry Pi Foundation. 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. ``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
- * 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.
- */
-
-#ifndef MemoryPressureHandler_h
-#define MemoryPressureHandler_h
-
-#include &lt;atomic&gt;
-#include &lt;ctime&gt;
-#include &lt;functional&gt;
-#include &lt;wtf/FastMalloc.h&gt;
-#include &lt;wtf/Forward.h&gt;
-#include &lt;wtf/NeverDestroyed.h&gt;
-#include &lt;wtf/Optional.h&gt;
-#include &lt;wtf/RunLoop.h&gt;
-
-#if USE(GLIB)
-#include &lt;wtf/glib/GRefPtr.h&gt;
-#endif
-
-namespace WebCore {
-
-enum class MemoryUsagePolicy {
-    Unrestricted, // Allocate as much as you want
-    Conservative, // Maybe you don't cache every single thing
-    Strict, // Time to start pinching pennies for real
-    Panic, // OH GOD WE'RE SINKING, THROW EVERYTHING OVERBOARD
-};
-
-enum class Critical { No, Yes };
-enum class Synchronous { No, Yes };
-
-typedef std::function&lt;void(Critical, Synchronous)&gt; LowMemoryHandler;
-
-class MemoryPressureHandler {
-    WTF_MAKE_FAST_ALLOCATED;
-    friend class WTF::NeverDestroyed&lt;MemoryPressureHandler&gt;;
-public:
-    WEBCORE_EXPORT static MemoryPressureHandler&amp; singleton();
-
-    WEBCORE_EXPORT void install();
-
-    WEBCORE_EXPORT void setShouldUsePeriodicMemoryMonitor(bool);
-
-    void setMemoryKillCallback(WTF::Function&lt;void()&gt; function) { m_memoryKillCallback = WTFMove(function); }
-    void setProcessIsEligibleForMemoryKillCallback(WTF::Function&lt;bool()&gt; function) { m_processIsEligibleForMemoryKillCallback = WTFMove(function); }
-
-    void setLowMemoryHandler(LowMemoryHandler&amp;&amp; handler)
-    {
-        m_lowMemoryHandler = WTFMove(handler);
-    }
-
-    bool isUnderMemoryPressure() const
-    {
-        return m_underMemoryPressure
-#if PLATFORM(MAC)
-            || m_memoryUsagePolicy &gt;= MemoryUsagePolicy::Strict
-#endif
-            || m_isSimulatingMemoryPressure;
-    }
-    void setUnderMemoryPressure(bool b) { m_underMemoryPressure = b; }
-
-#if OS(LINUX)
-    void setMemoryPressureMonitorHandle(int fd);
-#endif
-
-    class ReliefLogger {
-    public:
-        explicit ReliefLogger(const char *log)
-            : m_logString(log)
-            , m_initialMemory(loggingEnabled() ? platformMemoryUsage() : MemoryUsage { })
-        {
-        }
-
-        ~ReliefLogger()
-        {
-            if (loggingEnabled())
-                logMemoryUsageChange();
-        }
-
-
-        const char* logString() const { return m_logString; }
-        static void setLoggingEnabled(bool enabled) { s_loggingEnabled = enabled; }
-        static bool loggingEnabled()
-        {
-#if RELEASE_LOG_DISABLED
-            return s_loggingEnabled;
-#else
-            return true;
-#endif
-        }
-
-    private:
-        struct MemoryUsage {
-            MemoryUsage() = default;
-            MemoryUsage(size_t resident, size_t physical)
-                : resident(resident)
-                , physical(physical)
-            {
-            }
-            size_t resident { 0 };
-            size_t physical { 0 };
-        };
-        std::optional&lt;MemoryUsage&gt; platformMemoryUsage();
-        void logMemoryUsageChange();
-
-        const char* m_logString;
-        std::optional&lt;MemoryUsage&gt; m_initialMemory;
-
-        WEBCORE_EXPORT static bool s_loggingEnabled;
-    };
-
-    WEBCORE_EXPORT void releaseMemory(Critical, Synchronous = Synchronous::No);
-
-    WEBCORE_EXPORT void beginSimulatedMemoryPressure();
-    WEBCORE_EXPORT void endSimulatedMemoryPressure();
-
-private:
-    void uninstall();
-
-    void holdOff(unsigned);
-
-    MemoryPressureHandler();
-    ~MemoryPressureHandler() = delete;
-
-    void respondToMemoryPressure(Critical, Synchronous = Synchronous::No);
-    void platformReleaseMemory(Critical);
-
-    NO_RETURN_DUE_TO_CRASH void didExceedMemoryLimitAndFailedToRecover();
-    void measurementTimerFired();
-
-#if OS(LINUX)
-    class EventFDPoller {
-        WTF_MAKE_NONCOPYABLE(EventFDPoller); WTF_MAKE_FAST_ALLOCATED;
-    public:
-        EventFDPoller(int fd, std::function&lt;void ()&gt;&amp;&amp; notifyHandler);
-        ~EventFDPoller();
-
-    private:
-        void readAndNotify() const;
-
-        std::optional&lt;int&gt; m_fd;
-        std::function&lt;void ()&gt; m_notifyHandler;
-#if USE(GLIB)
-        GRefPtr&lt;GSource&gt; m_source;
-#else
-        ThreadIdentifier m_threadID;
-#endif
-    };
-#endif
-
-    bool m_installed { false };
-    LowMemoryHandler m_lowMemoryHandler;
-
-    std::atomic&lt;bool&gt; m_underMemoryPressure;
-    bool m_isSimulatingMemoryPressure { false };
-
-    std::unique_ptr&lt;RunLoop::Timer&lt;MemoryPressureHandler&gt;&gt; m_measurementTimer;
-    MemoryUsagePolicy m_memoryUsagePolicy { MemoryUsagePolicy::Unrestricted };
-    WTF::Function&lt;void()&gt; m_memoryKillCallback;
-    WTF::Function&lt;bool()&gt; m_processIsEligibleForMemoryKillCallback;
-
-#if OS(LINUX)
-    std::optional&lt;int&gt; m_eventFD;
-    std::optional&lt;int&gt; m_pressureLevelFD;
-    std::unique_ptr&lt;EventFDPoller&gt; m_eventFDPoller;
-    RunLoop::Timer&lt;MemoryPressureHandler&gt; m_holdOffTimer;
-    void holdOffTimerFired();
-    void logErrorAndCloseFDs(const char* error);
-    bool tryEnsureEventFD();
-#endif
-};
-
-} // namespace WebCore
-
-#endif // MemoryPressureHandler_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaMemoryPressureHandlerCocoamm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,200 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011-2015 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. ``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
- * 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.
- */
-
-#import &quot;config.h&quot;
-#import &quot;MemoryPressureHandler.h&quot;
-
-#import &quot;Logging.h&quot;
-#import &lt;mach/mach.h&gt;
-#import &lt;mach/task_info.h&gt;
-#import &lt;malloc/malloc.h&gt;
-#import &lt;notify.h&gt;
-#import &lt;wtf/CurrentTime.h&gt;
-
-#if PLATFORM(IOS)
-#import &quot;GraphicsServicesSPI.h&quot;
-#import &quot;SystemMemory.h&quot;
-#import &quot;WebCoreThreadInternal.h&quot;
-#endif
-
-#define ENABLE_FMW_FOOTPRINT_COMPARISON 0
-
-extern &quot;C&quot; void cache_simulate_memory_warning_event(uint64_t);
-
-namespace WebCore {
-
-void MemoryPressureHandler::platformReleaseMemory(Critical critical)
-{
-    if (critical == Critical::Yes &amp;&amp; (!isUnderMemoryPressure() || m_isSimulatingMemoryPressure)) {
-        // libcache listens to OS memory notifications, but for process suspension
-        // or memory pressure simulation, we need to prod it manually:
-        cache_simulate_memory_warning_event(DISPATCH_MEMORYPRESSURE_CRITICAL);
-    }
-}
-
-static dispatch_source_t _cache_event_source = 0;
-static dispatch_source_t _timer_event_source = 0;
-static int _notifyToken;
-
-// Disable memory event reception for a minimum of s_minimumHoldOffTime
-// seconds after receiving an event.  Don't let events fire any sooner than
-// s_holdOffMultiplier times the last cleanup processing time.  Effectively 
-// this is 1 / s_holdOffMultiplier percent of the time.
-// These value seems reasonable and testing verifies that it throttles frequent
-// low memory events, greatly reducing CPU usage.
-static const unsigned s_minimumHoldOffTime = 5;
-#if !PLATFORM(IOS)
-static const unsigned s_holdOffMultiplier = 20;
-#endif
-
-void MemoryPressureHandler::install()
-{
-    if (m_installed || _timer_event_source)
-        return;
-
-    dispatch_async(dispatch_get_main_queue(), ^{
-#if PLATFORM(IOS)
-        _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_NORMAL | DISPATCH_MEMORYPRESSURE_WARN | DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
-#elif PLATFORM(MAC)
-        _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
-#endif
-
-        dispatch_set_context(_cache_event_source, this);
-        dispatch_source_set_event_handler(_cache_event_source, ^{
-            bool critical = true;
-#if PLATFORM(IOS)
-            unsigned long status = dispatch_source_get_data(_cache_event_source);
-            critical = status == DISPATCH_MEMORYPRESSURE_CRITICAL;
-            auto&amp; memoryPressureHandler = MemoryPressureHandler::singleton();
-            bool wasCritical = memoryPressureHandler.isUnderMemoryPressure();
-            memoryPressureHandler.setUnderMemoryPressure(critical);
-            if (status == DISPATCH_MEMORYPRESSURE_NORMAL) {
-                if (ReliefLogger::loggingEnabled())
-                    NSLog(@&quot;System is no longer under (%s) memory pressure.&quot;, wasCritical ? &quot;critical&quot; : &quot;non-critical&quot;);
-                return;
-            }
-
-            if (ReliefLogger::loggingEnabled())
-                NSLog(@&quot;Got memory pressure notification (%s)&quot;, critical ? &quot;critical&quot; : &quot;non-critical&quot;);
-#endif
-            MemoryPressureHandler::singleton().respondToMemoryPressure(critical ? Critical::Yes : Critical::No);
-        });
-        dispatch_resume(_cache_event_source);
-    });
-
-    // Allow simulation of memory pressure with &quot;notifyutil -p org.WebKit.lowMemory&quot;
-    notify_register_dispatch(&quot;org.WebKit.lowMemory&quot;, &amp;_notifyToken, dispatch_get_main_queue(), ^(int) {
-#if ENABLE(FMW_FOOTPRINT_COMPARISON)
-        auto footprintBefore = pagesPerVMTag();
-#endif
-        beginSimulatedMemoryPressure();
-
-        WTF::releaseFastMallocFreeMemory();
-        malloc_zone_pressure_relief(nullptr, 0);
-
-#if ENABLE(FMW_FOOTPRINT_COMPARISON)
-        auto footprintAfter = pagesPerVMTag();
-        logFootprintComparison(footprintBefore, footprintAfter);
-#endif
-
-        dispatch_async(dispatch_get_main_queue(), ^{
-            endSimulatedMemoryPressure();
-        });
-    });
-
-    m_installed = true;
-}
-
-void MemoryPressureHandler::uninstall()
-{
-    if (!m_installed)
-        return;
-
-    dispatch_async(dispatch_get_main_queue(), ^{
-        if (_cache_event_source) {
-            dispatch_source_cancel(_cache_event_source);
-            dispatch_release(_cache_event_source);
-            _cache_event_source = 0;
-        }
-
-        if (_timer_event_source) {
-            dispatch_source_cancel(_timer_event_source);
-            dispatch_release(_timer_event_source);
-            _timer_event_source = 0;
-        }
-    });
-
-    m_installed = false;
-    
-    notify_cancel(_notifyToken);
-}
-
-void MemoryPressureHandler::holdOff(unsigned seconds)
-{
-    dispatch_async(dispatch_get_main_queue(), ^{
-        _timer_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
-        if (_timer_event_source) {
-            dispatch_set_context(_timer_event_source, this);
-            dispatch_source_set_timer(_timer_event_source, dispatch_time(DISPATCH_TIME_NOW, seconds * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, 1 * s_minimumHoldOffTime);
-            dispatch_source_set_event_handler(_timer_event_source, ^{
-                if (_timer_event_source) {
-                    dispatch_source_cancel(_timer_event_source);
-                    dispatch_release(_timer_event_source);
-                    _timer_event_source = 0;
-                }
-                MemoryPressureHandler::singleton().install();
-            });
-            dispatch_resume(_timer_event_source);
-        }
-    });
-}
-
-void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchronous synchronous)
-{
-#if !PLATFORM(IOS)
-    uninstall();
-    double startTime = monotonicallyIncreasingTime();
-#endif
-
-    releaseMemory(critical, synchronous);
-
-#if !PLATFORM(IOS)
-    unsigned holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
-    holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
-#endif
-}
-
-std::optional&lt;MemoryPressureHandler::ReliefLogger::MemoryUsage&gt; MemoryPressureHandler::ReliefLogger::platformMemoryUsage()
-{
-    task_vm_info_data_t vmInfo;
-    mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
-    kern_return_t err = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &amp;vmInfo, &amp;count);
-    if (err != KERN_SUCCESS)
-        return std::nullopt;
-
-    return MemoryUsage {static_cast&lt;size_t&gt;(vmInfo.internal), static_cast&lt;size_t&gt;(vmInfo.phys_footprint)};
-}
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -33,9 +33,9 @@
</span><span class="cx"> #include &quot;FontCascade.h&quot;
</span><span class="cx"> #include &quot;FontPlatformData.h&quot;
</span><span class="cx"> #include &quot;FontSelector.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;WebKitFontFamilyNames.h&quot;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/text/AtomicStringHash.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsWidthCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/WidthCache.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/WidthCache.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/graphics/WidthCache.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -26,12 +26,12 @@
</span><span class="cx"> #ifndef WidthCache_h
</span><span class="cx"> #define WidthCache_h
</span><span class="cx"> 
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;TextRun.h&quot;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/HashFunctions.h&gt;
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="cx"> #include &lt;wtf/Hasher.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -43,8 +43,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;TileControllerMemoryHandlerIOS.h&quot;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinMediaPlayerPrivateMediaFoundationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;COMPtr.h&quot;
</span><span class="cx"> #include &quot;MediaPlayerPrivate.h&quot;
</span><del>-#include &quot;Win32Handle.h&quot;
</del><span class="cx"> 
</span><span class="cx"> #include &lt;D3D9.h&gt;
</span><span class="cx"> #include &lt;Dxva2api.h&gt;
</span><span class="lines">@@ -44,6 +43,7 @@
</span><span class="cx"> #include &lt;wtf/Lock.h&gt;
</span><span class="cx"> #include &lt;wtf/ThreadingPrimitives.h&gt;
</span><span class="cx"> #include &lt;wtf/WeakPtr.h&gt;
</span><ins>+#include &lt;wtf/Win32Handle.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileCachemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/LegacyTileCache.mm (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileCache.mm        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/ios/LegacyTileCache.mm        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> #include &quot;LegacyTileLayer.h&quot;
</span><span class="cx"> #include &quot;LegacyTileLayerPool.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;QuartzCoreSPI.h&quot;
</span><span class="cx"> #include &quot;SystemMemory.h&quot;
</span><span class="cx"> #include &quot;WAKWindow.h&quot;
</span><span class="lines">@@ -43,6 +42,7 @@
</span><span class="cx"> #include &quot;WebCoreSystemInterface.h&quot;
</span><span class="cx"> #include &quot;WebCoreThreadRun.h&quot;
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/RAMSize.h&gt;
</span><span class="cx"> 
</span><span class="cx"> @interface WAKView (WebViewExtras)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileGridmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -32,12 +32,12 @@
</span><span class="cx"> #include &quot;LegacyTileGridTile.h&quot;
</span><span class="cx"> #include &quot;LegacyTileLayer.h&quot;
</span><span class="cx"> #include &quot;LegacyTileLayerPool.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;QuartzCoreSPI.h&quot;
</span><span class="cx"> #include &quot;SystemMemory.h&quot;
</span><span class="cx"> #include &quot;WAKWindow.h&quot;
</span><span class="cx"> #include &lt;algorithm&gt;
</span><span class="cx"> #include &lt;functional&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileLayerPoolmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -31,8 +31,8 @@
</span><span class="cx"> #include &quot;LegacyTileLayer.h&quot;
</span><span class="cx"> #include &quot;LegacyTileGrid.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileControllerMemoryHandlerIOScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -26,8 +26,8 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;TileControllerMemoryHandlerIOS.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;TileController.h&quot;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinMemoryPressureHandlerWincpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,132 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 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. ``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
- * 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.
- */
-
-#include &quot;config.h&quot;
-#include &quot;MemoryPressureHandler.h&quot;
-
-#include &lt;WebCore/Timer.h&gt;
-#include &lt;WebCore/Win32Handle.h&gt;
-#include &lt;psapi.h&gt;
-#include &lt;wtf/NeverDestroyed.h&gt;
-
-namespace WebCore {
-
-// We create a timer for checking the memory usage at regular intervals.
-
-class CheckMemoryTimer : public TimerBase {
-public:
-    CheckMemoryTimer(MemoryPressureHandler&amp;);
-
-private:
-    virtual void fired();
-
-    void handleMemoryLow();
-
-    MemoryPressureHandler&amp; m_pressureHandler;
-    Win32Handle m_lowMemoryHandle;
-};
-
-CheckMemoryTimer::CheckMemoryTimer(MemoryPressureHandler&amp; pressureHandler)
-    : m_pressureHandler(pressureHandler)
-{
-    m_lowMemoryHandle = CreateMemoryResourceNotification(LowMemoryResourceNotification);
-}
-
-void CheckMemoryTimer::fired()
-{
-    m_pressureHandler.setUnderMemoryPressure(false);
-
-    BOOL memoryLow;
-
-    if (QueryMemoryResourceNotification(m_lowMemoryHandle.get(), &amp;memoryLow) &amp;&amp; memoryLow) {
-        handleMemoryLow();
-        return;
-    }
-
-#if CPU(X86)
-    PROCESS_MEMORY_COUNTERS_EX counters;
-
-    if (!GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast&lt;PROCESS_MEMORY_COUNTERS*&gt;(&amp;counters), sizeof(counters)))
-        return;
-
-    // On Windows, 32-bit processes have 2GB of memory available, where some is used by the system.
-    // Debugging has shown that allocations might fail and cause crashes when memory usage is &gt; ~1GB.
-    // We should start releasing memory before we reach 1GB.
-    const int maxMemoryUsageBytes = 0.9 * 1024 * 1024 * 1024;
-
-    if (counters.PrivateUsage &gt; maxMemoryUsageBytes)
-        handleMemoryLow();
-#endif
-}
-
-void CheckMemoryTimer::handleMemoryLow()
-{
-    m_pressureHandler.setUnderMemoryPressure(true);
-    m_pressureHandler.releaseMemory(Critical::Yes);
-}
-
-void MemoryPressureHandler::platformReleaseMemory(Critical)
-{
-}
-
-static std::unique_ptr&lt;CheckMemoryTimer&gt;&amp; memCheckTimer()
-{
-    static NeverDestroyed&lt;std::unique_ptr&lt;CheckMemoryTimer&gt;&gt; memCheckTimer;
-    return memCheckTimer;
-}
-
-void MemoryPressureHandler::install()
-{
-    m_installed = true;
-    memCheckTimer() = std::make_unique&lt;CheckMemoryTimer&gt;(*this);
-    memCheckTimer()-&gt;startRepeating(60.0);
-}
-
-void MemoryPressureHandler::uninstall()
-{
-    if (!m_installed)
-        return;
-
-    memCheckTimer() = nullptr;
-    m_installed = false;
-}
-
-void MemoryPressureHandler::holdOff(unsigned seconds)
-{
-}
-
-void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchronous synchronous)
-{
-    uninstall();
-
-    releaseMemory(critical, synchronous);
-}
-
-std::optional&lt;MemoryPressureHandler::ReliefLogger::MemoryUsage&gt; MemoryPressureHandler::ReliefLogger::platformMemoryUsage()
-{
-    return std::nullopt;
-}
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformwinWin32Handleh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/win/Win32Handle.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/Win32Handle.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/platform/win/Win32Handle.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,68 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 Patrick Gansterer &lt;paroga@paroga.com&gt;
- *
- * 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 AND ITS CONTRIBUTORS &quot;AS IS&quot; 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 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.
- */
-
-#ifndef Win32Handle_h
-#define Win32Handle_h
-
-#include &lt;memory&gt;
-#include &lt;windows.h&gt;
-#include &lt;wtf/Noncopyable.h&gt;
-
-namespace WebCore {
-
-class Win32Handle {
-    WTF_MAKE_NONCOPYABLE(Win32Handle);
-public:
-    Win32Handle() : m_handle(INVALID_HANDLE_VALUE) { }
-    explicit Win32Handle(HANDLE handle) : m_handle(handle) { }
-
-    ~Win32Handle() { clear(); }
-
-    void clear()
-    {
-        if (!isValid())
-            return;
-        CloseHandle(m_handle);
-        m_handle = INVALID_HANDLE_VALUE;
-    }
-
-    bool isValid() const { return m_handle != INVALID_HANDLE_VALUE; }
-
-    HANDLE get() const { return m_handle; }
-    HANDLE release() { HANDLE ret = m_handle; m_handle = INVALID_HANDLE_VALUE; return ret; }
-
-    Win32Handle&amp; operator=(HANDLE handle)
-    {
-        clear();
-        m_handle = handle;
-        return *this;
-    }
-
-private:
-    HANDLE m_handle;
-};
-
-} // namespace WebCore
-
-#endif // Win32Handle_h
</del></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebCore/testing/Internals.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -92,7 +92,6 @@
</span><span class="cx"> #include &quot;MediaProducer.h&quot;
</span><span class="cx"> #include &quot;MemoryCache.h&quot;
</span><span class="cx"> #include &quot;MemoryInfo.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;MockLibWebRTCPeerConnection.h&quot;
</span><span class="cx"> #include &quot;MockPageOverlay.h&quot;
</span><span class="cx"> #include &quot;MockPageOverlayClient.h&quot;
</span><span class="lines">@@ -146,6 +145,7 @@
</span><span class="cx"> #include &lt;inspector/InspectorValues.h&gt;
</span><span class="cx"> #include &lt;runtime/JSCInlines.h&gt;
</span><span class="cx"> #include &lt;runtime/JSCJSValue.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringBuffer.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-03-01  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Move MemoryPressureHandler to WTF
+        &lt;https://webkit.org/b/168908&gt;
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/mac/NetworkProcessMac.mm:
+        * PluginProcess/PluginProcess.cpp:
+        * Shared/linux/WebMemorySamplerLinux.cpp:
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+
</ins><span class="cx"> 2017-03-01  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebRTC] Install libwebrtc.dylib inside of WebCore.framework
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -30,11 +30,11 @@
</span><span class="cx"> #include &quot;DownloadManager.h&quot;
</span><span class="cx"> #include &quot;MessageReceiverMap.h&quot;
</span><span class="cx"> #include &lt;WebCore/DiagnosticLoggingClient.h&gt;
</span><del>-#include &lt;WebCore/MemoryPressureHandler.h&gt;
</del><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><span class="cx"> #include &lt;memory&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/Function.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx">     void terminate() override;
</span><span class="cx">     void platformTerminate();
</span><span class="cx"> 
</span><del>-    void lowMemoryHandler(WebCore::Critical);
</del><ins>+    void lowMemoryHandler(Critical);
</ins><span class="cx"> 
</span><span class="cx">     // ChildProcess
</span><span class="cx">     void initializeProcess(const ChildProcessInitializationParameters&amp;) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessmacNetworkProcessMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -40,10 +40,10 @@
</span><span class="cx"> #import &lt;WebCore/CertificateInfo.h&gt;
</span><span class="cx"> #import &lt;WebCore/FileSystem.h&gt;
</span><span class="cx"> #import &lt;WebCore/LocalizedStrings.h&gt;
</span><del>-#import &lt;WebCore/MemoryPressureHandler.h&gt;
</del><span class="cx"> #import &lt;WebKitSystemInterface.h&gt;
</span><span class="cx"> #import &lt;notify.h&gt;
</span><span class="cx"> #import &lt;sysexits.h&gt;
</span><ins>+#import &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #import &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessPluginProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -36,8 +36,8 @@
</span><span class="cx"> #include &quot;PluginProcessCreationParameters.h&quot;
</span><span class="cx"> #include &quot;PluginProcessProxyMessages.h&quot;
</span><span class="cx"> #include &quot;WebProcessConnection.h&quot;
</span><del>-#include &lt;WebCore/MemoryPressureHandler.h&gt;
</del><span class="cx"> #include &lt;WebCore/NotImplemented.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedlinuxWebMemorySamplerLinuxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;JavaScriptCore/MemoryStatistics.h&gt;
</span><span class="cx"> #include &lt;WebCore/CommonVM.h&gt;
</span><del>-#include &lt;WebCore/CurrentProcessMemoryStatus.h&gt;
</del><span class="cx"> #include &lt;WebCore/JSDOMWindow.h&gt;
</span><span class="cx"> #include &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #include &lt;runtime/JSCInlines.h&gt;
</span><span class="lines">@@ -38,6 +37,7 @@
</span><span class="cx"> #include &lt;string.h&gt;
</span><span class="cx"> #include &lt;sys/sysinfo.h&gt;
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><ins>+#include &lt;wtf/linux/CurrentProcessMemoryStatus.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCompositingCoordinatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -35,8 +35,8 @@
</span><span class="cx"> #include &lt;WebCore/GraphicsContext.h&gt;
</span><span class="cx"> #include &lt;WebCore/InspectorController.h&gt;
</span><span class="cx"> #include &lt;WebCore/MainFrame.h&gt;
</span><del>-#include &lt;WebCore/MemoryPressureHandler.h&gt;
</del><span class="cx"> #include &lt;WebCore/Page.h&gt;
</span><ins>+#include &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #include &lt;wtf/SetForScope.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (213213 => 213214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2017-03-01 09:23:28 UTC (rev 213213)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2017-03-01 09:38:44 UTC (rev 213214)
</span><span class="lines">@@ -85,7 +85,6 @@
</span><span class="cx"> #import &lt;WebCore/KeyboardEvent.h&gt;
</span><span class="cx"> #import &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #import &lt;WebCore/MediaSessionManagerIOS.h&gt;
</span><del>-#import &lt;WebCore/MemoryPressureHandler.h&gt;
</del><span class="cx"> #import &lt;WebCore/Node.h&gt;
</span><span class="cx"> #import &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #import &lt;WebCore/Page.h&gt;
</span><span class="lines">@@ -107,6 +106,7 @@
</span><span class="cx"> #import &lt;WebCore/WebEvent.h&gt;
</span><span class="cx"> #import &lt;WebCore/htmlediting.h&gt;
</span><span class="cx"> #import &lt;wtf/MathExtras.h&gt;
</span><ins>+#import &lt;wtf/MemoryPressureHandler.h&gt;
</ins><span class="cx"> #import &lt;wtf/SetForScope.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span></span></pre>
</div>
</div>

</body>
</html>