Bug 1501108 - [3.6] Extend StorageController API to delete session context data. r=baku,snorp,geckoview-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D23732

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eugen Sawin 2019-07-21 17:20:19 +00:00
Родитель a953b9ae74
Коммит 10b4aa39cc
6 изменённых файлов: 43 добавлений и 2 удалений

Просмотреть файл

@ -65,7 +65,11 @@ GeckoViewStartup.prototype = {
GeckoViewUtils.addLazyGetter(this, "GeckoViewStorageController", {
module: "resource://gre/modules/GeckoViewStorageController.jsm",
ged: ["GeckoView:ClearData", "GeckoView:ClearHostData"],
ged: [
"GeckoView:ClearData",
"GeckoView:ClearSessionContextData",
"GeckoView:ClearHostData",
],
});
GeckoViewUtils.addLazyPrefObserver(

Просмотреть файл

@ -1047,6 +1047,7 @@ package org.mozilla.geckoview {
public final class StorageController {
ctor public StorageController();
method @AnyThread @NonNull public GeckoResult<Void> clearData(long);
method @AnyThread public void clearDataForSessionContext(@NonNull String);
method @AnyThread @NonNull public GeckoResult<Void> clearDataFromHost(@NonNull String, long);
}

Просмотреть файл

@ -86,6 +86,10 @@ public final class GeckoSessionSettings implements Parcelable {
* between sessions, only sessions that share the same ID share storage
* data.
*
* Warning: Storage data is collected persistently for each context,
* to delete context data, call {@link StorageController#clearDataForSessionContext}
* for the given context.
*
* @param value The custom context ID.
* The default ID is null, which removes isolation for this
* instance.

Просмотреть файл

@ -160,4 +160,24 @@ public final class StorageController {
return result;
}
/**
* Clear data for the given context ID.
* Use {@link GeckoSessionSettings.Builder#contextId}.to set a context ID
* for a session.
*
* Note: Any open session may re-accumulate previously cleared data. To
* ensure that no persistent data is left behind, you need to close all
* sessions for the given context prior to clearing data.
*
* @param contextId The context ID for the storage data to be deleted.
*/
@AnyThread
public void clearDataForSessionContext(final @NonNull String contextId) {
final GeckoBundle bundle = new GeckoBundle(1);
bundle.putString("contextId", contextId);
EventDispatcher.getInstance().dispatch(
"GeckoView:ClearSessionContextData", bundle);
}
}

Просмотреть файл

@ -143,6 +143,13 @@ exclude: true
[68.28]: ./GeckoSession.MediaSource.html
- Added API for session context assignment
[`GeckoSessionSettings.Builder.contextId`][68.29] and deletion of data
related to a session context
[`StorageController.clearSessionContextData`][68.30].
[68.29]: ../GeckoSessionSettings.Builder.html#contextId-
[68.30]: ../StorageController.html#clearSessionContextData-java.lang.String-
## v67
- Added [`setAutomaticFontSizeAdjustment`][67.2] to

Просмотреть файл

@ -98,6 +98,10 @@ const GeckoViewStorageController = {
this.clearData(aData.flags, aCallback);
break;
}
case "GeckoView:ClearSessionContextData": {
this.clearSessionContextData(aData.contextId);
break;
}
case "GeckoView:ClearHostData": {
this.clearHostData(aData.host, aData.flags, aCallback);
break;
@ -132,6 +136,7 @@ const GeckoViewStorageController = {
Services.clearData.deleteDataFromOriginAttributesPattern(pattern);
// Call QMS explicitly to work around bug 1537882.
Services.qms.clearStoragesForOriginAttributesPattern(
JSON.stringify(pattern));
JSON.stringify(pattern)
);
},
};