MemoryPressureHandler shouldn't know how to release WebCore memory
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2016 14:24:26 +0000 (14:24 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2016 14:24:26 +0000 (14:24 +0000)
commitb801ce34321be1dbec9ea4af94d40d302131a293
treecd00f4dfa2333fec66ef2fee35a03916d0b8a2c7
parent5960b658b43f012d8e65745958ce3cda2b563cdb
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/PlatformMac.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/page/MemoryRelease.cpp [new file with mode: 0644]
Source/WebCore/page/MemoryRelease.h [new file with mode: 0644]
Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm [new file with mode: 0644]
Source/WebCore/platform/MemoryPressureHandler.cpp
Source/WebCore/platform/MemoryPressureHandler.h
Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm
Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp
Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm