зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1468048 - Make GeckoSession.saveState() return a GeckoResult r=droeh,esawin
MozReview-Commit-ID: Ck6EZcaUeV2
This commit is contained in:
Родитель
68a96de0af
Коммит
aad0d2a7f6
|
@ -100,6 +100,18 @@ public class GeckoSession extends LayerSession
|
|||
private String mId = UUID.randomUUID().toString().replace("-", "");
|
||||
/* package */ String getId() { return mId; }
|
||||
|
||||
private static abstract class CallbackResult<T> extends GeckoResult<T> implements EventCallback {
|
||||
@Override
|
||||
public abstract void sendSuccess(Object response);
|
||||
|
||||
@Override
|
||||
public void sendError(Object response) {
|
||||
completeExceptionally(response != null ?
|
||||
new Exception(response.toString()) :
|
||||
new UnknownError());
|
||||
}
|
||||
}
|
||||
|
||||
private final GeckoSessionHandler<ContentDelegate> mContentHandler =
|
||||
new GeckoSessionHandler<ContentDelegate>(
|
||||
"GeckoViewContent", this,
|
||||
|
@ -1147,22 +1159,17 @@ public class GeckoSession extends LayerSession
|
|||
* but does not include information pertaining to the GeckoSession itself (for example,
|
||||
* this does not include settings on the GeckoSession).
|
||||
*
|
||||
* @param response This is a response which will be called with the state once it has been
|
||||
* saved. Can be null if we fail to save the state for any reason.
|
||||
* @return A {@link GeckoResult} containing the {@link SessionState}
|
||||
*/
|
||||
public void saveState(final GeckoResponse<SessionState> response) {
|
||||
mEventDispatcher.dispatch("GeckoView:SaveState", null, new EventCallback() {
|
||||
public @NonNull GeckoResult<SessionState> saveState() {
|
||||
CallbackResult<SessionState> result = new CallbackResult<SessionState>() {
|
||||
@Override
|
||||
public void sendSuccess(final Object result) {
|
||||
response.respond(new SessionState((String) result));
|
||||
public void sendSuccess(final Object value) {
|
||||
complete(new SessionState((String)value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(final Object result) {
|
||||
Log.w(LOGTAG, "Failed to save state, as another save is already in progress.");
|
||||
response.respond(null);
|
||||
}
|
||||
});
|
||||
};
|
||||
mEventDispatcher.dispatch("GeckoView:SaveState", null, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче