Add a way to drop all cached memory
This commit is contained in:
parent
22a3765394
commit
d83c36e0fd
2 changed files with 12 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "atom/renderer/api/atom_api_spell_check_client.h"
|
#include "atom/renderer/api/atom_api_spell_check_client.h"
|
||||||
|
#include "base/memory/memory_pressure_listener.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
@ -177,6 +178,14 @@ v8::Local<v8::Value> WebFrame::GetResourceUsage(v8::Isolate* isolate) {
|
||||||
return mate::Converter<blink::WebCache::ResourceTypeStats>::ToV8(isolate, stats);
|
return mate::Converter<blink::WebCache::ResourceTypeStats>::ToV8(isolate, stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebFrame::PurgeCaches(v8::Isolate* isolate) {
|
||||||
|
isolate->IdleNotificationDeadline(0.5);
|
||||||
|
blink::WebCache::clear();
|
||||||
|
|
||||||
|
base::MemoryPressureListener::NotifyMemoryPressure(
|
||||||
|
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void WebFrame::BuildPrototype(
|
void WebFrame::BuildPrototype(
|
||||||
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
|
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
|
||||||
|
@ -201,7 +210,8 @@ void WebFrame::BuildPrototype(
|
||||||
&WebFrame::RegisterURLSchemeAsPrivileged)
|
&WebFrame::RegisterURLSchemeAsPrivileged)
|
||||||
.SetMethod("insertText", &WebFrame::InsertText)
|
.SetMethod("insertText", &WebFrame::InsertText)
|
||||||
.SetMethod("executeJavaScript", &WebFrame::ExecuteJavaScript)
|
.SetMethod("executeJavaScript", &WebFrame::ExecuteJavaScript)
|
||||||
.SetMethod("getResourceUsage", &WebFrame::GetResourceUsage);
|
.SetMethod("getResourceUsage", &WebFrame::GetResourceUsage)
|
||||||
|
.SetMethod("purgeCaches", &WebFrame::PurgeCaches);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
|
@ -72,6 +72,7 @@ class WebFrame : public mate::Wrappable<WebFrame> {
|
||||||
|
|
||||||
// Resource related methods
|
// Resource related methods
|
||||||
v8::Local<v8::Value> GetResourceUsage(v8::Isolate* isolate);
|
v8::Local<v8::Value> GetResourceUsage(v8::Isolate* isolate);
|
||||||
|
void PurgeCaches(v8::Isolate* isolate);
|
||||||
|
|
||||||
scoped_ptr<SpellCheckClient> spell_check_client_;
|
scoped_ptr<SpellCheckClient> spell_check_client_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue