Mapping HTTP Requests to the Tab that made the request?

I am stuck with my Add-on and would love some help.

My Add-on looks at the current Tab that is in focus and tells you what ID’s were requested from that Tab page. The ID’s are collect from the PUT requests the page that is currently loaded in the Tab. The problem I am having is that I only know how to listen to the Global HTTP requests and don’ know how to figure out which request went with which URL or Tab.

I am using Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);. My observer see’s all the URL requests, so I just have one giant list, not a list per Tab. :frowning:

observe: function (subject, topic, data) {
    if (topic == "http-on-opening-request") {
      subject.QueryInterface(Ci.nsIHttpChannel);
      var url = subject.URI.spec;

      // what I wish todo: figure out the Tab or Tab url
      // (page that made the request) here.
      myModel.addUrlForTab(url, tab);
    }
  }

Any help would be greatly appreciated.

-H

Hmm… I think I might have found my answer:

Getting_the_browser_that_fires_the_http-on-modify-request_notification

Actually… not that I have had time to look into this issue I am still stuck. The above post does help, but I can not match the TabID’s or even the Tab items.

So… in my code I am listening for ActiveTab changing via:

const tabs = require("sdk/tabs");
tabs.on('activate', function () {
  console.log('active: ' + tabs.activeTab.url);  // returns "active: -3-1"
  var tab = tabs.activeTab;
  var tabId = tab.id;
  tabsModel.setTab(tab);
  updateViewFromModel();
});

When the HTTP request are fired I am recording them… but the Tab ID’s are always empty strings. The tab that is returned is a <tab.tabbrowser-tab>

Again… tab.id: ""

I am using the last method in the sample code that return ‘goodies’.