| Index: Source/core/timing/MemoryInfo.cpp
|
| diff --git a/Source/core/timing/MemoryInfo.cpp b/Source/core/timing/MemoryInfo.cpp
|
| index 2abe63ab6f5f39fff6ca9d32721ad106fb2f9cb3..c67e7c629ceaaf5bc79334f332738c4d8cc2216c 100644
|
| --- a/Source/core/timing/MemoryInfo.cpp
|
| +++ b/Source/core/timing/MemoryInfo.cpp
|
| @@ -31,12 +31,14 @@
|
| #include "config.h"
|
| #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"
|
| +#include <limits>
|
|
|
| namespace WebCore {
|
|
|
| @@ -133,13 +135,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->settings()->memoryInfoEnabled());
|
| + }
|
| +}
|
| +
|
| +void MemoryInfo::loadMemoryInfo(bool memoryInfoEnabled)
|
| +{
|
| + if (memoryInfoEnabled) {
|
| ScriptGCEvent::getHeapSize(m_info);
|
| } else {
|
| DEFINE_STATIC_LOCAL(HeapSizeCache, heapSizeCache, ());
|
|
|