зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1278625 - move SimpleStringFront to specs/string.js; r=ejpbruel
MozReview-Commit-ID: Ib11CZwL4pP --HG-- extra : rebase_source : 85b35231efa1e987bd4742a7d9255fb19bfeb435
This commit is contained in:
Родитель
6c3ffd2acd
Коммит
1d6c2684eb
|
@ -9,6 +9,9 @@ var {RetVal, Arg, Option} = protocol;
|
|||
var events = require("sdk/event/core");
|
||||
var {LongStringActor} = require("devtools/server/actors/string");
|
||||
|
||||
// The test implicitly relies on this.
|
||||
require("devtools/shared/fronts/string");
|
||||
|
||||
function simpleHello() {
|
||||
return {
|
||||
from: "root",
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
|
||||
const {DebuggerServer} = require("devtools/server/main");
|
||||
const promise = require("promise");
|
||||
const {Class} = require("sdk/core/heritage");
|
||||
const {longStringSpec} = require("devtools/shared/specs/string");
|
||||
const {longStringSpec, SimpleStringFront} = require("devtools/shared/specs/string");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
|
||||
const LongStringFront = protocol.FrontClass(longStringSpec, {
|
||||
|
@ -45,35 +44,4 @@ const LongStringFront = protocol.FrontClass(longStringSpec, {
|
|||
});
|
||||
|
||||
exports.LongStringFront = LongStringFront;
|
||||
|
||||
/**
|
||||
* When a caller is expecting a LongString actor but the string is already available on
|
||||
* client, the SimpleStringFront can be used as it shares the same API as a
|
||||
* LongStringFront but will not make unnecessary trips to the server.
|
||||
*/
|
||||
exports.SimpleStringFront = Class({
|
||||
initialize: function (str) {
|
||||
this.str = str;
|
||||
},
|
||||
|
||||
get length() {
|
||||
return this.str.length;
|
||||
},
|
||||
|
||||
get initial() {
|
||||
return this.str;
|
||||
},
|
||||
|
||||
string: function () {
|
||||
return promise.resolve(this.str);
|
||||
},
|
||||
|
||||
substring: function (start, end) {
|
||||
return promise.resolve(this.str.substring(start, end));
|
||||
},
|
||||
|
||||
release: function () {
|
||||
this.str = null;
|
||||
return promise.resolve(undefined);
|
||||
}
|
||||
});
|
||||
exports.SimpleStringFront = SimpleStringFront;
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {Arg, RetVal, generateActorSpec} = protocol;
|
||||
|
||||
loader.lazyRequireGetter(this, "SimpleStringFront",
|
||||
"devtools/shared/fronts/string", true);
|
||||
const promise = require("promise");
|
||||
const {Class} = require("sdk/core/heritage");
|
||||
|
||||
const longStringSpec = generateActorSpec({
|
||||
typeName: "longstractor",
|
||||
|
@ -26,6 +25,40 @@ const longStringSpec = generateActorSpec({
|
|||
|
||||
exports.longStringSpec = longStringSpec;
|
||||
|
||||
/**
|
||||
* When a caller is expecting a LongString actor but the string is already available on
|
||||
* client, the SimpleStringFront can be used as it shares the same API as a
|
||||
* LongStringFront but will not make unnecessary trips to the server.
|
||||
*/
|
||||
const SimpleStringFront = Class({
|
||||
initialize: function (str) {
|
||||
this.str = str;
|
||||
},
|
||||
|
||||
get length() {
|
||||
return this.str.length;
|
||||
},
|
||||
|
||||
get initial() {
|
||||
return this.str;
|
||||
},
|
||||
|
||||
string: function () {
|
||||
return promise.resolve(this.str);
|
||||
},
|
||||
|
||||
substring: function (start, end) {
|
||||
return promise.resolve(this.str.substring(start, end));
|
||||
},
|
||||
|
||||
release: function () {
|
||||
this.str = null;
|
||||
return promise.resolve(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
exports.SimpleStringFront = SimpleStringFront;
|
||||
|
||||
// The long string actor needs some custom marshalling, because it is sometimes
|
||||
// returned as a primitive rather than a complete form.
|
||||
|
||||
|
@ -47,7 +80,7 @@ protocol.types.addType("longstring", {
|
|||
throw Error("Passing a longstring as an argument isn't supported.");
|
||||
}
|
||||
if (typeof (value) === "string") {
|
||||
return SimpleStringFront(value);
|
||||
return new SimpleStringFront(value);
|
||||
}
|
||||
return stringActorType.read(value, context, detail);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче