<commit_before>/* See license.txt for terms of usage */

"use strict";

module.metadata = {
  "stability": "experimental"
};

const { defer } = require("sdk/core/promise");
const { Trace, TraceError } = require("./trace.js").get(module.id);
const { System } = require("./system.js");

// xxxHonza: Firefox 36+
const { ActorRegistryFront } = System.devtoolsRequire("devtools/server/actors/actor-registry");

// xxxHonza: Firefox 37+
const { registerActor } = System.devtoolsRequire("devtools/server/actors/utils/actor-registry-utils");

// Module implementation
let Rdp = {};

/**
 * TODO: docs
 */
Rdp.registerActor = function(client, options) {
  let deferred = defer();
  let frontCtor = options.frontClass;
  let typeName = frontCtor.prototype.typeName;
  let moduleUrl = options.moduleUrl;

  // Dynamic actor installation using ActorRegistryFront doesn't support
  // e10s yet. Also the registry actor has been introduced in Firefox 36
  // Firefox 37 introduces support for e10s (use registerActor method for
  // the feature detection).
  let notSupported = typeof registerActor == "undefined";
  if (System.isMultiprocessEnabled() && notSupported) {
    TraceError.sysout("logging.onToolboxReady; ERROR e10s is not " +
      "supported in this browser version. Try Firefox 37+");
    deferred.resolve({});
    return;
  }

  // ActorRegistryFront has been introduced in Firefox 36
  if (typeof ActorRegistryFront == "undefined") {
    TraceError.sysout("logging.onToolboxReady; ERROR dynamic actor " +
      "registration has been introduced in Firefox 36");
    deferred.resolve({});
    return;
  }

  // First ask for list of tabs to check out whether the actor is
  // already registered or not.
  // xxxHonza: there should be a cache for 'listTabs' response
  // to reduce number or 'listTabs' requests sent to the backend.<commit_msg>#270 TODO comment<commit_after>/* See license.txt for terms of usage */

"use strict";

module.metadata = {
  "stability": "experimental"
};

const { defer } = require("sdk/core/promise");
const { Trace, TraceError } = require("./trace.js").get(module.id);
const { System } = require("./system.js");

// xxxHonza: Firefox 36+
const { ActorRegistryFront } = System.devtoolsRequire("devtools/server/actors/actor-registry");

// xxxHonza: Firefox 37+
const { registerActor } = System.devtoolsRequire("devtools/server/actors/utils/actor-registry-utils");

// Module implementation
let Rdp = {};

/**
 * TODO: docs
 *
 * xxxHonza: TODO:
 * 1. caching to avoid too many 'listTabs' packets.
 * 2. using client.getActor to get existing front objects.
 */
Rdp.registerActor = function(client, options) {
  let deferred = defer();
  let frontCtor = options.frontClass;
  let typeName = frontCtor.prototype.typeName;
  let moduleUrl = options.moduleUrl;

  // Dynamic actor installation using ActorRegistryFront doesn't support
  // e10s yet. Also the registry actor has been introduced in Firefox 36
  // Firefox 37 introduces support for e10s (use registerActor method for
  // the feature detection).
  let notSupported = typeof registerActor == "undefined";
  if (System.isMultiprocessEnabled() && notSupported) {
    TraceError.sysout("logging.onToolboxReady; ERROR e10s is not " +
      "supported in this browser version. Try Firefox 37+");
    deferred.resolve({});
    return;
  }

  // ActorRegistryFront has been introduced in Firefox 36
  if (typeof ActorRegistryFront == "undefined") {
    TraceError.sysout("logging.onToolboxReady; ERROR dynamic actor " +
      "registration has been introduced in Firefox 36");
    deferred.resolve({});
    return;
  }

  // First ask for list of tabs to check out whether the actor is
  // already registered or not.
  // xxxHonza: there should be a cache for 'listTabs' response
  // to reduce number or 'listTabs' requests sent to the backend.
{'fraction_non_alphanumeric': 0.1174015131750587, 'fraction_numerical': 0.01174015131750587, 'mean_word_length': 3.8531645569620254, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4961550', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1073, 'n_words': 359}