Skip to content

Instantly share code, notes, and snippets.

@MikeRatcliffe
Created March 10, 2015 14:48
Show Gist options
  • Save MikeRatcliffe/23bdfb9f9cc061c73366 to your computer and use it in GitHub Desktop.
Save MikeRatcliffe/23bdfb9f9cc061c73366 to your computer and use it in GitHub Desktop.
Storage Actor Message Passing
diff --git a/toolkit/devtools/server/actors/childtab.js b/toolkit/devtools/server/actors/childtab.js
--- a/toolkit/devtools/server/actors/childtab.js
+++ b/toolkit/devtools/server/actors/childtab.js
@@ -24,16 +24,18 @@ let { TabActor } = require("devtools/ser
*/
function ContentActor(connection, chromeGlobal)
{
this._chromeGlobal = chromeGlobal;
TabActor.call(this, connection, chromeGlobal);
this.traits.reconfigure = false;
this._sendForm = this._sendForm.bind(this);
this._chromeGlobal.addMessageListener("debug:form", this._sendForm);
+ this._chromeGlobal.addMessageListener("storage:getCookiesFromHost",
+ this._getCookiesFromHost);
}
ContentActor.prototype = Object.create(TabActor.prototype);
ContentActor.prototype.constructor = ContentActor;
Object.defineProperty(ContentActor.prototype, "docShell", {
get: function() {
@@ -82,8 +84,12 @@ ContentActor.prototype.form = function (
/**
* On navigation events, our URL and/or title may change, so we update our
* counterpart in the parent process that participates in the tab list.
*/
ContentActor.prototype._sendForm = function() {
this._chromeGlobal.sendAsyncMessage("debug:form", this.form());
};
+
+ContentActor.prototype._getCookiesFromHost = function(aMessage) {
+ return {result: true};
+};
diff --git a/toolkit/devtools/server/actors/storage.js b/toolkit/devtools/server/actors/storage.js
--- a/toolkit/devtools/server/actors/storage.js
+++ b/toolkit/devtools/server/actors/storage.js
@@ -529,17 +529,25 @@ StorageActors.createActor({
isDomain: cookie.isDomain,
isSecure: cookie.isSecure,
isHttpOnly: cookie.isHttpOnly
}
},
populateStoresForHost: function(host) {
this.hostVsStores.set(host, new Map());
- let cookies = Services.cookies.getCookiesFromHost(host);
+
+debugger;
+ let cookies = this.storageActor.parentActor._chromeGlobal
+ .sendSyncMessage("storage:getCookiesFromHost", {
+ type: "storage:getCookiesFromHost",
+ data: host
+ });
+debugger;
+
while (cookies.hasMoreElements()) {
let cookie = cookies.getNext().QueryInterface(Ci.nsICookie)
.QueryInterface(Ci.nsICookie2);
if (this.isCookieAtHost(cookie, host)) {
this.hostVsStores.get(host).set(cookie.name, cookie);
}
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment