memoryFootprint should return size_t not optional<size_t>
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 20:13:27 +0000 (20:13 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 20:13:27 +0000 (20:13 +0000)
commit05fdef877e9a2d783f0121f1462661d08191e359
tree90a94b08c37d8f45549168a04539a9fbbdc17d1e
parentbf4aebab83dd17f2d50d8667c7976837d2673891
memoryFootprint should return size_t not optional<size_t>
https://bugs.webkit.org/show_bug.cgi?id=188444

Reviewed by Simon Fraser.

Source/WebCore:

* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::ResourceUsageOverlay::platformDraw):

Source/WTF:

We're now going to return zero instead of returning nullopt on failure.
There was a lot of code dancing around memoryFootprint failing for no
good reason.

Users of this API were previously doing this on failure:
- Treating it as zero (this was the most common user).
- Crashing.
- Bailing out early and not changing our memory pressure state. This change
has the effect that instead of not changing our memory pressure state on
failure, we will go back to thinking we're not under memory pressure. Since
we relied on this API not failing to do anything useful (like kill the process
or release memory), this won't change our behavior here in a meaningful way.

* wtf/MemoryFootprint.h:
* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::currentMemoryUsagePolicy):
(WTF::MemoryPressureHandler::shrinkOrDie):
(WTF::MemoryPressureHandler::measurementTimerFired):
* wtf/cocoa/MemoryFootprintCocoa.cpp:
(WTF::memoryFootprint):
* wtf/linux/MemoryFootprintLinux.cpp:
(WTF::memoryFootprint):
* wtf/linux/MemoryPressureHandlerLinux.cpp:
(WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
* wtf/win/MemoryFootprintWin.cpp:
(WTF::memoryFootprint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/MemoryFootprint.h
Source/WTF/wtf/MemoryPressureHandler.cpp
Source/WTF/wtf/cocoa/MemoryFootprintCocoa.cpp
Source/WTF/wtf/linux/MemoryFootprintLinux.cpp
Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp
Source/WTF/wtf/win/MemoryFootprintWin.cpp
Source/WebCore/ChangeLog
Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm