Rename webFrame.purgeCaches to webFrame.clearCache
This matches the name of session.clearCache.
This commit is contained in:
parent
7459581d13
commit
c740438032
3 changed files with 27 additions and 34 deletions
|
@ -178,10 +178,9 @@ blink::WebCache::ResourceTypeStats WebFrame::GetResourceUsage(
|
|||
return stats;
|
||||
}
|
||||
|
||||
void WebFrame::PurgeCaches(v8::Isolate* isolate) {
|
||||
void WebFrame::ClearCache(v8::Isolate* isolate) {
|
||||
isolate->IdleNotificationDeadline(0.5);
|
||||
blink::WebCache::clear();
|
||||
|
||||
base::MemoryPressureListener::NotifyMemoryPressure(
|
||||
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
|
||||
}
|
||||
|
@ -211,7 +210,7 @@ void WebFrame::BuildPrototype(
|
|||
.SetMethod("insertText", &WebFrame::InsertText)
|
||||
.SetMethod("executeJavaScript", &WebFrame::ExecuteJavaScript)
|
||||
.SetMethod("getResourceUsage", &WebFrame::GetResourceUsage)
|
||||
.SetMethod("purgeCaches", &WebFrame::PurgeCaches);
|
||||
.SetMethod("clearCache", &WebFrame::ClearCache);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -72,7 +72,7 @@ class WebFrame : public mate::Wrappable<WebFrame> {
|
|||
|
||||
// Resource related methods
|
||||
blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate);
|
||||
void PurgeCaches(v8::Isolate* isolate);
|
||||
void ClearCache(v8::Isolate* isolate);
|
||||
|
||||
scoped_ptr<SpellCheckClient> spell_check_client_;
|
||||
|
||||
|
|
|
@ -108,47 +108,41 @@ this limitation.
|
|||
|
||||
### `webFrame.getResourceUsage()`
|
||||
|
||||
Returns more detailed memory usage information in kilobytes of Blink's internal
|
||||
memory caches. Returns an Object of the following shape:
|
||||
Returns an object describing usage information of Blink's internal memory
|
||||
caches.
|
||||
|
||||
```js
|
||||
```javascript
|
||||
console.log(webFrame.getResourceUsage())
|
||||
```
|
||||
|
||||
This will generate:
|
||||
|
||||
```javascript
|
||||
{
|
||||
"images": {
|
||||
"count": 22,
|
||||
"size": 2549, // 2549kb
|
||||
"liveSize": 2542, // 2542kb, etc...
|
||||
"decodedSize": 478,
|
||||
"purgedSize": 0,
|
||||
"purgeableSize": 0
|
||||
images: {
|
||||
count: 22,
|
||||
size: 2549,
|
||||
liveSize: 2542,
|
||||
decodedSize: 478,
|
||||
purgedSize: 0,
|
||||
purgeableSize: 0
|
||||
},
|
||||
"cssStyleSheets": {
|
||||
"count": 7,
|
||||
/* ... */
|
||||
},
|
||||
"xslStyleSheets": {
|
||||
"count": 0,
|
||||
/* ... */
|
||||
},
|
||||
"fonts": {
|
||||
"count": 18,
|
||||
/* ... */
|
||||
},
|
||||
"other": {
|
||||
"count": 0,
|
||||
/* ... */
|
||||
}
|
||||
cssStyleSheets: { /* same with "images" */ },
|
||||
xslStyleSheets: { /* same with "images" */ },
|
||||
fonts: { /* same with "images" */ },
|
||||
other: { /* same with "images" */ },
|
||||
}
|
||||
```
|
||||
|
||||
### `webFrame.purgeCaches()`
|
||||
### `webFrame.clearCache()`
|
||||
|
||||
Attempts to free memory that is no longer being used (i.e. images from a
|
||||
previous navigation, etc etc).
|
||||
Attempts to free memory that is no longer being used (like images from a
|
||||
previous navigation).
|
||||
|
||||
Note that blindly calling this method probably makes Electron slower since it
|
||||
will have to refill these emptied caches, you should only call it if an event
|
||||
in your app has occured that makes you think your page is actually using less
|
||||
memory (i.e. you have navigated from a super heavy page to a mostly empty one,
|
||||
and intend to stay there)
|
||||
and intend to stay there).
|
||||
|
||||
[spellchecker]: https://github.com/atom/node-spellchecker
|
||||
|
|
Loading…
Reference in a new issue