Bug 993282 - Lazy load more js modules - Part 2: contacts r=gwagner
☠☠ backed out by 7616388e078a ☠ ☠
authorFabrice Desré <fabrice@mozilla.com>
Wed, 07 May 2014 15:53:16 -0700
changeset 182108 6b9c8d6ab40114d34ca417cd46904bb463677e64
parent 182107 96e1a542bb45af1ffd666ffe6d8f445caabdb4e7
child 182109 30e0991d49e0e55633014653a852a9e4f05f8da3
push id26747
push usercbook@mozilla.com
push dateThu, 08 May 2014 12:04:10 +0000
treeherdermozilla-central@a8602e656d86 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgwagner
bugs993282
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 993282 - Lazy load more js modules - Part 2: contacts r=gwagner
dom/contacts/fallback/ContactDB.jsm
dom/contacts/fallback/ContactService.jsm
dom/phonenumberutils/PhoneNumber.jsm
dom/phonenumberutils/PhoneNumberUtils.jsm
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -10,19 +10,21 @@ this.EXPORTED_SYMBOLS = ["ContactDB", "D
 
 const DEBUG = false;
 function debug(s) { dump("-*- ContactDB component: " + s + "\n"); }
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
-Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberUtils",
+                                  "resource://gre/modules/PhoneNumberUtils.jsm");
 Cu.importGlobalProperties(["indexedDB"]);
 
 /* all exported symbols need to be bound to this on B2G - Bug 961777 */
 this.DB_NAME = "contacts";
 this.DB_VERSION = 20;
 this.STORE_NAME = "contacts";
 this.SAVED_GETALL_STORE_NAME = "getallcache";
 const CHUNK_SIZE = 20;
--- a/dom/contacts/fallback/ContactService.jsm
+++ b/dom/contacts/fallback/ContactService.jsm
@@ -10,18 +10,21 @@ function debug(s) { dump("-*- Fallback C
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 this.EXPORTED_SYMBOLS = ["ContactService"];
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/ContactDB.jsm");
-Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "ContactDB",
+                                  "resource://gre/modules/ContactDB.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberUtils",
+                                  "resource://gre/modules/PhoneNumberUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageListenerManager");
 
 
 /* all exported symbols need to be bound to this on B2G - Bug 961777 */
 let ContactService = this.ContactService = {
--- a/dom/phonenumberutils/PhoneNumber.jsm
+++ b/dom/phonenumberutils/PhoneNumber.jsm
@@ -3,19 +3,23 @@
 
 // Don't modify this code. Please use:
 // https://github.com/andreasgal/PhoneNumber.js
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["PhoneNumber"];
 
-Components.utils.import("resource://gre/modules/PhoneNumberMetaData.jsm");
-Components.utils.import("resource://gre/modules/PhoneNumberNormalizer.jsm");
+const Cu = Components.utils;
 
+Cu.import('resource://gre/modules/XPCOMUtils.jsm');
+XPCOMUtils.defineLazyModuleGetter(this, "PHONE_NUMBER_META_DATA",
+                                  "resource://gre/modules/PhoneNumberMetaData.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberNormalizer",
+                                  "resource://gre/modules/PhoneNumberNormalizer.jsm");
 this.PhoneNumber = (function (dataBase) {
   // Use strict in our context only - users might not want it
   'use strict';
 
   const MAX_PHONE_NUMBER_LENGTH = 50;
   const NON_ALPHA_CHARS = /[^a-zA-Z]/g;
   const NON_DIALABLE_CHARS = /[^,#+\*\d]/g;
   const NON_DIALABLE_CHARS_ONCE = new RegExp(NON_DIALABLE_CHARS.source);
--- a/dom/phonenumberutils/PhoneNumberUtils.jsm
+++ b/dom/phonenumberutils/PhoneNumberUtils.jsm
@@ -9,18 +9,20 @@ const DEBUG = false;
 function debug(s) { if(DEBUG) dump("-*- PhoneNumberutils: " + s + "\n"); }
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-Cu.import("resource://gre/modules/PhoneNumberNormalizer.jsm");
-Cu.import("resource://gre/modules/mcc_iso3166_table.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberNormalizer",
+                                  "resource://gre/modules/PhoneNumberNormalizer.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "MCC_ISO3166_TABLE",
+                                  "resource://gre/modules/mcc_iso3166_table.jsm");
 
 #ifdef MOZ_B2G_RIL
 XPCOMUtils.defineLazyServiceGetter(this, "mobileConnection",
                                    "@mozilla.org/ril/content-helper;1",
                                    "nsIMobileConnectionProvider");
 XPCOMUtils.defineLazyServiceGetter(this, "icc",
                                    "@mozilla.org/ril/content-helper;1",
                                    "nsIIccProvider");
@@ -191,15 +193,16 @@ this.PhoneNumberUtils = {
         if (DEBUG) debug("WRONG MESSAGE NAME: " + aMessage.name);
     }
   }
 };
 
 let inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
                  .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 if (inParent) {
-  Cu.import("resource://gre/modules/PhoneNumber.jsm");
+  XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumber",
+                                    "resource://gre/modules/PhoneNumber.jsm");
   XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                      "@mozilla.org/parentprocessmessagemanager;1",
                                      "nsIMessageListenerManager");
   PhoneNumberUtils.init();
 }