зеркало из https://github.com/mozilla/gecko-dev.git
bug 755661 part 2 - add thread scoped long strings; r=past
This commit is contained in:
Родитель
df3899ae85
Коммит
48f940e2ba
|
@ -487,6 +487,7 @@ function ThreadClient(aClient, aActor) {
|
||||||
this._frameCache = [];
|
this._frameCache = [];
|
||||||
this._scriptCache = {};
|
this._scriptCache = {};
|
||||||
this._pauseGrips = {};
|
this._pauseGrips = {};
|
||||||
|
this._threadGrips = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadClient.prototype = {
|
ThreadClient.prototype = {
|
||||||
|
@ -861,30 +862,74 @@ ThreadClient.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of LongStringClient for the given long string grip.
|
* Get or create a long string client, checking the grip client cache if it
|
||||||
|
* already exists.
|
||||||
|
*
|
||||||
|
* @param aGrip Object
|
||||||
|
* The long string grip returned by the protocol.
|
||||||
|
* @param aGripCacheName String
|
||||||
|
* The property name of the grip client cache to check for existing
|
||||||
|
* clients in.
|
||||||
|
*/
|
||||||
|
_longString: function TC__longString(aGrip, aGripCacheName) {
|
||||||
|
if (aGrip.actor in this[aGripCacheName]) {
|
||||||
|
return this[aGripCacheName][aGrip.actor];
|
||||||
|
}
|
||||||
|
|
||||||
|
let client = new LongStringClient(this._client, aGrip);
|
||||||
|
this[aGripCacheName][aGrip.actor] = client;
|
||||||
|
return client;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an instance of LongStringClient for the given long string grip that
|
||||||
|
* is scoped to the current pause.
|
||||||
*
|
*
|
||||||
* @param aGrip Object
|
* @param aGrip Object
|
||||||
* The long string grip returned by the protocol.
|
* The long string grip returned by the protocol.
|
||||||
*/
|
*/
|
||||||
longString: function TC_longString(aGrip) {
|
pauseLongString: function TC_pauseLongString(aGrip) {
|
||||||
if (aGrip.actor in this._pauseGrips) {
|
return this._longString(aGrip, "_pauseGrips");
|
||||||
return this._pauseGrips[aGrip.actor];
|
},
|
||||||
}
|
|
||||||
|
|
||||||
let client = new LongStringClient(this._client, aGrip);
|
/**
|
||||||
this._pauseGrips[aGrip.actor] = client;
|
* Return an instance of LongStringClient for the given long string grip that
|
||||||
return client;
|
* is scoped to the thread lifetime.
|
||||||
|
*
|
||||||
|
* @param aGrip Object
|
||||||
|
* The long string grip returned by the protocol.
|
||||||
|
*/
|
||||||
|
threadLongString: function TC_threadLongString(aGrip) {
|
||||||
|
return this._longString(aGrip, "_threadGrips");
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear and invalidate all the grip clients from the given cache.
|
||||||
|
*
|
||||||
|
* @param aGripCacheName
|
||||||
|
* The property name of the grip cache we want to clear.
|
||||||
|
*/
|
||||||
|
_clearGripClients: function TC_clearGrips(aGripCacheName) {
|
||||||
|
for each (let grip in this[aGripCacheName]) {
|
||||||
|
grip.valid = false;
|
||||||
|
}
|
||||||
|
this[aGripCacheName] = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidate pause-lifetime grip clients and clear the list of
|
* Invalidate pause-lifetime grip clients and clear the list of
|
||||||
* current grip clients.
|
* current grip clients.
|
||||||
*/
|
*/
|
||||||
_clearPauseGrips: function TC_clearPauseGrips(aPacket) {
|
_clearPauseGrips: function TC_clearPauseGrips() {
|
||||||
for each (let grip in this._pauseGrips) {
|
this._clearGripClients("_pauseGrips");
|
||||||
grip.valid = false;
|
},
|
||||||
}
|
|
||||||
this._pauseGrips = {};
|
/**
|
||||||
|
* Invalidate pause-lifetime grip clients and clear the list of
|
||||||
|
* current grip clients.
|
||||||
|
*/
|
||||||
|
_clearThreadGrips: function TC_clearPauseGrips() {
|
||||||
|
this._clearGripClients("_threadGrips");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -895,6 +940,7 @@ ThreadClient.prototype = {
|
||||||
this._state = ThreadStateTypes[aPacket.type];
|
this._state = ThreadStateTypes[aPacket.type];
|
||||||
this._clearFrames();
|
this._clearFrames();
|
||||||
this._clearPauseGrips();
|
this._clearPauseGrips();
|
||||||
|
aPacket.type === ThreadStateTypes.detached && this._clearThreadGrips();
|
||||||
this._client._eventsEnabled && this.notify(aPacket.type, aPacket);
|
this._client._eventsEnabled && this.notify(aPacket.type, aPacket);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -787,7 +787,7 @@ ThreadActor.prototype = {
|
||||||
let type = typeof(aValue);
|
let type = typeof(aValue);
|
||||||
|
|
||||||
if (type === "string" && this._stringIsLong(aValue)) {
|
if (type === "string" && this._stringIsLong(aValue)) {
|
||||||
return this.longStringGrip(aValue);
|
return this.longStringGrip(aValue, this._pausePool);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "boolean" || type === "string" || type === "number") {
|
if (type === "boolean" || type === "string" || type === "number") {
|
||||||
|
@ -881,26 +881,44 @@ ThreadActor.prototype = {
|
||||||
*
|
*
|
||||||
* @param aString String
|
* @param aString String
|
||||||
* The string we are creating a grip for.
|
* The string we are creating a grip for.
|
||||||
|
* @param aPool ActorPool
|
||||||
|
* The actor pool where the new actor will be added.
|
||||||
*/
|
*/
|
||||||
longStringGrip: function TA_longStringGrip(aString) {
|
longStringGrip: function TA_longStringGrip(aString, aPool) {
|
||||||
if (!this._pausePool) {
|
if (!aPool.longStringActors) {
|
||||||
throw new Error("LongString grip requested while not paused.");
|
aPool.longStringActors = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._pausePool.longStringActors) {
|
if (aPool.longStringActors.hasOwnProperty(aString)) {
|
||||||
this._pausePool.longStringActors = {};
|
return aPool.longStringActors[aString].grip();
|
||||||
}
|
|
||||||
|
|
||||||
if (this._pausePool.longStringActors.hasOwnProperty(aString)) {
|
|
||||||
return this._pausePool.longStringActors[aString].grip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let actor = new LongStringActor(aString, this);
|
let actor = new LongStringActor(aString, this);
|
||||||
this._pausePool.addActor(actor);
|
aPool.addActor(actor);
|
||||||
this._pausePool.longStringActors[aString] = actor;
|
aPool.longStringActors[aString] = actor;
|
||||||
return actor.grip();
|
return actor.grip();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a long string grip that is scoped to a pause.
|
||||||
|
*
|
||||||
|
* @param aString String
|
||||||
|
* The string we are creating a grip for.
|
||||||
|
*/
|
||||||
|
pauseLongStringGrip: function TA_pauseLongStringGrip (aString) {
|
||||||
|
return this.longStringGrip(aString, this._pausePool);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a long string grip that is scoped to a thread.
|
||||||
|
*
|
||||||
|
* @param aString String
|
||||||
|
* The string we are creating a grip for.
|
||||||
|
*/
|
||||||
|
threadLongStringGrip: function TA_pauseLongStringGrip (aString) {
|
||||||
|
return this.longStringGrip(aString, this._threadLifetimePool);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the string is long enough to use a LongStringActor instead
|
* Returns true if the string is long enough to use a LongStringActor instead
|
||||||
* of passing the value directly over the protocol.
|
* of passing the value directly over the protocol.
|
||||||
|
|
|
@ -48,7 +48,7 @@ function test_longstring_grip()
|
||||||
do_check_eq(grip.length, longString.length);
|
do_check_eq(grip.length, longString.length);
|
||||||
do_check_eq(grip.initial, longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH));
|
do_check_eq(grip.initial, longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH));
|
||||||
|
|
||||||
let longStringClient = gThreadClient.longString(grip);
|
let longStringClient = gThreadClient.pauseLongString(grip);
|
||||||
longStringClient.substring(22, 28, function (aResponse) {
|
longStringClient.substring(22, 28, function (aResponse) {
|
||||||
try {
|
try {
|
||||||
do_check_eq(aResponse.substring, "monkey");
|
do_check_eq(aResponse.substring, "monkey");
|
||||||
|
|
|
@ -36,7 +36,7 @@ function test_longstring_grip()
|
||||||
actor: "123fakeActor123",
|
actor: "123fakeActor123",
|
||||||
initial: ""
|
initial: ""
|
||||||
};
|
};
|
||||||
let longStringClient = gThreadClient.longString(fakeLongStringGrip);
|
let longStringClient = gThreadClient.pauseLongString(fakeLongStringGrip);
|
||||||
longStringClient.substring(22, 28, function (aResponse) {
|
longStringClient.substring(22, 28, function (aResponse) {
|
||||||
try {
|
try {
|
||||||
do_check_true(!!aResponse.error,
|
do_check_true(!!aResponse.error,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче