Files
firefox/devtools/shared/fronts/string.js
T
Nicolas Chevobbe f0ac5d9860 Bug 1591330 - Remove LongStringClient. r=jdescottes.
The LongStringClient is removed and we replace its
usage with LongStringFront instead.
This require a few variable/function renaming, as
well as updating the mocks we use in node tests.

Switch usage to LongStringFront instead.

Differential Revision: https://phabricator.services.mozilla.com/D50579
2019-10-28 16:22:06 +00:00

52 lines
1.4 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DebuggerServer } = require("devtools/server/debugger-server");
const {
longStringSpec,
SimpleStringFront,
} = require("devtools/shared/specs/string");
const {
FrontClassWithSpec,
registerFront,
} = require("devtools/shared/protocol");
class LongStringFront extends FrontClassWithSpec(longStringSpec) {
destroy() {
this.initial = null;
this.length = null;
this.strPromise = null;
super.destroy();
}
form(form) {
this.actorID = form.actor;
this.initial = form.initial;
this.length = form.length;
}
string() {
if (!this.strPromise) {
const promiseRest = thusFar => {
if (thusFar.length === this.length) {
return Promise.resolve(thusFar);
}
return this.substring(
thusFar.length,
thusFar.length + DebuggerServer.LONG_STRING_READ_LENGTH
).then(next => promiseRest(thusFar + next));
};
this.strPromise = promiseRest(this.initial);
}
return this.strPromise;
}
}
exports.LongStringFront = LongStringFront;
registerFront(LongStringFront);
exports.SimpleStringFront = SimpleStringFront;
registerFront(SimpleStringFront);