<!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>[208534] 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/208534">208534</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-11-10 06:24:26 -0800 (Thu, 10 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>MemoryPressureHandler shouldn't know how to release WebCore memory
https://bugs.webkit.org/show_bug.cgi?id=160497

Reviewed by Michael Catanzaro.

Source/WebCore:

All processes should set their own low memory handler, instead of leaving the web process using the default one
that needs to access APIs that are not in platform layer. This patch fixes all the layering violations in the
MemoryPressureHandler. Since the default implementation, that releases the WebCore memory, is shared by the
WebProcess in WebKit2 and WebKit1 ports, it has been moved to its own file to the WebCore layer.

* CMakeLists.txt: Add new files to compilation.
* PlatformMac.cmake: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad): Use WebCore::jettisonExpensiveObjectsOnTopLevelNavigation().
* page/MemoryRelease.cpp: Added.
(WebCore::releaseNoncriticalMemory):
(WebCore::releaseCriticalMemory):
(WebCore::releaseMemory):
(WebCore::platformReleaseMemory):
(WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
(WebCore::registerMemoryReleaseNotifyCallbacks):
* page/MemoryRelease.h: Added.
* page/cocoa/MemoryReleaseCocoa.mm: Added.
(WebCore::platformReleaseMemory):
(WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
(WebCore::registerMemoryReleaseNotifyCallbacks):
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::MemoryPressureHandler):
(WebCore::MemoryPressureHandler::beginSimulatedMemoryPressure):
(WebCore::MemoryPressureHandler::releaseMemory): Use the current handler if it has been set.
(WebCore::MemoryPressureHandler::platformReleaseMemory): Deleted.
* platform/MemoryPressureHandler.h:
(WebCore::MemoryPressureHandler::setLowMemoryHandler):
(WebCore::MemoryPressureHandler::m_releaseMemoryBlock):
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::respondToMemoryPressure): Call releaseMemory() instead of using the handler directly.
(WebCore::MemoryPressureHandler::platformReleaseMemory): Deleted.
* platform/linux/MemoryPressureHandlerLinux.cpp:
* platform/win/MemoryPressureHandlerWin.cpp:
(WebCore::MemoryPressureHandler::respondToMemoryPressure): Call releaseMemory() instead of using the handler directly.

Source/WebKit/mac:

Set the low memory handler before installing the memory pressure handler.

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):

Source/WebKit/win:

Set the low memory handler before installing the memory pressure handler.

* WebView.cpp:
(WebView::initWithFrame):

Source/WebKit2:

Set the low memory handler before installing the memory pressure handler.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):</pre>

<h3>Modified Paths</h3>
<ul>
<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="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<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><a href="#trunkSourceWebCoreplatformlinuxMemoryPressureHandlerLinuxcpp">trunk/Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformwinMemoryPressureHandlerWincpp">trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKitwinChangeLog">trunk/Source/WebKit/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitwinWebViewcpp">trunk/Source/WebKit/win/WebView.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcesscpp">trunk/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebProcessCocoamm">trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepageMemoryReleasecpp">trunk/Source/WebCore/page/MemoryRelease.cpp</a></li>
<li><a href="#trunkSourceWebCorepageMemoryReleaseh">trunk/Source/WebCore/page/MemoryRelease.h</a></li>
<li><a href="#trunkSourceWebCorepagecocoaMemoryReleaseCocoamm">trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -2040,6 +2040,7 @@
</span><span class="cx">     page/IntersectionObserverEntry.cpp
</span><span class="cx">     page/Location.cpp
</span><span class="cx">     page/MainFrame.cpp
</span><ins>+    page/MemoryRelease.cpp
</ins><span class="cx">     page/MouseEventWithHitTestResults.cpp
</span><span class="cx">     page/Navigator.cpp
</span><span class="cx">     page/NavigatorBase.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/ChangeLog        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2016-10-14  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        MemoryPressureHandler shouldn't know how to release WebCore memory
+        https://bugs.webkit.org/show_bug.cgi?id=160497
+
+        Reviewed by Michael Catanzaro.
+
+        All processes should set their own low memory handler, instead of leaving the web process using the default one
+        that needs to access APIs that are not in platform layer. This patch fixes all the layering violations in the
+        MemoryPressureHandler. Since the default implementation, that releases the WebCore memory, is shared by the
+        WebProcess in WebKit2 and WebKit1 ports, it has been moved to its own file to the WebCore layer.
+
+        * CMakeLists.txt: Add new files to compilation.
+        * PlatformMac.cmake: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::commitProvisionalLoad): Use WebCore::jettisonExpensiveObjectsOnTopLevelNavigation().
+        * page/MemoryRelease.cpp: Added.
+        (WebCore::releaseNoncriticalMemory):
+        (WebCore::releaseCriticalMemory):
+        (WebCore::releaseMemory):
+        (WebCore::platformReleaseMemory):
+        (WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
+        (WebCore::registerMemoryReleaseNotifyCallbacks):
+        * page/MemoryRelease.h: Added.
+        * page/cocoa/MemoryReleaseCocoa.mm: Added.
+        (WebCore::platformReleaseMemory):
+        (WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
+        (WebCore::registerMemoryReleaseNotifyCallbacks):
+        * platform/MemoryPressureHandler.cpp:
+        (WebCore::MemoryPressureHandler::MemoryPressureHandler):
+        (WebCore::MemoryPressureHandler::beginSimulatedMemoryPressure):
+        (WebCore::MemoryPressureHandler::releaseMemory): Use the current handler if it has been set.
+        (WebCore::MemoryPressureHandler::platformReleaseMemory): Deleted.
+        * platform/MemoryPressureHandler.h:
+        (WebCore::MemoryPressureHandler::setLowMemoryHandler):
+        (WebCore::MemoryPressureHandler::m_releaseMemoryBlock):
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::respondToMemoryPressure): Call releaseMemory() instead of using the handler directly.
+        (WebCore::MemoryPressureHandler::platformReleaseMemory): Deleted.
+        * platform/linux/MemoryPressureHandlerLinux.cpp:
+        * platform/win/MemoryPressureHandlerWin.cpp:
+        (WebCore::MemoryPressureHandler::respondToMemoryPressure): Call releaseMemory() instead of using the handler directly.
+
</ins><span class="cx"> 2016-11-08  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [css-grid] Fix fr tracks sizing under min|max-size constraints
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/PlatformMac.cmake        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -260,6 +260,7 @@
</span><span class="cx">     page/CaptionUserPreferencesMediaAF.cpp
</span><span class="cx">     page/PageDebuggable.cpp
</span><span class="cx"> 
</span><ins>+    page/cocoa/MemoryReleaseCocoa.mm
</ins><span class="cx">     page/cocoa/UserAgent.mm
</span><span class="cx">     page/cocoa/ResourceUsageOverlayCocoa.mm
</span><span class="cx">     page/cocoa/ResourceUsageThreadCocoa.mm
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -1545,6 +1545,9 @@
</span><span class="cx">                 4138F8571D253F08001CB61E /* JSDOMIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4138F8551D253EEE001CB61E /* JSDOMIterator.cpp */; };
</span><span class="cx">                 4138F8581D253F0E001CB61E /* JSDOMIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138F8561D253EEE001CB61E /* JSDOMIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 413C2C341BC29A8F0075204C /* JSDOMConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 413C2C331BC29A7B0075204C /* JSDOMConstructor.h */; };
</span><ins>+                413E00791DB0E4F2002341D2 /* MemoryRelease.h in Headers */ = {isa = PBXBuildFile; fileRef = 413E00781DB0E4DE002341D2 /* MemoryRelease.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                413E007A1DB0E4F9002341D2 /* MemoryRelease.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413E00771DB0E4DE002341D2 /* MemoryRelease.cpp */; };
+                413E007C1DB0E70A002341D2 /* MemoryReleaseCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */; };
</ins><span class="cx">                 4147E2B71C89912C00A7E715 /* FetchLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4147E2B41C89912600A7E715 /* FetchLoader.cpp */; };
</span><span class="cx">                 4147E2B81C89912F00A7E715 /* FetchBodyOwner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4147E2B31C89912600A7E715 /* FetchBodyOwner.cpp */; };
</span><span class="cx">                 414B82041D6DF0DF0077EBE3 /* StructuredClone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 414B82021D6DF0D90077EBE3 /* StructuredClone.cpp */; };
</span><span class="lines">@@ -8604,6 +8607,9 @@
</span><span class="cx">                 4138F8551D253EEE001CB61E /* JSDOMIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMIterator.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 4138F8561D253EEE001CB61E /* JSDOMIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 413C2C331BC29A7B0075204C /* JSDOMConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMConstructor.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                413E00771DB0E4DE002341D2 /* MemoryRelease.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryRelease.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                413E00781DB0E4DE002341D2 /* MemoryRelease.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryRelease.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryReleaseCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 4147E2B21C88337F00A7E715 /* FetchBodyOwner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchBodyOwner.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 4147E2B31C89912600A7E715 /* FetchBodyOwner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchBodyOwner.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 4147E2B41C89912600A7E715 /* FetchLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchLoader.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -17182,6 +17188,7 @@
</span><span class="cx">                 5D5975B5196362BE00D00878 /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */,
</ins><span class="cx">                                 ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */,
</span><span class="cx">                                 A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */,
</span><span class="cx">                                 A182D5B61BE722620087A7CC /* SettingsCocoa.mm */,
</span><span class="lines">@@ -17738,6 +17745,8 @@
</span><span class="cx">                                 BC59DEFA169DEDD80016AC34 /* make_settings.pl */,
</span><span class="cx">                                 931BCC601124DFCB00BE70DD /* MediaCanStartListener.h */,
</span><span class="cx">                                 52E2CAFB19FF0207001EEB4F /* MediaProducer.h */,
</span><ins>+                                413E00771DB0E4DE002341D2 /* MemoryRelease.cpp */,
+                                413E00781DB0E4DE002341D2 /* MemoryRelease.h */,
</ins><span class="cx">                                 93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */,
</span><span class="cx">                                 935C476209AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h */,
</span><span class="cx">                                 A9C6E5A30D746458006442E9 /* Navigator.cpp */,
</span><span class="lines">@@ -25229,6 +25238,7 @@
</span><span class="cx">                                 84730D891248F0B300D3A9C9 /* FESpecularLighting.h in Headers */,
</span><span class="cx">                                 416E6FE81BBD12DF000A6023 /* FetchInternalsBuiltins.h in Headers */,
</span><span class="cx">                                 41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */,
</span><ins>+                                413E00791DB0E4F2002341D2 /* MemoryRelease.h in Headers */,
</ins><span class="cx">                                 84730D8B1248F0B300D3A9C9 /* FETile.h in Headers */,
</span><span class="cx">                                 84730D8D1248F0B300D3A9C9 /* FETurbulence.h in Headers */,
</span><span class="cx">                                 FD31609512B026F700C1A359 /* FFTConvolver.h in Headers */,
</span><span class="lines">@@ -28540,6 +28550,7 @@
</span><span class="cx">                                 CDE8B5EC1A69777300B4B66A /* CDMPrivateClearKey.cpp in Sources */,
</span><span class="cx">                                 CDCA98EB18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp in Sources */,
</span><span class="cx">                                 CD318622199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm in Sources */,
</span><ins>+                                413E007C1DB0E70A002341D2 /* MemoryReleaseCocoa.mm in Sources */,
</ins><span class="cx">                                 CDE595951BF16DF300A1CBE8 /* CDMSessionAVContentKeySession.mm in Sources */,
</span><span class="cx">                                 CDDE02ED18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm in Sources */,
</span><span class="cx">                                 CDDE02F018B5651300CF7FF1 /* CDMSessionAVStreamSession.mm in Sources */,
</span><span class="lines">@@ -30274,6 +30285,7 @@
</span><span class="cx">                                 078E090317D14CEE00420AA1 /* MediaStreamTrackEvent.cpp in Sources */,
</span><span class="cx">                                 07FFDE68181AED420072D409 /* MediaStreamTrackPrivate.cpp in Sources */,
</span><span class="cx">                                 CD641EBF1819B36000EE4C41 /* MediaTimeAVFoundation.cpp in Sources */,
</span><ins>+                                413E007A1DB0E4F9002341D2 /* MemoryRelease.cpp in Sources */,
</ins><span class="cx">                                 CD60C0C6193E87C7003C656B /* MediaTimeQTKit.mm in Sources */,
</span><span class="cx">                                 0705853A17FE0770005F2BCB /* MediaTrackConstraint.cpp in Sources */,
</span><span class="cx">                                 0705852317FDC140005F2BCB /* MediaTrackConstraints.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -85,6 +85,7 @@
</span><span class="cx"> #include &quot;MIMETypeRegistry.h&quot;
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><span class="cx"> #include &quot;MemoryCache.h&quot;
</span><ins>+#include &quot;MemoryRelease.h&quot;
</ins><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageCache.h&quot;
</span><span class="cx"> #include &quot;PageTransitionEvent.h&quot;
</span><span class="lines">@@ -133,7 +134,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #include &quot;DocumentType.h&quot;
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &quot;ResourceLoader.h&quot;
</span><span class="cx"> #include &quot;RuntimeApplicationChecks.h&quot;
</span><span class="cx"> #include &quot;SystemMemory.h&quot;
</span><span class="lines">@@ -1775,7 +1775,7 @@
</span><span class="cx">         // We are doing this here because we know for sure that a new page is about to be loaded.
</span><span class="cx">         PageCache::singleton().addIfCacheable(*history().currentItem(), m_frame.page());
</span><span class="cx">         
</span><del>-        MemoryPressureHandler::singleton().jettisonExpensiveObjectsOnTopLevelNavigation();
</del><ins>+        WebCore::jettisonExpensiveObjectsOnTopLevelNavigation();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_loadType != FrameLoadType::Replace)
</span></span></pre></div>
<a id="trunkSourceWebCorepageMemoryReleasecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/MemoryRelease.cpp (0 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/MemoryRelease.cpp                                (rev 0)
+++ trunk/Source/WebCore/page/MemoryRelease.cpp        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -0,0 +1,171 @@
</span><ins>+/*
+ * Copyright (C) 2011, 2014 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;MemoryRelease.h&quot;
+
+#include &quot;CSSValuePool.h&quot;
+#include &quot;Chrome.h&quot;
+#include &quot;ChromeClient.h&quot;
+#include &quot;Document.h&quot;
+#include &quot;FontCache.h&quot;
+#include &quot;GCController.h&quot;
+#include &quot;HTMLMediaElement.h&quot;
+#include &quot;InlineStyleSheetOwner.h&quot;
+#include &quot;InspectorInstrumentation.h&quot;
+#include &quot;MemoryCache.h&quot;
+#include &quot;Page.h&quot;
+#include &quot;PageCache.h&quot;
+#include &quot;ScrollingThread.h&quot;
+#include &quot;StyleScope.h&quot;
+#include &quot;StyledElement.h&quot;
+#include &quot;WorkerThread.h&quot;
+#include &lt;wtf/FastMalloc.h&gt;
+
+namespace WebCore {
+
+static void releaseNoncriticalMemory()
+{
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Purge inactive FontData&quot;);
+        FontCache::singleton().purgeInactiveFontData();
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Clear WidthCaches&quot;);
+        clearWidthCaches();
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Discard Selector Query Cache&quot;);
+        for (auto* document : Document::allDocuments())
+            document-&gt;clearSelectorQueryCache();
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Prune MemoryCache dead resources&quot;);
+        MemoryCache::singleton().pruneDeadResourcesToSize(0);
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Prune presentation attribute cache&quot;);
+        StyledElement::clearPresentationAttributeCache();
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Clear inline stylesheet cache&quot;);
+        InlineStyleSheetOwner::clearCache();
+    }
+}
+
+static void releaseCriticalMemory(Synchronous synchronous)
+{
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Empty the PageCache&quot;);
+        // Right now, the only reason we call release critical memory while not under memory pressure is if the process is about to be suspended.
+        PruningReason pruningReason = MemoryPressureHandler::singleton().isUnderMemoryPressure() ? PruningReason::MemoryPressure : PruningReason::ProcessSuspended;
+        PageCache::singleton().pruneToSizeNow(0, pruningReason);
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Prune MemoryCache live resources&quot;);
+        MemoryCache::singleton().pruneLiveResourcesToSize(0, /*shouldDestroyDecodedDataForAllLiveResources*/ true);
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Drain CSSValuePool&quot;);
+        CSSValuePool::singleton().drain();
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Discard StyleResolvers&quot;);
+        Vector&lt;RefPtr&lt;Document&gt;&gt; documents;
+        copyToVector(Document::allDocuments(), documents);
+        for (auto&amp; document : documents)
+            document-&gt;styleScope().clearResolver();
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Discard all JIT-compiled code&quot;);
+        GCController::singleton().deleteAllCode();
+    }
+
+#if ENABLE(VIDEO)
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Dropping buffered data from paused media elements&quot;);
+        for (auto* mediaElement : HTMLMediaElement::allMediaElements()) {
+            if (mediaElement-&gt;paused())
+                mediaElement-&gt;purgeBufferedDataIfPossible();
+        }
+    }
+#endif
+
+    if (synchronous == Synchronous::Yes) {
+        MemoryPressureHandler::ReliefLogger log(&quot;Collecting JavaScript garbage&quot;);
+        GCController::singleton().garbageCollectNow();
+    } else
+        GCController::singleton().garbageCollectNowIfNotDoneRecently();
+
+    // We reduce tiling coverage while under memory pressure, so make sure to drop excess tiles ASAP.
+    Page::forEachPage([](Page&amp; page) {
+        page.chrome().client().scheduleCompositingLayerFlush();
+    });
+}
+
+void releaseMemory(Critical critical, Synchronous synchronous)
+{
+    if (critical == Critical::Yes)
+        releaseCriticalMemory(synchronous);
+
+    releaseNoncriticalMemory();
+
+    platformReleaseMemory(critical);
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Release free FastMalloc memory&quot;);
+        // FastMalloc has lock-free thread specific caches that can only be cleared from the thread itself.
+        WorkerThread::releaseFastMallocFreeMemoryInAllThreads();
+#if ENABLE(ASYNC_SCROLLING) &amp;&amp; !PLATFORM(IOS)
+        ScrollingThread::dispatch([]() {
+            WTF::releaseFastMallocFreeMemory();
+        });
+#endif
+        WTF::releaseFastMallocFreeMemory();
+    }
+
+#if ENABLE(RESOURCE_USAGE)
+    Page::forEachPage([&amp;](Page&amp; page) {
+        InspectorInstrumentation::didHandleMemoryPressure(page, critical);
+    });
+#endif
+}
+
+#if !PLATFORM(COCOA)
+void platformReleaseMemory(Critical) { }
+void jettisonExpensiveObjectsOnTopLevelNavigation() { }
+void registerMemoryReleaseNotifyCallbacks() { }
+#endif
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorepageMemoryReleaseh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/MemoryRelease.h (0 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/MemoryRelease.h                                (rev 0)
+++ trunk/Source/WebCore/page/MemoryRelease.h        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -0,0 +1,37 @@
</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. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &quot;MemoryPressureHandler.h&quot;
+
+namespace WebCore {
+
+WEBCORE_EXPORT void releaseMemory(Critical, Synchronous);
+void platformReleaseMemory(Critical);
+void jettisonExpensiveObjectsOnTopLevelNavigation();
+WEBCORE_EXPORT void registerMemoryReleaseNotifyCallbacks();
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorepagecocoaMemoryReleaseCocoamm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm (0 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm                                (rev 0)
+++ trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -0,0 +1,93 @@
</span><ins>+/*
+ * 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. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;MemoryRelease.h&quot;
+
+#import &quot;GCController.h&quot;
+#import &quot;IOSurfacePool.h&quot;
+#import &quot;LayerPool.h&quot;
+#import &lt;notify.h&gt;
+
+extern &quot;C&quot; void _sqlite3_purgeEligiblePagerCacheMemory(void);
+
+namespace WebCore {
+
+void platformReleaseMemory(Critical)
+{
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Purging SQLite caches&quot;);
+        _sqlite3_purgeEligiblePagerCacheMemory();
+    }
+
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Drain LayerPools&quot;);
+        for (auto&amp; pool : LayerPool::allLayerPools())
+            pool-&gt;drain();
+    }
+#if USE(IOSURFACE)
+    {
+        MemoryPressureHandler::ReliefLogger log(&quot;Drain IOSurfacePool&quot;);
+        IOSurfacePool::sharedPool().discardAllSurfaces();
+    }
+#endif
+}
+
+void jettisonExpensiveObjectsOnTopLevelNavigation()
+{
+#if PLATFORM(IOS)
+    // Protect against doing excessive jettisoning during repeated navigations.
+    const auto minimumTimeSinceNavigation = 2s;
+
+    static auto timeOfLastNavigation = std::chrono::steady_clock::now();
+    auto now = std::chrono::steady_clock::now();
+    bool shouldJettison = now - timeOfLastNavigation &gt;= minimumTimeSinceNavigation;
+    timeOfLastNavigation = now;
+
+    if (!shouldJettison)
+        return;
+
+    // Throw away linked JS code. Linked code is tied to a global object and is not reusable.
+    // The immediate memory savings outweigh the cost of recompilation in case we go back again.
+    GCController::singleton().deleteAllLinkedCode();
+#endif
+}
+
+void registerMemoryReleaseNotifyCallbacks()
+{
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        int dummy;
+        notify_register_dispatch(&quot;com.apple.WebKit.fullGC&quot;, &amp;dummy, dispatch_get_main_queue(), ^(int) {
+            GCController::singleton().garbageCollectNow();
+        });
+        notify_register_dispatch(&quot;com.apple.WebKit.deleteAllCode&quot;, &amp;dummy, dispatch_get_main_queue(), ^(int) {
+            GCController::singleton().deleteAllCode();
+            GCController::singleton().garbageCollectNow();
+        });
+    });
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -26,28 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;MemoryPressureHandler.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;CSSValuePool.h&quot;
-#include &quot;Chrome.h&quot;
-#include &quot;ChromeClient.h&quot;
-#include &quot;Document.h&quot;
-#include &quot;FontCache.h&quot;
-#include &quot;GCController.h&quot;
-#include &quot;HTMLMediaElement.h&quot;
-#include &quot;InlineStyleSheetOwner.h&quot;
-#include &quot;InspectorInstrumentation.h&quot;
</del><span class="cx"> #include &quot;Logging.h&quot;
</span><del>-#include &quot;MemoryCache.h&quot;
-#include &quot;Page.h&quot;
-#include &quot;PageCache.h&quot;
-#include &quot;ScrollingThread.h&quot;
-#include &quot;StyleScope.h&quot;
-#include &quot;StyledElement.h&quot;
-#include &quot;WorkerThread.h&quot;
-#include &lt;JavaScriptCore/IncrementalSweeper.h&gt;
-#include &lt;chrono&gt;
-#include &lt;wtf/CurrentTime.h&gt;
-#include &lt;wtf/FastMalloc.h&gt;
-#include &lt;wtf/StdLibExtras.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -59,136 +38,17 @@
</span><span class="cx">     return memoryPressureHandler;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-MemoryPressureHandler::MemoryPressureHandler() 
-    : m_installed(false)
-    , m_lastRespondTime(0)
-    , m_lowMemoryHandler([this] (Critical critical, Synchronous synchronous) { releaseMemory(critical, synchronous); })
-    , m_underMemoryPressure(false)
-#if PLATFORM(IOS)
-    // FIXME: Can we share more of this with OpenSource?
-    , m_memoryPressureReason(MemoryPressureReasonNone)
-    , m_clearPressureOnMemoryRelease(true)
-    , m_releaseMemoryBlock(0)
-    , m_observer(0)
-#elif OS(LINUX)
-    , m_holdOffTimer(RunLoop::main(), this, &amp;MemoryPressureHandler::holdOffTimerFired)
</del><ins>+MemoryPressureHandler::MemoryPressureHandler()
+#if OS(LINUX)
+    : m_holdOffTimer(RunLoop::main(), this, &amp;MemoryPressureHandler::holdOffTimerFired)
</ins><span class="cx"> #endif
</span><span class="cx"> {
</span><del>-    platformInitialize();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MemoryPressureHandler::releaseNoncriticalMemory()
-{
-    {
-        ReliefLogger log(&quot;Purge inactive FontData&quot;);
-        FontCache::singleton().purgeInactiveFontData();
-    }
-
-    {
-        ReliefLogger log(&quot;Clear WidthCaches&quot;);
-        clearWidthCaches();
-    }
-
-    {
-        ReliefLogger log(&quot;Discard Selector Query Cache&quot;);
-        for (auto* document : Document::allDocuments())
-            document-&gt;clearSelectorQueryCache();
-    }
-
-    {
-        ReliefLogger log(&quot;Prune MemoryCache dead resources&quot;);
-        MemoryCache::singleton().pruneDeadResourcesToSize(0);
-    }
-
-    {
-        ReliefLogger log(&quot;Prune presentation attribute cache&quot;);
-        StyledElement::clearPresentationAttributeCache();
-    }
-
-    {
-        ReliefLogger log(&quot;Clear inline stylesheet cache&quot;);
-        InlineStyleSheetOwner::clearCache();
-    }
-}
-
-void MemoryPressureHandler::releaseCriticalMemory(Synchronous synchronous)
-{
-    {
-        ReliefLogger log(&quot;Empty the PageCache&quot;);
-        // Right now, the only reason we call release critical memory while not under memory pressure is if the process is about to be suspended.
-        PruningReason pruningReason = isUnderMemoryPressure() ? PruningReason::MemoryPressure : PruningReason::ProcessSuspended;
-        PageCache::singleton().pruneToSizeNow(0, pruningReason);
-    }
-
-    {
-        ReliefLogger log(&quot;Prune MemoryCache live resources&quot;);
-        MemoryCache::singleton().pruneLiveResourcesToSize(0, /*shouldDestroyDecodedDataForAllLiveResources*/ true);
-    }
-
-    {
-        ReliefLogger log(&quot;Drain CSSValuePool&quot;);
-        CSSValuePool::singleton().drain();
-    }
-
-    {
-        ReliefLogger log(&quot;Discard StyleResolvers&quot;);
-        Vector&lt;RefPtr&lt;Document&gt;&gt; documents;
-        copyToVector(Document::allDocuments(), documents);
-        for (auto&amp; document : documents)
-            document-&gt;styleScope().clearResolver();
-    }
-
-    {
-        ReliefLogger log(&quot;Discard all JIT-compiled code&quot;);
-        GCController::singleton().deleteAllCode();
-    }
-
-#if ENABLE(VIDEO)
-    {
-        ReliefLogger log(&quot;Dropping buffered data from paused media elements&quot;);
-        for (auto* mediaElement: HTMLMediaElement::allMediaElements()) {
-            if (mediaElement-&gt;paused())
-                mediaElement-&gt;purgeBufferedDataIfPossible();
-        }
-    }
-#endif
-
-    if (synchronous == Synchronous::Yes) {
-        ReliefLogger log(&quot;Collecting JavaScript garbage&quot;);
-        GCController::singleton().garbageCollectNow();
-    } else
-        GCController::singleton().garbageCollectNowIfNotDoneRecently();
-
-    // We reduce tiling coverage while under memory pressure, so make sure to drop excess tiles ASAP.
-    Page::forEachPage([](Page&amp; page) {
-        page.chrome().client().scheduleCompositingLayerFlush();
-    });
-}
-
-void MemoryPressureHandler::jettisonExpensiveObjectsOnTopLevelNavigation()
-{
-#if PLATFORM(IOS)
-    // Protect against doing excessive jettisoning during repeated navigations.
-    const auto minimumTimeSinceNavigation = 2s;
-
-    static auto timeOfLastNavigation = std::chrono::steady_clock::now();
-    auto now = std::chrono::steady_clock::now();
-    bool shouldJettison = now - timeOfLastNavigation &gt;= minimumTimeSinceNavigation;
-    timeOfLastNavigation = now;
-
-    if (!shouldJettison)
-        return;
-
-    // Throw away linked JS code. Linked code is tied to a global object and is not reusable.
-    // The immediate memory savings outweigh the cost of recompilation in case we go back again.
-    GCController::singleton().deleteAllLinkedCode();
-#endif
-}
-
</del><span class="cx"> void MemoryPressureHandler::beginSimulatedMemoryPressure()
</span><span class="cx"> {
</span><span class="cx">     m_isSimulatingMemoryPressure = true;
</span><del>-    MemoryPressureHandler::singleton().respondToMemoryPressure(Critical::Yes, Synchronous::Yes);
</del><ins>+    respondToMemoryPressure(Critical::Yes, Synchronous::Yes);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MemoryPressureHandler::endSimulatedMemoryPressure()
</span><span class="lines">@@ -198,30 +58,11 @@
</span><span class="cx"> 
</span><span class="cx"> void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous)
</span><span class="cx"> {
</span><del>-    if (critical == Critical::Yes)
-        releaseCriticalMemory(synchronous);
</del><ins>+    if (!m_lowMemoryHandler)
+        return;
</ins><span class="cx"> 
</span><del>-    releaseNoncriticalMemory();
-
</del><ins>+    m_lowMemoryHandler(critical, synchronous);
</ins><span class="cx">     platformReleaseMemory(critical);
</span><del>-
-    {
-        ReliefLogger log(&quot;Release free FastMalloc memory&quot;);
-        // FastMalloc has lock-free thread specific caches that can only be cleared from the thread itself.
-        WorkerThread::releaseFastMallocFreeMemoryInAllThreads();
-#if ENABLE(ASYNC_SCROLLING) &amp;&amp; !PLATFORM(IOS)
-        ScrollingThread::dispatch([]() {
-            WTF::releaseFastMallocFreeMemory();
-        });
-#endif
-        WTF::releaseFastMallocFreeMemory();
-    }
-
-#if ENABLE(RESOURCE_USAGE)
-    Page::forEachPage([&amp;](Page&amp; page) {
-        InspectorInstrumentation::didHandleMemoryPressure(page, critical);
-    });
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MemoryPressureHandler::ReliefLogger::logMemoryUsageChange()
</span><span class="lines">@@ -249,10 +90,6 @@
</span><span class="cx">         MEMORYPRESSURE_LOG(&quot;Memory pressure relief: &quot; STRING_SPECIFICATION &quot;: =dirty (at %zu bytes)&quot;, m_logString, currentMemory);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !PLATFORM(COCOA)
-void MemoryPressureHandler::platformInitialize() { }
-#endif
-
</del><span class="cx"> #if !PLATFORM(COCOA) &amp;&amp; !OS(LINUX) &amp;&amp; !PLATFORM(WIN)
</span><span class="cx"> void MemoryPressureHandler::install() { }
</span><span class="cx"> void MemoryPressureHandler::uninstall() { }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.h        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #include &lt;wtf/Lock.h&gt;
</span><span class="lines">@@ -66,14 +67,12 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void install();
</span><span class="cx"> 
</span><del>-    void setLowMemoryHandler(LowMemoryHandler handler)
</del><ins>+    void setLowMemoryHandler(LowMemoryHandler&amp;&amp; handler)
</ins><span class="cx">     {
</span><span class="cx">         ASSERT(!m_installed);
</span><del>-        m_lowMemoryHandler = handler;
</del><ins>+        m_lowMemoryHandler = WTFMove(handler);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void jettisonExpensiveObjectsOnTopLevelNavigation();
-
</del><span class="cx">     bool isUnderMemoryPressure() const { return m_underMemoryPressure || m_isSimulatingMemoryPressure; }
</span><span class="cx">     void setUnderMemoryPressure(bool b) { m_underMemoryPressure = b; }
</span><span class="cx"> 
</span><span class="lines">@@ -130,10 +129,6 @@
</span><span class="cx">     WEBCORE_EXPORT void endSimulatedMemoryPressure();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void platformInitialize();
-    void releaseNoncriticalMemory();
-    void releaseCriticalMemory(Synchronous);
-
</del><span class="cx">     void uninstall();
</span><span class="cx"> 
</span><span class="cx">     void holdOff(unsigned);
</span><span class="lines">@@ -164,8 +159,8 @@
</span><span class="cx">     };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    bool m_installed;
-    time_t m_lastRespondTime;
</del><ins>+    bool m_installed { false };
+    time_t m_lastRespondTime { 0 };
</ins><span class="cx">     LowMemoryHandler m_lowMemoryHandler;
</span><span class="cx"> 
</span><span class="cx">     std::atomic&lt;bool&gt; m_underMemoryPressure;
</span><span class="lines">@@ -172,10 +167,11 @@
</span><span class="cx">     bool m_isSimulatingMemoryPressure { false };
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    uint32_t m_memoryPressureReason;
-    bool m_clearPressureOnMemoryRelease;
-    void (^m_releaseMemoryBlock)();
-    CFRunLoopObserverRef m_observer;
</del><ins>+    // FIXME: Can we share more of this with OpenSource?
+    uint32_t m_memoryPressureReason { MemoryPressureReasonNone };
+    bool m_clearPressureOnMemoryRelease { true };
+    void (^m_releaseMemoryBlock)() { nullptr };
+    CFRunLoopObserverRef m_observer { nullptr };
</ins><span class="cx">     Lock m_observerMutex;
</span><span class="cx"> #elif OS(LINUX)
</span><span class="cx">     Optional&lt;int&gt; m_eventFD;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaMemoryPressureHandlerCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -26,15 +26,12 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;MemoryPressureHandler.h&quot;
</span><span class="cx"> 
</span><del>-#import &quot;GCController.h&quot;
-#import &quot;IOSurfacePool.h&quot;
-#import &quot;LayerPool.h&quot;
</del><span class="cx"> #import &quot;Logging.h&quot;
</span><del>-#import &quot;ResourceUsageThread.h&quot;
</del><span class="cx"> #import &lt;mach/mach.h&gt;
</span><span class="cx"> #import &lt;mach/task_info.h&gt;
</span><span class="cx"> #import &lt;malloc/malloc.h&gt;
</span><span class="cx"> #import &lt;notify.h&gt;
</span><ins>+#import &lt;wtf/CurrentTime.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #import &quot;SystemMemory.h&quot;
</span><span class="lines">@@ -44,41 +41,11 @@
</span><span class="cx"> #define ENABLE_FMW_FOOTPRINT_COMPARISON 0
</span><span class="cx"> 
</span><span class="cx"> extern &quot;C&quot; void cache_simulate_memory_warning_event(uint64_t);
</span><del>-extern &quot;C&quot; void _sqlite3_purgeEligiblePagerCacheMemory(void);
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-void MemoryPressureHandler::platformInitialize()
-{
-    int dummy;
-    notify_register_dispatch(&quot;com.apple.WebKit.fullGC&quot;, &amp;dummy, dispatch_get_main_queue(), ^(int) {
-        GCController::singleton().garbageCollectNow();
-    });
-    notify_register_dispatch(&quot;com.apple.WebKit.deleteAllCode&quot;, &amp;dummy, dispatch_get_main_queue(), ^(int) {
-        GCController::singleton().deleteAllCode();
-        GCController::singleton().garbageCollectNow();
-    });
-}
-
</del><span class="cx"> void MemoryPressureHandler::platformReleaseMemory(Critical critical)
</span><span class="cx"> {
</span><del>-    {
-        ReliefLogger log(&quot;Purging SQLite caches&quot;);
-        _sqlite3_purgeEligiblePagerCacheMemory();
-    }
-
-    {
-        ReliefLogger log(&quot;Drain LayerPools&quot;);
-        for (auto&amp; pool : LayerPool::allLayerPools())
-            pool-&gt;drain();
-    }
-#if USE(IOSURFACE)
-    {
-        ReliefLogger log(&quot;Drain IOSurfacePool&quot;);
-        IOSurfacePool::sharedPool().discardAllSurfaces();
-    }
-#endif
-
</del><span class="cx">     if (critical == Critical::Yes &amp;&amp; (!isUnderMemoryPressure() || m_isSimulatingMemoryPressure)) {
</span><span class="cx">         // libcache listens to OS memory notifications, but for process suspension
</span><span class="cx">         // or memory pressure simulation, we need to prod it manually:
</span><span class="lines">@@ -211,7 +178,7 @@
</span><span class="cx">     double startTime = monotonicallyIncreasingTime();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    m_lowMemoryHandler(critical, synchronous);
</del><ins>+    releaseMemory(critical, synchronous);
</ins><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">     unsigned holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformlinuxMemoryPressureHandlerLinuxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -298,7 +298,7 @@
</span><span class="cx">     uninstall();
</span><span class="cx"> 
</span><span class="cx">     double startTime = monotonicallyIncreasingTime();
</span><del>-    m_lowMemoryHandler(critical, synchronous);
</del><ins>+    releaseMemory(critical, synchronous);
</ins><span class="cx">     unsigned holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
</span><span class="cx">     holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinMemoryPressureHandlerWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -120,7 +120,7 @@
</span><span class="cx"> {
</span><span class="cx">     uninstall();
</span><span class="cx"> 
</span><del>-    m_lowMemoryHandler(critical, synchronous);
</del><ins>+    releaseMemory(critical, synchronous);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> size_t MemoryPressureHandler::ReliefLogger::platformMemoryUsage()
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-10-14  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        MemoryPressureHandler shouldn't know how to release WebCore memory
+        https://bugs.webkit.org/show_bug.cgi?id=160497
+
+        Reviewed by Michael Catanzaro.
+
+        Set the low memory handler before installing the memory pressure handler.
+
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+
</ins><span class="cx"> 2016-11-09  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         WebHTMLView's _attributeStringFromDOMRange should use HTMLConverter instead of NSAttributedString's _initWithDOMRange
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx"> #import &lt;WebCore/MIMETypeRegistry.h&gt;
</span><span class="cx"> #import &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #import &lt;WebCore/MemoryCache.h&gt;
</span><del>-#import &lt;WebCore/MemoryPressureHandler.h&gt;
</del><ins>+#import &lt;WebCore/MemoryRelease.h&gt;
</ins><span class="cx"> #import &lt;WebCore/NSSpellCheckerSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/NSTouchBarSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/NSURLFileTypeMappingsSPI.h&gt;
</span><span class="lines">@@ -1430,9 +1430,19 @@
</span><span class="cx">     _private-&gt;page-&gt;settings().setFontFallbackPrefersPictographs(true);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (![[NSUserDefaults standardUserDefaults] boolForKey:@&quot;WebKitSuppressMemoryPressureHandler&quot;])
-        MemoryPressureHandler::singleton().install();
</del><ins>+    if (![[NSUserDefaults standardUserDefaults] boolForKey:@&quot;WebKitSuppressMemoryPressureHandler&quot;]) {
+        WebCore::registerMemoryReleaseNotifyCallbacks();
</ins><span class="cx"> 
</span><ins>+        static std::once_flag onceFlag;
+        std::call_once(onceFlag, [] {
+            auto&amp; memoryPressureHandler = MemoryPressureHandler::singleton();
+            memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous synchronous) {
+                WebCore::releaseMemory(critical, synchronous);
+            });
+            memoryPressureHandler.install();
+        });
+    }
+
</ins><span class="cx">     if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION)) {
</span><span class="cx">         // Originally, we allowed all local loads.
</span><span class="cx">         SecurityPolicy::setLocalLoadPolicy(SecurityPolicy::AllowLocalLoadsForAll);
</span></span></pre></div>
<a id="trunkSourceWebKitwinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/ChangeLog (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/ChangeLog        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebKit/win/ChangeLog        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-10-14  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        MemoryPressureHandler shouldn't know how to release WebCore memory
+        https://bugs.webkit.org/show_bug.cgi?id=160497
+
+        Reviewed by Michael Catanzaro.
+
+        Set the low memory handler before installing the memory pressure handler.
+
+        * WebView.cpp:
+        (WebView::initWithFrame):
+
</ins><span class="cx"> 2016-11-09  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix Windows build after r208499
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebView.cpp (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebView.cpp        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebKit/win/WebView.cpp        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx"> #include &lt;WebCore/MIMETypeRegistry.h&gt;
</span><span class="cx"> #include &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #include &lt;WebCore/MemoryCache.h&gt;
</span><del>-#include &lt;WebCore/MemoryPressureHandler.h&gt;
</del><ins>+#include &lt;WebCore/MemoryRelease.h&gt;
</ins><span class="cx"> #include &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #include &lt;WebCore/Page.h&gt;
</span><span class="cx"> #include &lt;WebCore/PageCache.h&gt;
</span><span class="lines">@@ -3084,7 +3084,11 @@
</span><span class="cx"> 
</span><span class="cx">         WebKitInitializeWebDatabasesIfNecessary();
</span><span class="cx"> 
</span><del>-        MemoryPressureHandler::singleton().install();
</del><ins>+        auto&amp; memoryPressureHandler = MemoryPressureHandler::singleton();
+        memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous synchronous) {
+            WebCore::releaseMemory(critical, synchronous);
+        });
+        memoryPressureHandler.install();
</ins><span class="cx"> 
</span><span class="cx">         didOneTimeInitialization = true;
</span><span class="cx">      }
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebKit2/ChangeLog        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-10-14  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        MemoryPressureHandler shouldn't know how to release WebCore memory
+        https://bugs.webkit.org/show_bug.cgi?id=160497
+
+        Reviewed by Michael Catanzaro.
+
+        Set the low memory handler before installing the memory pressure handler.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
</ins><span class="cx"> 2016-10-27  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] New API to notify about dynamically added forms
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx"> #include &lt;WebCore/Language.h&gt;
</span><span class="cx"> #include &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #include &lt;WebCore/MemoryCache.h&gt;
</span><del>-#include &lt;WebCore/MemoryPressureHandler.h&gt;
</del><ins>+#include &lt;WebCore/MemoryRelease.h&gt;
</ins><span class="cx"> #include &lt;WebCore/NetworkStorageSession.h&gt;
</span><span class="cx"> #include &lt;WebCore/Page.h&gt;
</span><span class="cx"> #include &lt;WebCore/PageCache.h&gt;
</span><span class="lines">@@ -273,8 +273,13 @@
</span><span class="cx">     WTF::setCurrentThreadIsUserInteractive(-1);
</span><span class="cx"> 
</span><span class="cx">     m_suppressMemoryPressureHandler = parameters.shouldSuppressMemoryPressureHandler;
</span><del>-    if (!m_suppressMemoryPressureHandler)
-        MemoryPressureHandler::singleton().install();
</del><ins>+    if (!m_suppressMemoryPressureHandler) {
+        auto&amp; memoryPressureHandler = MemoryPressureHandler::singleton();
+        memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous synchronous) {
+            WebCore::releaseMemory(critical, synchronous);
+        });
+        memoryPressureHandler.install();
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (!parameters.injectedBundlePath.isEmpty())
</span><span class="cx">         m_injectedBundle = InjectedBundle::create(parameters, transformHandlesToObjects(parameters.initializationUserData.object()).get());
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebProcessCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm (208533 => 208534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm        2016-11-10 13:37:38 UTC (rev 208533)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm        2016-11-10 14:24:26 UTC (rev 208534)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> #import &lt;WebCore/FontCache.h&gt;
</span><span class="cx"> #import &lt;WebCore/FontCascade.h&gt;
</span><span class="cx"> #import &lt;WebCore/LocalizedStrings.h&gt;
</span><del>-#import &lt;WebCore/MemoryPressureHandler.h&gt;
</del><ins>+#import &lt;WebCore/MemoryRelease.h&gt;
</ins><span class="cx"> #import &lt;WebCore/NSAccessibilitySPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/RuntimeApplicationChecks.h&gt;
</span><span class="cx"> #import &lt;WebCore/VNodeTracker.h&gt;
</span><span class="lines">@@ -120,6 +120,7 @@
</span><span class="cx">     m_compositingRenderServerPort = WTFMove(parameters.acceleratedCompositingPort);
</span><span class="cx">     m_presenterApplicationPid = parameters.presenterApplicationPid;
</span><span class="cx"> 
</span><ins>+    WebCore::registerMemoryReleaseNotifyCallbacks();
</ins><span class="cx">     MemoryPressureHandler::ReliefLogger::setLoggingEnabled(parameters.shouldEnableMemoryPressureReliefLogging);
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre>
</div>
</div>

</body>
</html>