diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index 2d1ebd288dfc..7ce3466ae50f 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -368,6 +368,15 @@ void WebFrame::ClearCache(v8::Isolate* isolate) { base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); } +void WebFrame::SetCacheCapacity(v8::Isolate* isolate, int capacity) { + if (capacity > 0) { + blink::WebCache::SetCapacity(capacity); + } else { + isolate->ThrowException(v8::Exception::TypeError( + mate::StringToV8(isolate, "Invalid cache capacity"))); + } +} + // static void WebFrame::BuildPrototype( v8::Isolate* isolate, v8::Local prototype) { @@ -408,6 +417,7 @@ void WebFrame::BuildPrototype( &WebFrame::SetIsolatedWorldHumanReadableName) .SetMethod("getResourceUsage", &WebFrame::GetResourceUsage) .SetMethod("clearCache", &WebFrame::ClearCache) + .SetMethod("setCacheCapacity", &WebFrame::SetCacheCapacity) // TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings .SetMethod("setZoomLevelLimits", &WebFrame::SetVisualZoomLevelLimits); } diff --git a/atom/renderer/api/atom_api_web_frame.h b/atom/renderer/api/atom_api_web_frame.h index 7abf870e7ae4..cbc60d9b0b1e 100644 --- a/atom/renderer/api/atom_api_web_frame.h +++ b/atom/renderer/api/atom_api_web_frame.h @@ -92,6 +92,7 @@ class WebFrame : public mate::Wrappable { // Resource related methods blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate); void ClearCache(v8::Isolate* isolate); + void SetCacheCapacity(v8::Isolate* isolate, int capacity); std::unique_ptr spell_check_client_;