| Index: Source/core/timing/MemoryInfo.cpp
|
| diff --git a/Source/core/timing/MemoryInfo.cpp b/Source/core/timing/MemoryInfo.cpp
|
| index 3bb082123a1f4f7f7c7dcc44c19857dca484d686..fd421cbe3bfc78f9257b5f2d4ce5cbaa42369546 100644
|
| --- a/Source/core/timing/MemoryInfo.cpp
|
| +++ b/Source/core/timing/MemoryInfo.cpp
|
| @@ -32,8 +32,10 @@
|
| #include "core/timing/MemoryInfo.h"
|
|
|
| #include <limits>
|
| +#include "core/dom/Document.h"
|
| #include "core/frame/Frame.h"
|
| #include "core/frame/Settings.h"
|
| +#include "core/workers/WorkerGlobalScope.h"
|
| #include "wtf/CurrentTime.h"
|
| #include "wtf/MainThread.h"
|
| #include "wtf/MathExtras.h"
|
| @@ -132,13 +134,31 @@ size_t quantizeMemorySize(size_t size)
|
| }
|
|
|
|
|
| -MemoryInfo::MemoryInfo(Frame* frame)
|
| +MemoryInfo::MemoryInfo(ExecutionContext* context)
|
| {
|
| ScriptWrappable::init(this);
|
| - if (!frame || !frame->settings())
|
| +
|
| + if (!context)
|
| return;
|
|
|
| - if (frame->settings()->memoryInfoEnabled()) {
|
| + if (context->isDocument()) {
|
| + Frame* frame = toDocument(context)->frame();
|
| + if (!frame || !frame->settings())
|
| + return;
|
| + loadMemoryInfo(frame->settings()->memoryInfoEnabled());
|
| + }
|
| +
|
| + if (context->isWorkerGlobalScope()) {
|
| + WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
|
| + if (!workerGlobalScope)
|
| + return;
|
| + loadMemoryInfo(workerGlobalScope->memoryInfoEnabled());
|
| + }
|
| +}
|
| +
|
| +void MemoryInfo::loadMemoryInfo(bool memoryInfoEnabled)
|
| +{
|
| + if (memoryInfoEnabled) {
|
| ScriptGCEvent::getHeapSize(m_info);
|
| } else {
|
| DEFINE_STATIC_LOCAL(HeapSizeCache, heapSizeCache, ());
|
|
|