<!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>[195644] 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/195644">195644</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-26 17:29:25 -0800 (Tue, 26 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Generalize ResourceUsageData gathering to be used outside of ResourceUsageOverlay
https://bugs.webkit.org/show_bug.cgi?id=153509
&lt;rdar://problem/24354291&gt;

Reviewed by Andreas Kling.

Source/JavaScriptCore:

* heap/Heap.h:
* heap/HeapInlines.h:
(JSC::Heap::didAllocateBlock):
(JSC::Heap::didFreeBlock):
Rename the ENABLE flag.

Source/WebCore:

* CMakeLists.txt:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* page/Page.cpp:
* page/Page.h:
* page/Settings.cpp:
* page/Settings.h:
* page/ResourceUsageOverlay.cpp:
* page/ResourceUsageOverlay.h:
Add new files to the build and updated ENABLE flag name.

* page/ResourceUsageData.cpp: Added.
(WebCore::ResourceUsageData::ResourceUsageData):
* page/ResourceUsageData.h: Added.
(WebCore::MemoryCategoryInfo::MemoryCategoryInfo):
Platform agnostic resource data that may be used by multiple clients,
such as the ResourceUsageOverlay and later the Inspector.

* page/ResourceUsageThread.h: Added.
* page/ResourceUsageThread.cpp: Added.
(WebCore::ResourceUsageThread::ResourceUsageThread):
(WebCore::ResourceUsageThread::singleton):
(WebCore::ResourceUsageThread::addObserver):
(WebCore::ResourceUsageThread::removeObserver):
(WebCore::ResourceUsageThread::waitUntilObservers):
(WebCore::ResourceUsageThread::notifyObservers):
(WebCore::ResourceUsageThread::createThreadIfNeeded):
(WebCore::ResourceUsageThread::threadCallback):
(WebCore::ResourceUsageThread::threadBody):
Platform agnostic resource usage thread that can be used to gather data
into a ResourceUsageData struct on a background thread and notify observers
on the main thread. Platforms need only implement ResourceUsageThread::platformThreadBody
to populate the ResourceUsageData struct with data.

* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::HistoricMemoryCategoryInfo::HistoricMemoryCategoryInfo):
(WebCore::HistoricResourceUsageData::HistoricResourceUsageData):
(WebCore::historicUsageData):
(WebCore::appendDataToHistory):
(WebCore::ResourceUsageOverlay::platformInitialize):
(WebCore::ResourceUsageOverlay::platformDestroy):
(WebCore::drawMemHistory):
(WebCore::drawMemoryPie):
(WebCore::ResourceUsageOverlay::platformDraw):
Move CPU and memory resource usage calculations to ResourceUsageThread.
The overlay adds itself as an observer, and builds its RingBuffer list
of data from notifications from the ResourceUsageThread. Renamed
some of the fields.

* page/cocoa/ResourceUsageThreadCocoa.mm: Added.
(WebCore::vmPageSize):
(WebCore::TagInfo::TagInfo):
(WebCore::pagesPerVMTag):
(WebCore::cpuUsage):
(WebCore::categoryForVMTag):
(WebCore::ResourceUsageThread::platformThreadBody):
Extracted from ResourceUsageOverlayCocoa.

* page/scrolling/ScrollingThread.cpp:
(WebCore::ScrollingThread::dispatch):
Drive-by, don't call singleton again, we already have the result.

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Rename the ENABLE flag.

Source/WTF:

* wtf/Platform.h:
Rename the ENABLE flag.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeaph">trunk/Source/JavaScriptCore/heap/Heap.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapInlinesh">trunk/Source/JavaScriptCore/heap/HeapInlines.h</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformh">trunk/Source/WTF/wtf/Platform.h</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="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageOverlaycpp">trunk/Source/WebCore/page/ResourceUsageOverlay.cpp</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageOverlayh">trunk/Source/WebCore/page/ResourceUsageOverlay.h</a></li>
<li><a href="#trunkSourceWebCorepageSettingscpp">trunk/Source/WebCore/page/Settings.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsh">trunk/Source/WebCore/page/Settings.h</a></li>
<li><a href="#trunkSourceWebCorepagecocoaResourceUsageOverlayCocoamm">trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm</a></li>
<li><a href="#trunkSourceWebCorepagescrollingScrollingThreadcpp">trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepageResourceUsageDatacpp">trunk/Source/WebCore/page/ResourceUsageData.cpp</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageDatah">trunk/Source/WebCore/page/ResourceUsageData.h</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageThreadcpp">trunk/Source/WebCore/page/ResourceUsageThread.cpp</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageThreadh">trunk/Source/WebCore/page/ResourceUsageThread.h</a></li>
<li><a href="#trunkSourceWebCorepagecocoaResourceUsageThreadCocoamm">trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-01-26  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Generalize ResourceUsageData gathering to be used outside of ResourceUsageOverlay
+        https://bugs.webkit.org/show_bug.cgi?id=153509
+        &lt;rdar://problem/24354291&gt;
+
+        Reviewed by Andreas Kling.
+
+        * heap/Heap.h:
+        * heap/HeapInlines.h:
+        (JSC::Heap::didAllocateBlock):
+        (JSC::Heap::didFreeBlock):
+        Rename the ENABLE flag.
+
</ins><span class="cx"> 2016-01-26  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [B3] Fix control reaches end of non-void function GCC warning after r195139
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/Heap.h (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/Heap.h        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/JavaScriptCore/heap/Heap.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx"> 
</span><span class="cx">     void addLogicallyEmptyWeakBlock(WeakBlock*);
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     size_t blockBytesAllocated() const { return m_blockBytesAllocated; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -456,7 +456,7 @@
</span><span class="cx"> 
</span><span class="cx">     ParallelHelperClient m_helperClient;
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     size_t m_blockBytesAllocated { 0 };
</span><span class="cx"> #endif
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/HeapInlines.h (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/HeapInlines.h        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/JavaScriptCore/heap/HeapInlines.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -310,7 +310,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline void Heap::didAllocateBlock(size_t capacity)
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     m_blockBytesAllocated += capacity;
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(capacity);
</span><span class="lines">@@ -319,7 +319,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline void Heap::didFreeBlock(size_t capacity)
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     m_blockBytesAllocated -= capacity;
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(capacity);
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WTF/ChangeLog        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-01-26  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Generalize ResourceUsageData gathering to be used outside of ResourceUsageOverlay
+        https://bugs.webkit.org/show_bug.cgi?id=153509
+        &lt;rdar://problem/24354291&gt;
+
+        Reviewed by Andreas Kling.
+
+        * wtf/Platform.h:
+        Rename the ENABLE flag.
+
</ins><span class="cx"> 2016-01-26  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make HashTable iterators STL iterators compatible
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WTF/wtf/Platform.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -1091,7 +1091,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-#define ENABLE_RESOURCE_USAGE_OVERLAY 1
</del><ins>+#define ENABLE_RESOURCE_USAGE 1
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK) || PLATFORM(EFL)
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -2039,7 +2039,9 @@
</span><span class="cx">     page/PerformanceUserTiming.cpp
</span><span class="cx">     page/PointerLockController.cpp
</span><span class="cx">     page/PrintContext.cpp
</span><ins>+    page/ResourceUsageData.cpp
</ins><span class="cx">     page/ResourceUsageOverlay.cpp
</span><ins>+    page/ResourceUsageThread.cpp
</ins><span class="cx">     page/Screen.cpp
</span><span class="cx">     page/SecurityOrigin.cpp
</span><span class="cx">     page/SecurityOriginData.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/ChangeLog        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -1,3 +1,73 @@
</span><ins>+2016-01-26  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Generalize ResourceUsageData gathering to be used outside of ResourceUsageOverlay
+        https://bugs.webkit.org/show_bug.cgi?id=153509
+        &lt;rdar://problem/24354291&gt;
+
+        Reviewed by Andreas Kling.
+
+        * CMakeLists.txt:
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/Page.cpp:
+        * page/Page.h:
+        * page/Settings.cpp:
+        * page/Settings.h:
+        * page/ResourceUsageOverlay.cpp:
+        * page/ResourceUsageOverlay.h:
+        Add new files to the build and updated ENABLE flag name.
+
+        * page/ResourceUsageData.cpp: Added.
+        (WebCore::ResourceUsageData::ResourceUsageData):
+        * page/ResourceUsageData.h: Added.
+        (WebCore::MemoryCategoryInfo::MemoryCategoryInfo):
+        Platform agnostic resource data that may be used by multiple clients,
+        such as the ResourceUsageOverlay and later the Inspector.
+
+        * page/ResourceUsageThread.h: Added.
+        * page/ResourceUsageThread.cpp: Added.
+        (WebCore::ResourceUsageThread::ResourceUsageThread):
+        (WebCore::ResourceUsageThread::singleton):
+        (WebCore::ResourceUsageThread::addObserver):
+        (WebCore::ResourceUsageThread::removeObserver):
+        (WebCore::ResourceUsageThread::waitUntilObservers):
+        (WebCore::ResourceUsageThread::notifyObservers):
+        (WebCore::ResourceUsageThread::createThreadIfNeeded):
+        (WebCore::ResourceUsageThread::threadCallback):
+        (WebCore::ResourceUsageThread::threadBody):
+        Platform agnostic resource usage thread that can be used to gather data
+        into a ResourceUsageData struct on a background thread and notify observers
+        on the main thread. Platforms need only implement ResourceUsageThread::platformThreadBody
+        to populate the ResourceUsageData struct with data.
+
+        * page/cocoa/ResourceUsageOverlayCocoa.mm:
+        (WebCore::HistoricMemoryCategoryInfo::HistoricMemoryCategoryInfo):
+        (WebCore::HistoricResourceUsageData::HistoricResourceUsageData):
+        (WebCore::historicUsageData):
+        (WebCore::appendDataToHistory):
+        (WebCore::ResourceUsageOverlay::platformInitialize):
+        (WebCore::ResourceUsageOverlay::platformDestroy):
+        (WebCore::drawMemHistory):
+        (WebCore::drawMemoryPie):
+        (WebCore::ResourceUsageOverlay::platformDraw):
+        Move CPU and memory resource usage calculations to ResourceUsageThread.
+        The overlay adds itself as an observer, and builds its RingBuffer list
+        of data from notifications from the ResourceUsageThread. Renamed
+        some of the fields.
+
+        * page/cocoa/ResourceUsageThreadCocoa.mm: Added.
+        (WebCore::vmPageSize):
+        (WebCore::TagInfo::TagInfo):
+        (WebCore::pagesPerVMTag):
+        (WebCore::cpuUsage):
+        (WebCore::categoryForVMTag):
+        (WebCore::ResourceUsageThread::platformThreadBody):
+        Extracted from ResourceUsageOverlayCocoa.
+
+        * page/scrolling/ScrollingThread.cpp:
+        (WebCore::ScrollingThread::dispatch):
+        Drive-by, don't call singleton again, we already have the result.
+
</ins><span class="cx"> 2016-01-26  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Use initializers in HTMLCanvasElement
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/PlatformMac.cmake        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -271,6 +271,7 @@
</span><span class="cx"> 
</span><span class="cx">     page/cocoa/UserAgent.mm
</span><span class="cx">     page/cocoa/ResourceUsageOverlayCocoa.mm
</span><ins>+    page/cocoa/ResourceUsageOverlayThread.mm
</ins><span class="cx">     page/cocoa/SettingsCocoa.mm
</span><span class="cx"> 
</span><span class="cx">     page/mac/ChromeMac.mm
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -4158,6 +4158,11 @@
</span><span class="cx">                 A456FA2711AD4A830020B420 /* LabelsNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = A456FA2511AD4A830020B420 /* LabelsNodeList.h */; };
</span><span class="cx">                 A501920E132EBF2E008BFE55 /* Autocapitalize.h in Headers */ = {isa = PBXBuildFile; fileRef = A501920C132EBF2E008BFE55 /* Autocapitalize.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A502C5DF13049B3500FC7D53 /* WebSafeGCActivityCallbackIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A502C5DD13049B3500FC7D53 /* WebSafeGCActivityCallbackIOS.h */; };
</span><ins>+                A5071E851C56D0DC009951BE /* ResourceUsageData.h in Headers */ = {isa = PBXBuildFile; fileRef = A5071E821C56D079009951BE /* ResourceUsageData.h */; };
+                A5071E861C56D0DF009951BE /* ResourceUsageThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5071E831C56D079009951BE /* ResourceUsageThread.cpp */; };
+                A5071E871C56D0E1009951BE /* ResourceUsageThread.h in Headers */ = {isa = PBXBuildFile; fileRef = A5071E841C56D079009951BE /* ResourceUsageThread.h */; };
+                A5071E891C56D4FE009951BE /* ResourceUsageThreadCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */; };
+                A5071E8B1C56FB31009951BE /* ResourceUsageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */; };
</ins><span class="cx">                 A513B3D7114B1666001C429B /* KeyEventCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */; };
</span><span class="cx">                 A513B3D8114B166A001C429B /* KeyEventCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */; };
</span><span class="cx">                 A516E8B7136E04DB0076C3C0 /* LocalizedDateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A516E8B4136E04DB0076C3C0 /* LocalizedDateCache.h */; };
</span><span class="lines">@@ -11765,6 +11770,11 @@
</span><span class="cx">                 A456FA2511AD4A830020B420 /* LabelsNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelsNodeList.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A501920C132EBF2E008BFE55 /* Autocapitalize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Autocapitalize.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A502C5DD13049B3500FC7D53 /* WebSafeGCActivityCallbackIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSafeGCActivityCallbackIOS.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A5071E821C56D079009951BE /* ResourceUsageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceUsageData.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A5071E831C56D079009951BE /* ResourceUsageThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageThread.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A5071E841C56D079009951BE /* ResourceUsageThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceUsageThread.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceUsageThreadCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageData.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A516E8B4136E04DB0076C3C0 /* LocalizedDateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedDateCache.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A516E8B5136E04DB0076C3C0 /* LocalizedDateCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDateCache.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A518225417E2A0D400A9BA1D /* InspectorOverlayPage.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = InspectorOverlayPage.css; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -17300,6 +17310,7 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */,
</span><ins>+                                A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */,
</ins><span class="cx">                                 A182D5B61BE722620087A7CC /* SettingsCocoa.mm */,
</span><span class="cx">                                 26255F0118878E110006E1FD /* UserAgent.h */,
</span><span class="cx">                                 5D5975B61963637B00D00878 /* UserAgent.mm */,
</span><span class="lines">@@ -17876,8 +17887,12 @@
</span><span class="cx">                                 3772B09516535856000A49CA /* PopupOpeningObserver.h */,
</span><span class="cx">                                 B776D43C1104527500BEB0EC /* PrintContext.cpp */,
</span><span class="cx">                                 B776D43A1104525D00BEB0EC /* PrintContext.h */,
</span><ins>+                                A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */,
+                                A5071E821C56D079009951BE /* ResourceUsageData.h */,
</ins><span class="cx">                                 ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */,
</span><span class="cx">                                 ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */,
</span><ins>+                                A5071E831C56D079009951BE /* ResourceUsageThread.cpp */,
+                                A5071E841C56D079009951BE /* ResourceUsageThread.h */,
</ins><span class="cx">                                 BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */,
</span><span class="cx">                                 BCEC01BB0C274DAC009F4EC9 /* Screen.h */,
</span><span class="cx">                                 BCEC01BC0C274DAC009F4EC9 /* Screen.idl */,
</span><span class="lines">@@ -25947,6 +25962,7 @@
</span><span class="cx">                                 1AB5EBD2194A50F30059AC70 /* HTTPHeaderNames.h in Headers */,
</span><span class="cx">                                 514C76730CE923A1007EF3CD /* HTTPParsers.h in Headers */,
</span><span class="cx">                                 375CD232119D43C800A2A859 /* Hyphenation.h in Headers */,
</span><ins>+                                A5071E871C56D0E1009951BE /* ResourceUsageThread.h in Headers */,
</ins><span class="cx">                                 862F12A018C1DD02005C54AF /* HysteresisActivity.h in Headers */,
</span><span class="cx">                                 B275356E0B053814002CE64F /* Icon.h in Headers */,
</span><span class="cx">                                 97E4029013A696ED00913D67 /* IconController.h in Headers */,
</span><span class="lines">@@ -26618,6 +26634,7 @@
</span><span class="cx">                                 B2FA3E050AB75A6F000E5AC4 /* JSSVGTextElement.h in Headers */,
</span><span class="cx">                                 B22362290C3AF04A0008CA9B /* JSSVGTextPathElement.h in Headers */,
</span><span class="cx">                                 B2FA3E070AB75A6F000E5AC4 /* JSSVGTextPositioningElement.h in Headers */,
</span><ins>+                                A5071E851C56D0DC009951BE /* ResourceUsageData.h in Headers */,
</ins><span class="cx">                                 B2FA3E090AB75A6F000E5AC4 /* JSSVGTitleElement.h in Headers */,
</span><span class="cx">                                 B2FA3E0B0AB75A6F000E5AC4 /* JSSVGTransform.h in Headers */,
</span><span class="cx">                                 B2FA3E0D0AB75A6F000E5AC4 /* JSSVGTransformList.h in Headers */,
</span><span class="lines">@@ -28717,6 +28734,7 @@
</span><span class="cx">                                 7C1E97271A9F9834007BF0FB /* AutoFillButtonElement.cpp in Sources */,
</span><span class="cx">                                 45830D4D1679B4F800ACF8C3 /* AutoscrollController.cpp in Sources */,
</span><span class="cx">                                 A8CFF0500A154F09000A4234 /* AutoTableLayout.cpp in Sources */,
</span><ins>+                                A5071E891C56D4FE009951BE /* ResourceUsageThreadCocoa.mm in Sources */,
</ins><span class="cx">                                 070363E1181A1CDC00C074A5 /* AVAudioCaptureSource.mm in Sources */,
</span><span class="cx">                                 070363E3181A1CDC00C074A5 /* AVCaptureDeviceManager.mm in Sources */,
</span><span class="cx">                                 070363E5181A1CDC00C074A5 /* AVMediaCaptureSource.mm in Sources */,
</span><span class="lines">@@ -29041,6 +29059,7 @@
</span><span class="cx">                                 59A8F1D411A69508001AC34A /* DeviceOrientationController.cpp in Sources */,
</span><span class="cx">                                 59D1C10411EB5DCF00B638C8 /* DeviceOrientationData.cpp in Sources */,
</span><span class="cx">                                 59A85EA2119D68D900DEF1EF /* DeviceOrientationEvent.cpp in Sources */,
</span><ins>+                                A5071E861C56D0DF009951BE /* ResourceUsageThread.cpp in Sources */,
</ins><span class="cx">                                 267725FC1A5B3AD9003C24DD /* DFA.cpp in Sources */,
</span><span class="cx">                                 5C9A7A751AA0F6EA00958ACF /* DFABytecodeCompiler.cpp in Sources */,
</span><span class="cx">                                 5C9A7A761AA0F6ED00958ACF /* DFABytecodeInterpreter.cpp in Sources */,
</span><span class="lines">@@ -31629,6 +31648,7 @@
</span><span class="cx">                                 49C7B9E51042D32F0009D447 /* WebGLTexture.cpp in Sources */,
</span><span class="cx">                                 6F995A231A7078B100A735F4 /* WebGLTransformFeedback.cpp in Sources */,
</span><span class="cx">                                 0C3F1F5A10C8871200D72CE1 /* WebGLUniformLocation.cpp in Sources */,
</span><ins>+                                A5071E8B1C56FB31009951BE /* ResourceUsageData.cpp in Sources */,
</ins><span class="cx">                                 6F995A251A7078B100A735F4 /* WebGLVertexArrayObject.cpp in Sources */,
</span><span class="cx">                                 6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */,
</span><span class="cx">                                 77A17A7712F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/Page.cpp        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -1848,7 +1848,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx"> void Page::setResourceUsageOverlayVisible(bool visible)
</span><span class="cx"> {
</span><span class="cx">     if (!visible) {
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/Page.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -341,7 +341,7 @@
</span><span class="cx">     void dnsPrefetchingStateChanged();
</span><span class="cx">     void storageBlockingStateChanged();
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     void setResourceUsageOverlayVisible(bool);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -656,7 +656,7 @@
</span><span class="cx"> 
</span><span class="cx">     HashSet&lt;ViewStateChangeObserver*&gt; m_viewStateChangeObservers;
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     std::unique_ptr&lt;ResourceUsageOverlay&gt; m_resourceUsageOverlay;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageDatacpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/ResourceUsageData.cpp (0 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageData.cpp                                (rev 0)
+++ trunk/Source/WebCore/page/ResourceUsageData.cpp        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+/*
+ * Copyright (C) 2016 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;ResourceUsageData.h&quot;
+
+#if ENABLE(RESOURCE_USAGE)
+
+namespace WebCore {
+
+ResourceUsageData::ResourceUsageData()
+{
+    // VM tag categories.
+    categories[MemoryCategory::JSJIT] = MemoryCategoryInfo(MemoryCategory::JSJIT);
+    categories[MemoryCategory::Images] = MemoryCategoryInfo(MemoryCategory::Images);
+    categories[MemoryCategory::Layers] = MemoryCategoryInfo(MemoryCategory::Layers);
+    categories[MemoryCategory::LibcMalloc] = MemoryCategoryInfo(MemoryCategory::LibcMalloc);
+    categories[MemoryCategory::bmalloc] = MemoryCategoryInfo(MemoryCategory::bmalloc);
+    categories[MemoryCategory::Other] = MemoryCategoryInfo(MemoryCategory::Other);
+
+    // Sub categories (e.g breakdown of bmalloc tag.)
+    categories[MemoryCategory::GCHeap] = MemoryCategoryInfo(MemoryCategory::GCHeap, true);
+    categories[MemoryCategory::GCOwned] = MemoryCategoryInfo(MemoryCategory::GCOwned, true);
+}
+
+ResourceUsageData::ResourceUsageData(const ResourceUsageData&amp; other)
+    : cpu(other.cpu)
+    , totalDirtySize(other.totalDirtySize)
+    , timeOfNextEdenCollection(other.timeOfNextEdenCollection)
+    , timeOfNextFullCollection(other.timeOfNextFullCollection)
+{
+    std::copy(other.categories.begin(), other.categories.end(), categories.begin());
+}
+
+}
+
+#endif // ENABLE(RESOURCE_USAGE)
</ins></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageDatah"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/ResourceUsageData.h (0 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageData.h                                (rev 0)
+++ trunk/Source/WebCore/page/ResourceUsageData.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef ResourceUsageData_h
+#define ResourceUsageData_h
+
+#if ENABLE(RESOURCE_USAGE)
+
+#include &lt;array&gt;
+
+namespace WebCore {
+
+namespace MemoryCategory {
+static const unsigned bmalloc = 0;
+static const unsigned LibcMalloc = 1;
+static const unsigned JSJIT = 2;
+static const unsigned Images = 3;
+static const unsigned GCHeap = 4;
+static const unsigned GCOwned = 5;
+static const unsigned Other = 6;
+static const unsigned Layers = 7;
+static const unsigned NumberOfCategories = 8;
+}
+
+struct MemoryCategoryInfo {
+    MemoryCategoryInfo() { } // Needed for std::array.
+    MemoryCategoryInfo(unsigned category, bool subcategory = false)
+        : isSubcategory(subcategory)
+        , type(category)
+    {
+    }
+
+    size_t dirtySize { 0 };
+    size_t reclaimableSize { 0 };
+    bool isSubcategory { false };
+    unsigned type { MemoryCategory::NumberOfCategories };
+};
+
+struct ResourceUsageData {
+    ResourceUsageData();
+    ResourceUsageData(const ResourceUsageData&amp; data);
+
+    float cpu { 0 };
+    size_t totalDirtySize { 0 };
+    std::array&lt;MemoryCategoryInfo, MemoryCategory::NumberOfCategories&gt; categories;
+    double timeOfNextEdenCollection { 0 };
+    double timeOfNextFullCollection { 0 };
+};
+
+} // namespace WebCore
+
+#endif // ResourceUsageData_h
+
+#endif // ENABLE(RESOURCE_USAGE)
</ins></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageOverlaycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ResourceUsageOverlay.cpp (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageOverlay.cpp        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/ResourceUsageOverlay.cpp        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;ResourceUsageOverlay.h&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageOverlayh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ResourceUsageOverlay.h (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageOverlay.h        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/ResourceUsageOverlay.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> #ifndef ResourceUsageOverlay_h
</span><span class="cx"> #define ResourceUsageOverlay_h
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;FloatRect.h&quot;
</span><span class="cx"> #include &quot;IntRect.h&quot;
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageThreadcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/ResourceUsageThread.cpp (0 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageThread.cpp                                (rev 0)
+++ trunk/Source/WebCore/page/ResourceUsageThread.cpp        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -0,0 +1,130 @@
</span><ins>+/*
+ * Copyright (C) 2016 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;ResourceUsageThread.h&quot;
+
+#if ENABLE(RESOURCE_USAGE)
+
+#include &quot;JSDOMWindow.h&quot;
+#include &lt;thread&gt;
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+namespace WebCore {
+
+ResourceUsageThread::ResourceUsageThread()
+{
+}
+
+ResourceUsageThread&amp; ResourceUsageThread::singleton()
+{
+    static NeverDestroyed&lt;ResourceUsageThread&gt; resourceUsageThread;
+    return resourceUsageThread;
+}
+
+void ResourceUsageThread::addObserver(void* key, std::function&lt;void (const ResourceUsageData&amp;)&gt; function)
+{
+    auto&amp; resourceUsageThread = ResourceUsageThread::singleton();
+    resourceUsageThread.createThreadIfNeeded();
+
+    {
+        LockHolder locker(resourceUsageThread.m_lock);
+        bool wasEmpty = resourceUsageThread.m_observers.isEmpty();
+        resourceUsageThread.m_observers.set(key, function);
+
+        if (wasEmpty)
+            resourceUsageThread.m_condition.notifyAll();
+    }
+}
+
+void ResourceUsageThread::removeObserver(void* key)
+{
+    auto&amp; resourceUsageThread = ResourceUsageThread::singleton();
+
+    {
+        LockHolder locker(resourceUsageThread.m_lock);
+        resourceUsageThread.m_observers.remove(key);
+    }
+}
+
+void ResourceUsageThread::waitUntilObservers()
+{
+    LockHolder locker(m_lock);
+    while (m_observers.isEmpty())
+        m_condition.wait(m_lock);
+}
+
+void ResourceUsageThread::notifyObservers(ResourceUsageData&amp; data)
+{
+    callOnMainThread([data]() mutable {
+        Vector&lt;std::function&lt;void (const ResourceUsageData&amp;)&gt;&gt; functions;
+        
+        {
+            auto&amp; resourceUsageThread = ResourceUsageThread::singleton();
+            LockHolder locker(resourceUsageThread.m_lock);
+            copyValuesToVector(resourceUsageThread.m_observers, functions);
+        }
+
+        for (auto&amp; function : functions)
+            function(data);
+    });
+}
+
+void ResourceUsageThread::createThreadIfNeeded()
+{
+    if (m_threadIdentifier)
+        return;
+
+    m_vm = &amp;JSDOMWindow::commonVM();
+    m_threadIdentifier = createThread(threadCallback, this, &quot;WebCore: ResourceUsage&quot;);
+}
+
+void ResourceUsageThread::threadCallback(void* resourceUsageThread)
+{
+    static_cast&lt;ResourceUsageThread*&gt;(resourceUsageThread)-&gt;threadBody();
+}
+
+NO_RETURN void ResourceUsageThread::threadBody()
+{
+    while (true) {
+        // Only do work if we have observers.
+        waitUntilObservers();
+
+        auto start = std::chrono::system_clock::now();
+
+        ResourceUsageData data;
+        platformThreadBody(m_vm, data);
+        notifyObservers(data);
+
+        auto duration = std::chrono::duration_cast&lt;std::chrono::milliseconds&gt;(std::chrono::system_clock::now() - start);
+        auto difference = std::chrono::milliseconds(500) - duration;
+        std::this_thread::sleep_for(difference);
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(RESOURCE_USAGE)
</ins></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageThreadh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/ResourceUsageThread.h (0 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageThread.h                                (rev 0)
+++ trunk/Source/WebCore/page/ResourceUsageThread.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -0,0 +1,79 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef ResourceUsageThread_h
+#define ResourceUsageThread_h
+
+#if ENABLE(RESOURCE_USAGE)
+
+#include &quot;ResourceUsageData.h&quot;
+#include &lt;functional&gt;
+#include &lt;wtf/Condition.h&gt;
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/Lock.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+
+namespace JSC {
+class VM;
+}
+
+namespace WebCore {
+
+class ResourceUsageThread {
+    WTF_MAKE_NONCOPYABLE(ResourceUsageThread);
+
+public:
+    static void addObserver(void* key, std::function&lt;void (const ResourceUsageData&amp;)&gt;);
+    static void removeObserver(void* key);
+
+private:
+    friend NeverDestroyed&lt;ResourceUsageThread&gt;;
+    ResourceUsageThread();
+    static ResourceUsageThread&amp; singleton();
+
+    void waitUntilObservers();
+    void notifyObservers(ResourceUsageData&amp;);
+
+    void createThreadIfNeeded();
+    static void threadCallback(void* scrollingThread);
+    void threadBody();
+    void platformThreadBody(JSC::VM*, ResourceUsageData&amp;);
+
+    ThreadIdentifier m_threadIdentifier { 0 };
+    Lock m_lock;
+    Condition m_condition;
+    HashMap&lt;void*, std::function&lt;void (const ResourceUsageData&amp;)&gt;&gt; m_observers;
+
+    // Platforms may need to access some data from the common VM.
+    // They should ensure their use of the VM is thread safe.
+    JSC::VM* m_vm { nullptr };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(RESOURCE_USAGE)
+
+#endif // ResourceUsageThread_h
</ins></span></pre></div>
<a id="trunkSourceWebCorepageSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.cpp (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.cpp        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/Settings.cpp        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -540,7 +540,7 @@
</span><span class="cx">     m_showTiledScrollingIndicator = enabled;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx"> void Settings::setResourceUsageOverlayVisible(bool visible)
</span><span class="cx"> {
</span><span class="cx">     if (m_resourceUsageOverlayVisible == visible)
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.h (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.h        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/Settings.h        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -193,7 +193,7 @@
</span><span class="cx">     WEBCORE_EXPORT void setShowTiledScrollingIndicator(bool);
</span><span class="cx">     bool showTiledScrollingIndicator() const { return m_showTiledScrollingIndicator; }
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     bool resourceUsageOverlayVisible() const { return m_resourceUsageOverlayVisible; }
</span><span class="cx">     WEBCORE_EXPORT void setResourceUsageOverlayVisible(bool);
</span><span class="cx"> #endif
</span><span class="lines">@@ -352,7 +352,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool m_forcePendingWebGLPolicy : 1;
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     bool m_resourceUsageOverlayVisible { false };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepagecocoaResourceUsageOverlayCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -26,21 +26,14 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ResourceUsageOverlay.h&quot;
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;JSDOMWindow.h&quot;
</span><del>-#include &quot;MachVMSPI.h&quot;
</del><span class="cx"> #include &quot;PlatformCALayer.h&quot;
</span><ins>+#include &quot;ResourceUsageThread.h&quot;
</ins><span class="cx"> #include &lt;CoreGraphics/CGContext.h&gt;
</span><del>-#include &lt;JavaScriptCore/GCActivityCallback.h&gt;
</del><span class="cx"> #include &lt;QuartzCore/CALayer.h&gt;
</span><span class="cx"> #include &lt;QuartzCore/CATransaction.h&gt;
</span><del>-#include &lt;array&gt;
-#include &lt;mach/mach.h&gt;
-#include &lt;mach/vm_statistics.h&gt;
-#include &lt;runtime/JSLock.h&gt;
-#include &lt;sys/sysctl.h&gt;
-#include &lt;thread&gt;
</del><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -71,19 +64,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static size_t vmPageSize()
-{
-    static size_t pageSize;
-    static std::once_flag onceFlag;
-    std::call_once(onceFlag, [&amp;] {
-        size_t outputSize = sizeof(pageSize);
-        int status = sysctlbyname(&quot;vm.pagesize&quot;, &amp;pageSize, &amp;outputSize, nullptr, 0);
-        ASSERT_UNUSED(status, status != -1);
-        ASSERT(pageSize);
-    });
-    return pageSize;
-}
-
</del><span class="cx"> template&lt;typename T, size_t size = 70&gt;
</span><span class="cx"> class RingBuffer {
</span><span class="cx"> public:
</span><span class="lines">@@ -133,18 +113,6 @@
</span><span class="cx">     unsigned m_current { 0 };
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-namespace MemoryCategory {
-static const unsigned bmalloc = 0;
-static const unsigned LibcMalloc = 1;
-static const unsigned JSJIT = 2;
-static const unsigned Images = 3;
-static const unsigned GCHeap = 4;
-static const unsigned GCOwned = 5;
-static const unsigned Other = 6;
-static const unsigned Layers = 7;
-static const unsigned NumberOfCategories = 8;
-}
-
</del><span class="cx"> static CGColorRef createColor(float r, float g, float b, float a)
</span><span class="cx"> {
</span><span class="cx">     static CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
</span><span class="lines">@@ -152,10 +120,10 @@
</span><span class="cx">     return CGColorCreate(colorSpace, components);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-struct MemoryCategoryInfo {
-    MemoryCategoryInfo() { } // Needed for std::array.
</del><ins>+struct HistoricMemoryCategoryInfo {
+    HistoricMemoryCategoryInfo() { } // Needed for std::array.
</ins><span class="cx"> 
</span><del>-    MemoryCategoryInfo(unsigned category, RGBA32 rgba, String name, bool subcategory = false)
</del><ins>+    HistoricMemoryCategoryInfo(unsigned category, RGBA32 rgba, String name, bool subcategory = false)
</ins><span class="cx">         : name(WTFMove(name))
</span><span class="cx">         , isSubcategory(subcategory)
</span><span class="cx">         , type(category)
</span><span class="lines">@@ -167,65 +135,76 @@
</span><span class="cx"> 
</span><span class="cx">     String name;
</span><span class="cx">     RetainPtr&lt;CGColorRef&gt; color;
</span><del>-    RingBuffer&lt;size_t&gt; history;
-    RingBuffer&lt;size_t&gt; reclaimableHistory;
</del><ins>+    RingBuffer&lt;size_t&gt; dirtySize;
+    RingBuffer&lt;size_t&gt; reclaimableSize;
</ins><span class="cx">     bool isSubcategory { false };
</span><span class="cx">     unsigned type { MemoryCategory::NumberOfCategories };
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-struct ResourceUsageData {
-    ResourceUsageData();
</del><ins>+struct HistoricResourceUsageData {
+    HistoricResourceUsageData();
</ins><span class="cx"> 
</span><del>-    Lock lock;
-
-    RingBuffer&lt;size_t&gt; totalDirty;
-    std::array&lt;MemoryCategoryInfo, MemoryCategory::NumberOfCategories&gt; categories;
-
-    RingBuffer&lt;float&gt; cpuHistory;
-    RingBuffer&lt;size_t&gt; gcHeapSizeHistory;
-
-    HashSet&lt;CALayer *&gt; overlayLayers;
-    JSC::VM* vm { nullptr };
-
</del><ins>+    RingBuffer&lt;float&gt; cpu;
+    RingBuffer&lt;size_t&gt; totalDirtySize;
+    RingBuffer&lt;size_t&gt; gcHeapSize;
+    std::array&lt;HistoricMemoryCategoryInfo, MemoryCategory::NumberOfCategories&gt; categories;
</ins><span class="cx">     double timeOfNextEdenCollection { 0 };
</span><span class="cx">     double timeOfNextFullCollection { 0 };
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-ResourceUsageData::ResourceUsageData()
</del><ins>+HistoricResourceUsageData::HistoricResourceUsageData()
</ins><span class="cx"> {
</span><span class="cx">     // VM tag categories.
</span><del>-    categories[MemoryCategory::JSJIT] = MemoryCategoryInfo(MemoryCategory::JSJIT, 0xFFFF60FF, &quot;JS JIT&quot;);
-    categories[MemoryCategory::Images] = MemoryCategoryInfo(MemoryCategory::Images, 0xFFFFFF00, &quot;Images&quot;);
-    categories[MemoryCategory::Layers] = MemoryCategoryInfo(MemoryCategory::Layers, 0xFF00FFFF, &quot;Layers&quot;);
-    categories[MemoryCategory::LibcMalloc] = MemoryCategoryInfo(MemoryCategory::LibcMalloc, 0xFF00FF00, &quot;libc malloc&quot;);
-    categories[MemoryCategory::bmalloc] = MemoryCategoryInfo(MemoryCategory::bmalloc, 0xFFFF6060, &quot;bmalloc&quot;);
-    categories[MemoryCategory::Other] = MemoryCategoryInfo(MemoryCategory::Other, 0xFFC0FF00, &quot;Other&quot;);
</del><ins>+    categories[MemoryCategory::JSJIT] = HistoricMemoryCategoryInfo(MemoryCategory::JSJIT, 0xFFFF60FF, &quot;JS JIT&quot;);
+    categories[MemoryCategory::Images] = HistoricMemoryCategoryInfo(MemoryCategory::Images, 0xFFFFFF00, &quot;Images&quot;);
+    categories[MemoryCategory::Layers] = HistoricMemoryCategoryInfo(MemoryCategory::Layers, 0xFF00FFFF, &quot;Layers&quot;);
+    categories[MemoryCategory::LibcMalloc] = HistoricMemoryCategoryInfo(MemoryCategory::LibcMalloc, 0xFF00FF00, &quot;libc malloc&quot;);
+    categories[MemoryCategory::bmalloc] = HistoricMemoryCategoryInfo(MemoryCategory::bmalloc, 0xFFFF6060, &quot;bmalloc&quot;);
+    categories[MemoryCategory::Other] = HistoricMemoryCategoryInfo(MemoryCategory::Other, 0xFFC0FF00, &quot;Other&quot;);
</ins><span class="cx"> 
</span><span class="cx">     // Sub categories (e.g breakdown of bmalloc tag.)
</span><del>-    categories[MemoryCategory::GCHeap] = MemoryCategoryInfo(MemoryCategory::GCHeap, 0xFFA0A0FF, &quot;GC heap&quot;, true);
-    categories[MemoryCategory::GCOwned] = MemoryCategoryInfo(MemoryCategory::GCOwned, 0xFFFFC060, &quot;GC owned&quot;, true);
</del><ins>+    categories[MemoryCategory::GCHeap] = HistoricMemoryCategoryInfo(MemoryCategory::GCHeap, 0xFFA0A0FF, &quot;GC heap&quot;, true);
+    categories[MemoryCategory::GCOwned] = HistoricMemoryCategoryInfo(MemoryCategory::GCOwned, 0xFFFFC060, &quot;GC owned&quot;, true);
+
+#ifndef NDEBUG
+    // Ensure this aligns with ResourceUsageData's category order.
+    ResourceUsageData d;
+    ASSERT(categories.size() == d.categories.size());
+    for (size_t i = 0; i &lt; categories.size(); ++i)
+        ASSERT(categories[i].type == d.categories[i].type);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static ResourceUsageData&amp; sharedData()
</del><ins>+static HistoricResourceUsageData&amp; historicUsageData()
</ins><span class="cx"> {
</span><del>-    static NeverDestroyed&lt;ResourceUsageData&gt; data;
</del><ins>+    static NeverDestroyed&lt;HistoricResourceUsageData&gt; data;
</ins><span class="cx">     return data;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void runSamplerThread(void*);
-
-void ResourceUsageOverlay::platformInitialize()
</del><ins>+static void appendDataToHistory(const ResourceUsageData&amp; data)
</ins><span class="cx"> {
</span><del>-    auto&amp; data = sharedData();
-    LockHolder locker(data.lock);
</del><ins>+    ASSERT(isMainThread());
</ins><span class="cx"> 
</span><del>-    // FIXME: The sampler thread will never stop once started.
-    static std::once_flag onceFlag;
-    std::call_once(onceFlag, [&amp;] {
-        data.vm = &amp;JSDOMWindow::commonVM();
-        createThread(runSamplerThread, nullptr, &quot;ResourceUsageOverlay Sampler&quot;);
-    });
</del><ins>+    auto&amp; historicData = historicUsageData();
+    historicData.cpu.append(data.cpu);
+    historicData.totalDirtySize.append(data.totalDirtySize);
+    for (auto&amp; category : historicData.categories) {
+        category.dirtySize.append(data.categories[category.type].dirtySize);
+        category.reclaimableSize.append(data.categories[category.type].reclaimableSize);
+    }
+    historicData.timeOfNextEdenCollection = data.timeOfNextEdenCollection;
+    historicData.timeOfNextFullCollection = data.timeOfNextFullCollection;
</ins><span class="cx"> 
</span><ins>+    // FIXME: Find a way to add this to ResourceUsageData and calculate it on the resource usage sampler thread.
+    {
+        JSC::VM* vm = &amp;JSDOMWindow::commonVM();
+        JSC::JSLockHolder lock(vm);
+        historicData.gcHeapSize.append(vm-&gt;heap.size() - vm-&gt;heap.extraMemorySize());
+    }
+}
+
+void ResourceUsageOverlay::platformInitialize()
+{
</ins><span class="cx">     m_layer = adoptNS([[WebOverlayLayer alloc] initWithResourceUsageOverlay:this]);
</span><span class="cx"> 
</span><span class="cx">     m_containerLayer = adoptNS([[CALayer alloc] init]);
</span><span class="lines">@@ -241,14 +220,24 @@
</span><span class="cx"> 
</span><span class="cx">     overlay().layer().setContentsToPlatformLayer(m_layer.get(), GraphicsLayer::NoContentsLayer);
</span><span class="cx"> 
</span><del>-    data.overlayLayers.add(m_layer.get());
</del><ins>+    ResourceUsageThread::addObserver(this, [this] (const ResourceUsageData&amp; data) {
+        appendDataToHistory(data);
+
+        // FIXME: It shouldn't be necessary to update the bounds on every single thread loop iteration,
+        // but something is causing them to become 0x0.
+        [CATransaction begin];
+        CALayer *containerLayer = [m_layer superlayer];
+        CGRect rect = CGRectMake(0, 0, ResourceUsageOverlay::normalWidth, ResourceUsageOverlay::normalHeight);
+        [m_layer setBounds:rect];
+        [containerLayer setBounds:rect];
+        [m_layer setNeedsDisplay];
+        [CATransaction commit];
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceUsageOverlay::platformDestroy()
</span><span class="cx"> {
</span><del>-    auto&amp; data = sharedData();
-    LockHolder locker(data.lock);
-    data.overlayLayers.remove(m_layer.get());
</del><ins>+    ResourceUsageThread::removeObserver(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void showText(CGContextRef context, float x, float y, CGColorRef color, const String&amp; text)
</span><span class="lines">@@ -351,12 +340,12 @@
</span><span class="cx">     drawGraphLabel(context, x1, y2, &quot;GC&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void drawMemHistory(CGContextRef context, float x1, float y1, float y2, ResourceUsageData&amp; data)
</del><ins>+static void drawMemHistory(CGContextRef context, float x1, float y1, float y2, HistoricResourceUsageData&amp; data)
</ins><span class="cx"> {
</span><span class="cx">     float yScale = y2 - y1;
</span><span class="cx"> 
</span><span class="cx">     size_t peak = 0;
</span><del>-    data.totalDirty.forEach([&amp;](size_t m) {
</del><ins>+    data.totalDirtySize.forEach([&amp;](size_t m) {
</ins><span class="cx">         if (m &gt; peak)
</span><span class="cx">             peak = m;
</span><span class="cx">     });
</span><span class="lines">@@ -372,7 +361,7 @@
</span><span class="cx"> 
</span><span class="cx">     for (auto&amp; category : data.categories) {
</span><span class="cx">         unsigned x = 0;
</span><del>-        category.history.forEach([&amp;](size_t m) {
</del><ins>+        category.dirtySize.forEach([&amp;](size_t m) {
</ins><span class="cx">             columns[x][category.type] = { category.color.get(), m };
</span><span class="cx">             ++x;
</span><span class="cx">         });
</span><span class="lines">@@ -411,15 +400,15 @@
</span><span class="cx">     angle += part * fullCircleInRadians;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void drawMemoryPie(CGContextRef context, FloatRect&amp; rect, ResourceUsageData&amp; data)
</del><ins>+static void drawMemoryPie(CGContextRef context, FloatRect&amp; rect, HistoricResourceUsageData&amp; data)
</ins><span class="cx"> {
</span><span class="cx">     float radius = rect.width() / 2;
</span><span class="cx">     FloatPoint center = rect.center();
</span><del>-    size_t totalDirty = data.totalDirty.last();
</del><ins>+    size_t totalDirty = data.totalDirtySize.last();
</ins><span class="cx"> 
</span><span class="cx">     float angle = 0;
</span><span class="cx">     for (auto&amp; category : data.categories)
</span><del>-        drawSlice(context, center, angle, radius, category.history.last(), totalDirty, category.color.get());
</del><ins>+        drawSlice(context, center, angle, radius, category.dirtySize.last(), totalDirty, category.color.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static String formatByteNumber(size_t number)
</span><span class="lines">@@ -442,8 +431,7 @@
</span><span class="cx"> 
</span><span class="cx"> void ResourceUsageOverlay::platformDraw(CGContextRef context)
</span><span class="cx"> {
</span><del>-    auto&amp; data = sharedData();
-    LockHolder locker(data.lock);
</del><ins>+    auto&amp; data = historicUsageData();
</ins><span class="cx"> 
</span><span class="cx">     if (![m_layer.get() contentsAreFlipped]) {
</span><span class="cx">         CGContextScaleCTM(context, 1, -1);
</span><span class="lines">@@ -457,13 +445,13 @@
</span><span class="cx">     CGContextClearRect(context, viewBounds);
</span><span class="cx"> 
</span><span class="cx">     static CGColorRef colorForLabels = createColor(0.9, 0.9, 0.9, 1);
</span><del>-    showText(context, 10, 20, colorForLabels, String::format(&quot;        CPU: %g&quot;, data.cpuHistory.last()));
-    showText(context, 10, 30, colorForLabels, &quot;  Footprint: &quot; + formatByteNumber(data.totalDirty.last()));
</del><ins>+    showText(context, 10, 20, colorForLabels, String::format(&quot;        CPU: %g&quot;, data.cpu.last()));
+    showText(context, 10, 30, colorForLabels, &quot;  Footprint: &quot; + formatByteNumber(data.totalDirtySize.last()));
</ins><span class="cx"> 
</span><span class="cx">     float y = 50;
</span><span class="cx">     for (auto&amp; category : data.categories) {
</span><del>-        String label = String::format(&quot;% 11s: %s&quot;, category.name.ascii().data(), formatByteNumber(category.history.last()).ascii().data());
-        size_t reclaimable = category.reclaimableHistory.last();
</del><ins>+        String label = String::format(&quot;% 11s: %s&quot;, category.name.ascii().data(), formatByteNumber(category.dirtySize.last()).ascii().data());
+        size_t reclaimable = category.reclaimableSize.last();
</ins><span class="cx">         if (reclaimable)
</span><span class="cx">             label = label + String::format(&quot; [%s]&quot;, formatByteNumber(reclaimable).ascii().data());
</span><span class="cx"> 
</span><span class="lines">@@ -476,185 +464,14 @@
</span><span class="cx">     showText(context, 10, y + 10, colorForLabels, String::format(&quot;    Eden GC: %s&quot;, gcTimerString(data.timeOfNextEdenCollection, now).ascii().data()));
</span><span class="cx">     showText(context, 10, y + 20, colorForLabels, String::format(&quot;    Full GC: %s&quot;, gcTimerString(data.timeOfNextFullCollection, now).ascii().data()));
</span><span class="cx"> 
</span><del>-    drawCpuHistory(context, viewBounds.size.width - 70, 0, viewBounds.size.height, data.cpuHistory);
-    drawGCHistory(context, viewBounds.size.width - 140, 0, viewBounds.size.height, data.gcHeapSizeHistory, data.categories[MemoryCategory::GCHeap].history);
</del><ins>+    drawCpuHistory(context, viewBounds.size.width - 70, 0, viewBounds.size.height, data.cpu);
+    drawGCHistory(context, viewBounds.size.width - 140, 0, viewBounds.size.height, data.gcHeapSize, data.categories[MemoryCategory::GCHeap].dirtySize);
</ins><span class="cx">     drawMemHistory(context, viewBounds.size.width - 210, 0, viewBounds.size.height, data);
</span><span class="cx"> 
</span><span class="cx">     FloatRect pieRect(viewBounds.size.width - 330, 0, 100, viewBounds.size.height);
</span><span class="cx">     drawMemoryPie(context, pieRect, data);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-struct TagInfo {
-    TagInfo() { }
-    size_t dirty { 0 };
-    size_t reclaimable { 0 };
-};
-
-static std::array&lt;TagInfo, 256&gt; pagesPerVMTag()
-{
-    std::array&lt;TagInfo, 256&gt; tags;
-    task_t task = mach_task_self();
-    mach_vm_size_t size;
-    uint32_t depth = 0;
-    struct vm_region_submap_info_64 info = { };
-    mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
-    for (mach_vm_address_t addr = 0; ; addr += size) {
-        int purgeableState;
-        if (mach_vm_purgable_control(task, addr, VM_PURGABLE_GET_STATE, &amp;purgeableState) != KERN_SUCCESS)
-            purgeableState = VM_PURGABLE_DENY;
-
-        kern_return_t kr = mach_vm_region_recurse(task, &amp;addr, &amp;size, &amp;depth, (vm_region_info_t)&amp;info, &amp;count);
-        if (kr != KERN_SUCCESS)
-            break;
-
-        if (purgeableState == VM_PURGABLE_VOLATILE) {
-            tags[info.user_tag].reclaimable += info.pages_resident;
-            continue;
-        }
-
-        if (purgeableState == VM_PURGABLE_EMPTY) {
-            tags[info.user_tag].reclaimable += size / vmPageSize();
-            continue;
-        }
-
-        bool anonymous = !info.external_pager;
-        if (anonymous) {
-            tags[info.user_tag].dirty += info.pages_resident - info.pages_reusable;
-            tags[info.user_tag].reclaimable += info.pages_reusable;
-        } else
-            tags[info.user_tag].dirty += info.pages_dirtied;
-    }
-
-    return tags;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-static float cpuUsage()
-{
-    thread_array_t threadList;
-    mach_msg_type_number_t threadCount;
-    kern_return_t kr = task_threads(mach_task_self(), &amp;threadList, &amp;threadCount);
-    if (kr != KERN_SUCCESS)
-        return -1;
-
-    float usage = 0;
-
-    for (mach_msg_type_number_t i = 0; i &lt; threadCount; ++i) {
-        thread_info_data_t threadInfo;
-        thread_basic_info_t threadBasicInfo;
-
-        mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;
-        kr = thread_info(threadList[i], THREAD_BASIC_INFO, static_cast&lt;thread_info_t&gt;(threadInfo), &amp;threadInfoCount);
-        if (kr != KERN_SUCCESS)
-            return -1;
-
-        threadBasicInfo = reinterpret_cast&lt;thread_basic_info_t&gt;(threadInfo);
-
-        if (!(threadBasicInfo-&gt;flags &amp; TH_FLAGS_IDLE))
-            usage += threadBasicInfo-&gt;cpu_usage / static_cast&lt;float&gt;(TH_USAGE_SCALE) * 100.0;
-    }
-
-    kr = vm_deallocate(mach_task_self(), (vm_offset_t)threadList, threadCount * sizeof(thread_t));
-    ASSERT(kr == KERN_SUCCESS);
-
-    return usage;
-}
-
-static unsigned categoryForVMTag(unsigned tag)
-{
-    switch (tag) {
-    case VM_MEMORY_IOKIT:
-    case VM_MEMORY_LAYERKIT:
-        return MemoryCategory::Layers;
-    case VM_MEMORY_IMAGEIO:
-    case VM_MEMORY_CGIMAGE:
-        return MemoryCategory::Images;
-    case VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR:
-        return MemoryCategory::JSJIT;
-    case VM_MEMORY_MALLOC:
-    case VM_MEMORY_MALLOC_HUGE:
-    case VM_MEMORY_MALLOC_LARGE:
-    case VM_MEMORY_MALLOC_SMALL:
-    case VM_MEMORY_MALLOC_TINY:
-    case VM_MEMORY_MALLOC_NANO:
-        return MemoryCategory::LibcMalloc;
-    case VM_MEMORY_TCMALLOC:
-        return MemoryCategory::bmalloc;
-    default:
-        return MemoryCategory::Other;
-    }
-};
-
-NO_RETURN void runSamplerThread(void*)
-{
-    auto&amp; data = sharedData();
-    while (1) {
-        float cpu = cpuUsage();
-        auto tags = pagesPerVMTag();
-        Vector&lt;CALayer *, 8&gt; layers;
-
-        {
-            LockHolder locker(data.lock);
-            data.cpuHistory.append(cpu);
-
-            std::array&lt;TagInfo, MemoryCategory::NumberOfCategories&gt; pagesPerCategory;
-
-            size_t totalDirtyPages = 0;
-            for (unsigned i = 0; i &lt; 256; ++i) {
-                pagesPerCategory[categoryForVMTag(i)].dirty += tags[i].dirty;
-                pagesPerCategory[categoryForVMTag(i)].reclaimable += tags[i].reclaimable;
-                totalDirtyPages += tags[i].dirty;
-            }
-
-            for (auto&amp; category : data.categories) {
-                if (category.isSubcategory) // Only do automatic tallying for top-level categories.
-                    continue;
-                category.history.append(pagesPerCategory[category.type].dirty * vmPageSize());
-                category.reclaimableHistory.append(pagesPerCategory[category.type].reclaimable * vmPageSize());
-            }
-            data.totalDirty.append(totalDirtyPages * vmPageSize());
-
-            copyToVector(data.overlayLayers, layers);
-
-            size_t currentGCHeapCapacity = data.vm-&gt;heap.blockBytesAllocated();
-            size_t currentGCOwned = data.vm-&gt;heap.extraMemorySize();
-
-            data.categories[MemoryCategory::GCHeap].history.append(currentGCHeapCapacity);
-            data.categories[MemoryCategory::GCOwned].history.append(currentGCOwned);
-
-            // Subtract known subchunks from the bmalloc bucket.
-            // FIXME: Handle running with bmalloc disabled.
-            data.categories[MemoryCategory::bmalloc].history.last() -= currentGCHeapCapacity + currentGCOwned;
-
-            data.timeOfNextEdenCollection = data.vm-&gt;heap.edenActivityCallback()-&gt;nextFireTime();
-            data.timeOfNextFullCollection = data.vm-&gt;heap.fullActivityCallback()-&gt;nextFireTime();
-        }
-
-        [CATransaction begin];
-        for (CALayer *layer : layers) {
-            // FIXME: It shouldn't be necessary to update the bounds on every single thread loop iteration,
-            // but something is causing them to become 0x0.
-            CALayer *containerLayer = [layer superlayer];
-            CGRect rect = CGRectMake(0, 0, ResourceUsageOverlay::normalWidth, ResourceUsageOverlay::normalHeight);
-            [layer setBounds:rect];
-            [containerLayer setBounds:rect];
-            [layer setNeedsDisplay];
-        }
-        [CATransaction commit];
-
-        // FIXME: Find a way to get the size of the current GC heap size safely from the sampler thread.
-        callOnMainThread([] {
-            auto&amp; data = sharedData();
-            JSC::JSLockHolder lock(data.vm);
-            size_t gcHeapSize = data.vm-&gt;heap.size() - data.vm-&gt;heap.extraMemorySize();
-
-            LockHolder locker(data.lock);
-            data.gcHeapSizeHistory.append(gcHeapSize);
-        });
-
-        std::this_thread::sleep_for(std::chrono::milliseconds(500));
-    }
-}
-
-}
-
-#endif
</del><ins>+#endif // ENABLE(RESOURCE_USAGE)
</ins></span></pre></div>
<a id="trunkSourceWebCorepagecocoaResourceUsageThreadCocoamm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm (0 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm                                (rev 0)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -0,0 +1,191 @@
</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. 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;ResourceUsageThread.h&quot;
+
+#if ENABLE(RESOURCE_USAGE)
+
+#include &quot;MachVMSPI.h&quot;
+#include &lt;JavaScriptCore/GCActivityCallback.h&gt;
+#include &lt;heap/Heap.h&gt;
+#include &lt;mach/mach.h&gt;
+#include &lt;mach/vm_statistics.h&gt;
+#include &lt;runtime/VM.h&gt;
+#include &lt;sys/sysctl.h&gt;
+
+namespace WebCore {
+
+static size_t vmPageSize()
+{
+    static size_t pageSize;
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [&amp;] {
+        size_t outputSize = sizeof(pageSize);
+        int status = sysctlbyname(&quot;vm.pagesize&quot;, &amp;pageSize, &amp;outputSize, nullptr, 0);
+        ASSERT_UNUSED(status, status != -1);
+        ASSERT(pageSize);
+    });
+    return pageSize;
+}
+
+struct TagInfo {
+    TagInfo() { }
+    size_t dirty { 0 };
+    size_t reclaimable { 0 };
+};
+
+static std::array&lt;TagInfo, 256&gt; pagesPerVMTag()
+{
+    std::array&lt;TagInfo, 256&gt; tags;
+    task_t task = mach_task_self();
+    mach_vm_size_t size;
+    uint32_t depth = 0;
+    struct vm_region_submap_info_64 info = { };
+    mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
+    for (mach_vm_address_t addr = 0; ; addr += size) {
+        int purgeableState;
+        if (mach_vm_purgable_control(task, addr, VM_PURGABLE_GET_STATE, &amp;purgeableState) != KERN_SUCCESS)
+            purgeableState = VM_PURGABLE_DENY;
+
+        kern_return_t kr = mach_vm_region_recurse(task, &amp;addr, &amp;size, &amp;depth, (vm_region_info_t)&amp;info, &amp;count);
+        if (kr != KERN_SUCCESS)
+            break;
+
+        if (purgeableState == VM_PURGABLE_VOLATILE) {
+            tags[info.user_tag].reclaimable += info.pages_resident;
+            continue;
+        }
+
+        if (purgeableState == VM_PURGABLE_EMPTY) {
+            tags[info.user_tag].reclaimable += size / vmPageSize();
+            continue;
+        }
+
+        bool anonymous = !info.external_pager;
+        if (anonymous) {
+            tags[info.user_tag].dirty += info.pages_resident - info.pages_reusable;
+            tags[info.user_tag].reclaimable += info.pages_reusable;
+        } else
+            tags[info.user_tag].dirty += info.pages_dirtied;
+    }
+
+    return tags;
+}
+
+static float cpuUsage()
+{
+    thread_array_t threadList;
+    mach_msg_type_number_t threadCount;
+    kern_return_t kr = task_threads(mach_task_self(), &amp;threadList, &amp;threadCount);
+    if (kr != KERN_SUCCESS)
+        return -1;
+
+    float usage = 0;
+
+    for (mach_msg_type_number_t i = 0; i &lt; threadCount; ++i) {
+        thread_info_data_t threadInfo;
+        thread_basic_info_t threadBasicInfo;
+
+        mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;
+        kr = thread_info(threadList[i], THREAD_BASIC_INFO, static_cast&lt;thread_info_t&gt;(threadInfo), &amp;threadInfoCount);
+        if (kr != KERN_SUCCESS)
+            return -1;
+
+        threadBasicInfo = reinterpret_cast&lt;thread_basic_info_t&gt;(threadInfo);
+
+        if (!(threadBasicInfo-&gt;flags &amp; TH_FLAGS_IDLE))
+            usage += threadBasicInfo-&gt;cpu_usage / static_cast&lt;float&gt;(TH_USAGE_SCALE) * 100.0;
+    }
+
+    kr = vm_deallocate(mach_task_self(), (vm_offset_t)threadList, threadCount * sizeof(thread_t));
+    ASSERT(kr == KERN_SUCCESS);
+
+    return usage;
+}
+
+static unsigned categoryForVMTag(unsigned tag)
+{
+    switch (tag) {
+    case VM_MEMORY_IOKIT:
+    case VM_MEMORY_LAYERKIT:
+        return MemoryCategory::Layers;
+    case VM_MEMORY_IMAGEIO:
+    case VM_MEMORY_CGIMAGE:
+        return MemoryCategory::Images;
+    case VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR:
+        return MemoryCategory::JSJIT;
+    case VM_MEMORY_MALLOC:
+    case VM_MEMORY_MALLOC_HUGE:
+    case VM_MEMORY_MALLOC_LARGE:
+    case VM_MEMORY_MALLOC_SMALL:
+    case VM_MEMORY_MALLOC_TINY:
+    case VM_MEMORY_MALLOC_NANO:
+        return MemoryCategory::LibcMalloc;
+    case VM_MEMORY_TCMALLOC:
+        return MemoryCategory::bmalloc;
+    default:
+        return MemoryCategory::Other;
+    }
+};
+
+void ResourceUsageThread::platformThreadBody(JSC::VM* vm, ResourceUsageData&amp; data)
+{
+    data.cpu = cpuUsage();
+
+    auto tags = pagesPerVMTag();
+    std::array&lt;TagInfo, MemoryCategory::NumberOfCategories&gt; pagesPerCategory;
+    size_t totalDirtyPages = 0;
+    for (unsigned i = 0; i &lt; 256; ++i) {
+        pagesPerCategory[categoryForVMTag(i)].dirty += tags[i].dirty;
+        pagesPerCategory[categoryForVMTag(i)].reclaimable += tags[i].reclaimable;
+        totalDirtyPages += tags[i].dirty;
+    }
+
+    for (auto&amp; category : data.categories) {
+        if (category.isSubcategory) // Only do automatic tallying for top-level categories.
+            continue;
+        category.dirtySize = pagesPerCategory[category.type].dirty * vmPageSize();
+        category.reclaimableSize = pagesPerCategory[category.type].reclaimable * vmPageSize();
+    }
+    data.totalDirtySize = totalDirtyPages * vmPageSize();
+
+    size_t currentGCHeapCapacity = vm-&gt;heap.blockBytesAllocated();
+    size_t currentGCOwned = vm-&gt;heap.extraMemorySize();
+
+    data.categories[MemoryCategory::GCHeap].dirtySize = currentGCHeapCapacity;
+    data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwned;
+
+    // Subtract known subchunks from the bmalloc bucket.
+    // FIXME: Handle running with bmalloc disabled.
+    data.categories[MemoryCategory::bmalloc].dirtySize -= currentGCHeapCapacity + currentGCOwned;
+
+    data.timeOfNextEdenCollection = vm-&gt;heap.edenActivityCallback()-&gt;nextFireTime();
+    data.timeOfNextFullCollection = vm-&gt;heap.fullActivityCallback()-&gt;nextFireTime();
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCorepagescrollingScrollingThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     scrollingThread.createThreadIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     {
</span><del>-        std::lock_guard&lt;Lock&gt; lock(singleton().m_functionsMutex);
</del><ins>+        std::lock_guard&lt;Lock&gt; lock(scrollingThread.m_functionsMutex);
</ins><span class="cx">         scrollingThread.m_functions.append(function);
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebKit2/ChangeLog        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-01-26  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Generalize ResourceUsageData gathering to be used outside of ResourceUsageOverlay
+        https://bugs.webkit.org/show_bug.cgi?id=153509
+        &lt;rdar://problem/24354291&gt;
+
+        Reviewed by Andreas Kling.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        Rename the ENABLE flag.
+
</ins><span class="cx"> 2016-01-26  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r195602.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (195643 => 195644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-01-27 01:22:44 UTC (rev 195643)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-01-27 01:29:25 UTC (rev 195644)
</span><span class="lines">@@ -2849,7 +2849,7 @@
</span><span class="cx">     settings.setAllowsAirPlayForMediaPlayback(store.getBoolValueForKey(WebPreferencesKey::allowsAirPlayForMediaPlaybackKey()));
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE_OVERLAY)
</del><ins>+#if ENABLE(RESOURCE_USAGE)
</ins><span class="cx">     settings.setResourceUsageOverlayVisible(store.getBoolValueForKey(WebPreferencesKey::resourceUsageOverlayVisibleKey()));
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>