This source file includes following definitions.
- cleanUpDOMObjects
- numberOfDOMObjects
- collectGarbargeAndGetDOMCounts
#include "config.h"
#include "public/web/WebLeakDetector.h"
#include "bindings/v8/V8Binding.h"
#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/frame/DOMWindow.h"
#include "core/inspector/InspectorCounters.h"
#include "public/web/WebDocument.h"
#include "public/web/WebFrame.h"
#include <v8.h>
using namespace WebCore;
namespace {
void cleanUpDOMObjects(blink::WebFrame* frame)
{
v8::HandleScope handleScope(v8::Isolate::GetCurrent());
v8::Local<v8::Context> context(frame->mainWorldScriptContext());
v8::Context::Scope contextScope(context);
ResourceFetcher* fetcher = currentDOMWindow(context->GetIsolate())->document()->fetcher();
if (fetcher)
fetcher->garbageCollectDocumentResources();
memoryCache()->evictResources();
v8::V8::LowMemoryNotification();
}
void numberOfDOMObjects(blink::WebFrame *frame, unsigned* numberOfLiveDocuments, unsigned* numberOfLiveNodes)
{
v8::HandleScope handleScope(v8::Isolate::GetCurrent());
v8::Local<v8::Context> context(frame->mainWorldScriptContext());
v8::Context::Scope contextScope(context);
*numberOfLiveDocuments = InspectorCounters::counterValue(InspectorCounters::DocumentCounter);
*numberOfLiveNodes = InspectorCounters::counterValue(InspectorCounters::NodeCounter);
}
}
namespace blink {
void WebLeakDetector::collectGarbargeAndGetDOMCounts(WebLocalFrame* frame, unsigned* numberOfLiveDocuments, unsigned* numberOfLiveNodes)
{
cleanUpDOMObjects(frame);
numberOfDOMObjects(frame, numberOfLiveDocuments, numberOfLiveNodes);
}
}