feat: promisify session cache methods (#17185)

This commit is contained in:
Shelley Vohr 2019-03-08 14:42:03 -08:00 committed by GitHub
parent 652e232813
commit fc10620082
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 17 deletions

View file

@ -13,8 +13,6 @@ When a majority of affected functions are migrated, this flag will be enabled by
- [dialog.showCertificateTrustDialog([browserWindow, ]options, callback)](https://github.com/electron/electron/blob/master/docs/api/dialog.md#showCertificateTrustDialog)
- [inAppPurchase.purchaseProduct(productID, quantity, callback)](https://github.com/electron/electron/blob/master/docs/api/in-app-purchase.md#purchaseProduct)
- [inAppPurchase.getProducts(productIDs, callback)](https://github.com/electron/electron/blob/master/docs/api/in-app-purchase.md#getProducts)
- [ses.getCacheSize(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#getCacheSize)
- [ses.clearCache(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#clearCache)
- [ses.getBlobData(identifier, callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#getBlobData)
- [ses.clearAuthCache(options[, callback])](https://github.com/electron/electron/blob/master/docs/api/session.md#clearAuthCache)
- [contents.executeJavaScript(code[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#executeJavaScript)
@ -47,6 +45,8 @@ When a majority of affected functions are migrated, this flag will be enabled by
- [ses.clearStorageData([options, callback])](https://github.com/electron/electron/blob/master/docs/api/session.md#clearStorageData)
- [ses.setProxy(config, callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#setProxy)
- [ses.resolveProxy(url, callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#resolveProxy)
- [ses.getCacheSize(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#getCacheSize)
- [ses.clearCache(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#clearCache)
- [shell.openExternal(url[, options, callback])](https://github.com/electron/electron/blob/master/docs/api/shell.md#openExternal)
- [webviewTag.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#capturePage)
- [webviewTag.printToPDF(options, callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#printToPDF)

View file

@ -97,12 +97,28 @@ The following methods are available on instances of `Session`:
* `callback` Function
* `size` Integer - Cache size used in bytes.
* `error` Integer - The error code corresponding to the failure.
Callback is invoked with the session's current cache size.
**[Deprecated Soon](promisification.md)**
#### `ses.getCacheSize()`
Returns `Promise<Integer>` - the session's current cache size, in bytes.
#### `ses.clearCache(callback)`
* `callback` Function - Called when operation is done.
* `error` Integer - The error code corresponding to the failure.
Clears the sessions HTTP cache.
**[Deprecated Soon](promisification.md)**
#### `ses.clearCache()`
Returns `Promise<void>` - resolves when the cache clear operation is complete.
Clears the sessions HTTP cache.

View file

@ -128,7 +128,7 @@ Using the `Session` and `Cookies` classes as an example:
### Instance Methods
#### `ses.getCacheSize(callback)`
#### `ses.getCacheSize()`
### Instance Properties