Bug 1214366 - Part 1: Don't preprocess PushServiceWebSocket.jsm. r=kitcambridge
authorNick Alexander <nalexander@mozilla.com>
Fri, 16 Oct 2015 14:04:37 -0700
changeset 304766 07bf8588dda5af0b075918f578ad504fbf2a8757
parent 304765 c428767bf698ed72291ad05623e7ade44632df1c
child 304767 662e4aff03d4b102da29c5d500a072346be44bda
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskitcambridge
bugs1214366
milestone44.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 1214366 - Part 1: Don't preprocess PushServiceWebSocket.jsm. r=kitcambridge Just a little build system clean-up. There's no reason for this to be special, and it's easier to use in the debugger with correct line numbers.
dom/push/PushServiceWebSocket.jsm
dom/push/moz.build
--- a/dom/push/PushServiceWebSocket.jsm
+++ b/dom/push/PushServiceWebSocket.jsm
@@ -5,40 +5,41 @@
 
 "use strict";
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
+Cu.import("resource://gre/modules/AppConstants.jsm");
+Cu.import("resource://gre/modules/Preferences.jsm");
+Cu.import("resource://gre/modules/Promise.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/Timer.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
 const {PushDB} = Cu.import("resource://gre/modules/PushDB.jsm");
 const {PushRecord} = Cu.import("resource://gre/modules/PushRecord.jsm");
 const {
   PushCrypto,
   base64UrlDecode,
   getEncryptionKeyParams,
   getEncryptionParams,
 } = Cu.import("resource://gre/modules/PushCrypto.jsm");
-Cu.import("resource://gre/modules/Preferences.jsm");
-Cu.import("resource://gre/modules/Timer.jsm");
-Cu.import("resource://gre/modules/Promise.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
 
 XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
                                    "@mozilla.org/network/dns-service;1",
                                    "nsIDNSService");
 
-#ifdef MOZ_B2G
-XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService",
-                                   "@mozilla.org/power/powermanagerservice;1",
-                                   "nsIPowerManagerService");
-#endif
+if (AppConstants.MOZ_B2G) {
+  XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService",
+                                     "@mozilla.org/power/powermanagerservice;1",
+                                     "nsIPowerManagerService");
+}
 
 var threadManager = Cc["@mozilla.org/thread-manager;1"]
                       .getService(Ci.nsIThreadManager);
 
 const kPUSHWSDB_DB_NAME = "pushapi";
 const kPUSHWSDB_DB_VERSION = 5; // Change this if the IndexedDB format changes
 const kPUSHWSDB_STORE_NAME = "pushapi";
 
@@ -722,17 +723,20 @@ this.PushServiceWebSocket = {
       // alarm firing.
 
       // Websocket is shut down. Backoff interval expired, try to connect.
       this._beginWSSetup();
     }
   },
 
   _acquireWakeLock: function() {
-#ifdef MOZ_B2G
+    if (!AppConstants.MOZ_B2G) {
+      return;
+    }
+
     // Disable the wake lock on non-B2G platforms to work around bug 1154492.
     if (!this._socketWakeLock) {
       debug("Acquiring Socket Wakelock");
       this._socketWakeLock = gPowerManagerService.newWakeLock("cpu");
     }
     if (!this._socketWakeLockTimer) {
       debug("Creating Socket WakeLock Timer");
       this._socketWakeLockTimer = Cc["@mozilla.org/timer;1"]
@@ -743,30 +747,31 @@ this.PushServiceWebSocket = {
     this._socketWakeLockTimer
       .initWithCallback(this._releaseWakeLock.bind(this),
                         // Allow the same time for socket setup as we do for
                         // requests after the setup. Fudge it a bit since
                         // timers can be a little off and we don't want to go
                         // to sleep just as the socket connected.
                         this._requestTimeout + 1000,
                         Ci.nsITimer.TYPE_ONE_SHOT);
-#endif
   },
 
   _releaseWakeLock: function() {
-#ifdef MOZ_B2G
+    if (!AppConstants.MOZ_B2G) {
+      return;
+    }
+
     debug("Releasing Socket WakeLock");
     if (this._socketWakeLockTimer) {
       this._socketWakeLockTimer.cancel();
     }
     if (this._socketWakeLock) {
       this._socketWakeLock.unlock();
       this._socketWakeLock = null;
     }
-#endif
   },
 
   /**
    * Protocol handler invoked by server message.
    */
   _handleHelloReply: function(reply) {
     debug("handleHelloReply()");
     if (this._currentState != STATE_WAITING_FOR_HELLO) {
--- a/dom/push/moz.build
+++ b/dom/push/moz.build
@@ -5,27 +5,24 @@
 
 EXTRA_COMPONENTS += [
     'Push.js',
     'Push.manifest',
     'PushClient.js',
     'PushNotificationService.js',
 ]
 
-EXTRA_PP_JS_MODULES += [
-    'PushServiceWebSocket.jsm',
-]
-
 EXTRA_JS_MODULES += [
     'PushCrypto.jsm',
     'PushDB.jsm',
     'PushRecord.jsm',
     'PushService.jsm',
     'PushServiceChildPreload.jsm',
     'PushServiceHttp2.jsm',
+    'PushServiceWebSocket.jsm',
 ]
 
 MOCHITEST_MANIFESTS += [
     'test/mochitest.ini',
 ]
 
 XPCSHELL_TESTS_MANIFESTS += [
     'test/xpcshell/xpcshell.ini',