Merge birch to m-c.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 11 Jun 2013 21:02:41 -0400
changeset 146140 4e6b77e3ddd524b0086d947c9ee17223f67e99c9
parent 146135 2912073936087029874748e744c7a55278dc07cf (current diff)
parent 146139 76745eae01dfc19d2c7f7c7a3426e58d137f58db (diff)
child 146191 cc35f8929768bf4bf2d9e2f824c8553ae3863d67
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone24.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
Merge birch to m-c.
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -882,17 +882,22 @@ BrowserElementChild.prototype = {
       }
 
       if (stateFlags & Ci.nsIWebProgressListener.STATE_START) {
         this._seenLoadStart = true;
         sendAsyncMsg('loadstart');
       }
 
       if (stateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
-        sendAsyncMsg('loadend');
+        let bgColor = 'transparent';
+        try {
+          bgColor = content.getComputedStyle(content.document.body)
+                           .getPropertyValue('background-color');
+        } catch (e) {}
+        sendAsyncMsg('loadend', {backgroundColor: bgColor});
 
         // Ignoring NS_BINDING_ABORTED, which is set when loading page is
         // stopped.
         if (status == Cr.NS_OK ||
             status == Cr.NS_BINDING_ABORTED) {
           return;
         }
 
--- a/dom/browser-element/mochitest/Makefile.in
+++ b/dom/browser-element/mochitest/Makefile.in
@@ -19,16 +19,17 @@ MOCHITEST_FILES = \
 		file_empty_script.js \
 		file_empty.html \
 		file_focus.html \
 		browserElementTestHelpers.js \
 		test_browserElement_NoAttr.html \
 		test_browserElement_NoPref.html \
 		test_browserElement_NoWhitelist.html \
 		browserElement_LoadEvents.js \
+		file_browserElement_LoadEvents.html \
 		test_browserElement_inproc_LoadEvents.html \
 		browserElement_DataURI.js \
 		test_browserElement_inproc_DataURI.html \
 		browserElement_ErrorSecurity.js \
 		browserElement_Titlechange.js \
 		test_browserElement_inproc_Titlechange.html \
 		browserElement_TopBarrier.js \
 		test_browserElement_inproc_TopBarrier.html \
--- a/dom/browser-element/mochitest/browserElement_LoadEvents.js
+++ b/dom/browser-element/mochitest/browserElement_LoadEvents.js
@@ -17,17 +17,17 @@ function runTest() {
 
   var seenLoadEnd = false;
   var seenLoadStart = false;
   var seenLocationChange = false;
 
   var iframe = document.createElement('iframe');
   SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.id = 'iframe';
-  iframe.src = browserElementTestHelpers.emptyPage1;
+  iframe.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_LoadEvents.html';
 
   function loadstart(e) {
     ok(e.isTrusted, 'Event should be trusted.');
     ok(!seenLoadEnd, 'loadstart before loadend.');
     ok(!seenLoadStart, 'Just one loadstart event.');
     ok(!seenLocationChange, 'loadstart before locationchange.');
     seenLoadStart = true;
   }
@@ -41,16 +41,17 @@ function runTest() {
     ok(e.detail, browserElementTestHelpers.emptyPage1, "event's reported location");
   }
 
   function loadend(e) {
     ok(e.isTrusted, 'Event should be trusted.');
     ok(seenLoadStart, 'loadend after loadstart.');
     ok(!seenLoadEnd, 'Just one loadend event.');
     ok(seenLocationChange, 'loadend after locationchange.');
+    is(e.detail.backgroundColor, 'rgb(0, 128, 0)', 'Expected background color reported')
     seenLoadEnd = true;
   }
 
   iframe.addEventListener('mozbrowserloadstart', loadstart);
   iframe.addEventListener('mozbrowserlocationchange', locationchange);
   iframe.addEventListener('mozbrowserloadend', loadend);
 
   function waitForAllCallbacks() {
@@ -94,16 +95,17 @@ function runTest2() {
   });
 
   iframe.addEventListener('mozbrowserloadend', function(e) {
     ok(e.isTrusted, 'Event should be trusted.');
     ok(!seenLoadEnd, 'Just one load end event.');
     seenLoadEnd = true;
     ok(seenLoadStart, 'Load end after load start.');
     ok(seenLocationChange, 'Load end after location change.');
+    is(e.detail.backgroundColor, 'transparent', 'Expected background color reported')
   });
 
   iframe.src = browserElementTestHelpers.emptyPage2;
 
   function waitForAllCallbacks() {
     if (!seenLoadStart || !seenLoadEnd || !seenLocationChange) {
       SimpleTest.executeSoon(waitForAllCallbacks);
       return;
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/file_browserElement_LoadEvents.html
@@ -0,0 +1,14 @@
+<html>
+<body style="background-color:green;">
+
+<!-- Tests rely on the fact that there's an element in here called 'url' and
+     that there's visible text on the page. -->
+
+Aloha!  My URL is <span id='url'></span>.
+
+<script>
+document.getElementById('url').innerHTML = window.location;
+</script>
+
+</body>
+</html>
--- a/dom/network/src/NetworkStatsService.jsm
+++ b/dom/network/src/NetworkStatsService.jsm
@@ -13,19 +13,20 @@ this.EXPORTED_SYMBOLS = ["NetworkStatsSe
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/NetworkStatsDB.jsm");
 
 const NET_NETWORKSTATSSERVICE_CONTRACTID = "@mozilla.org/network/netstatsservice;1";
 const NET_NETWORKSTATSSERVICE_CID = Components.ID("{18725604-e9ac-488a-8aa0-2471e7f6c0a4}");
 
-const TOPIC_INTERFACE_REGISTERED = "network-interface-registered";
-const NETWORK_TYPE_WIFI = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
-const NETWORK_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
+const TOPIC_INTERFACE_REGISTERED   = "network-interface-registered";
+const TOPIC_INTERFACE_UNREGISTERED = "network-interface-unregistered";
+const NET_TYPE_WIFI = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
+const NET_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
 
 XPCOMUtils.defineLazyServiceGetter(this, "gIDBManager",
                                    "@mozilla.org/dom/indexeddb/manager;1",
                                    "nsIIndexedDatabaseManager");
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageListenerManager");
@@ -39,23 +40,27 @@ let myGlobal = this;
 this.NetworkStatsService = {
   init: function() {
     if (DEBUG) {
       debug("Service started");
     }
 
     Services.obs.addObserver(this, "xpcom-shutdown", false);
     Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, false);
+    Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, false);
     Services.obs.addObserver(this, "profile-after-change", false);
 
     this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
 
     this._connectionTypes = Object.create(null);
-    this._connectionTypes[NETWORK_TYPE_WIFI] = "wifi";
-    this._connectionTypes[NETWORK_TYPE_MOBILE] = "mobile";
+    this._connectionTypes[NET_TYPE_WIFI] = { name: "wifi",
+                                             network: Object.create(null) };
+    this._connectionTypes[NET_TYPE_MOBILE] = { name: "mobile",
+                                               network: Object.create(null) };
+
 
     this.messages = ["NetworkStats:Get",
                      "NetworkStats:Clear",
                      "NetworkStats:Types",
                      "NetworkStats:SampleRate",
                      "NetworkStats:MaxStorageSamples"];
 
     this.messages.forEach(function(msgName) {
@@ -90,51 +95,58 @@ this.NetworkStatsService = {
         break;
       case "NetworkStats:Clear":
         this.clearDB(mm, msg);
         break;
       case "NetworkStats:Types":
         // This message is sync.
         let types = [];
         for (let i in this._connectionTypes) {
-          types.push(this._connectionTypes[i]);
+          types.push(this._connectionTypes[i].name);
         }
         return types;
       case "NetworkStats:SampleRate":
         // This message is sync.
         return this._db.sampleRate;
       case "NetworkStats:MaxStorageSamples":
         // This message is sync.
         return this._db.maxStorageSamples;
     }
   },
 
   observe: function observe(subject, topic, data) {
     switch (topic) {
       case TOPIC_INTERFACE_REGISTERED:
+      case TOPIC_INTERFACE_UNREGISTERED:
         // If new interface is registered (notified from NetworkManager),
         // the stats are updated for the new interface without waiting to
         // complete the updating period
         let network = subject.QueryInterface(Ci.nsINetworkInterface);
         if (DEBUG) {
-          debug("Network " + network.name + " of type " + network.type + " registered");
+          debug("Network " + network.name + " of type " + network.type + " status change");
         }
-        this.updateStats(network.type);
+        if (this._connectionTypes[network.type]) {
+          this._connectionTypes[network.type].network = network;
+          this.updateStats(network.type);
+        }
         break;
       case "xpcom-shutdown":
         if (DEBUG) {
           debug("Service shutdown");
         }
 
         this.messages.forEach(function(msgName) {
           ppmm.removeMessageListener(msgName, this);
         }, this);
 
         Services.obs.removeObserver(this, "xpcom-shutdown");
         Services.obs.removeObserver(this, "profile-after-change");
+        Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED);
+        Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED);
+
         this.timer.cancel();
         this.timer = null;
 
         // Update stats before shutdown
         this.updateAllStats();
         break;
     }
   },
@@ -167,17 +179,17 @@ this.NetworkStatsService = {
         this._db.findAll(function onStatsFound(error, result) {
           mm.sendAsyncMessage("NetworkStats:Get:Return",
                               { id: msg.id, error: error, result: result });
         }, options);
         return;
       }
 
       for (let i in this._connectionTypes) {
-        if (this._connectionTypes[i] == options.connectionType) {
+        if (this._connectionTypes[i].name == options.connectionType) {
           this._db.find(function onStatsFound(error, result) {
             mm.sendAsyncMessage("NetworkStats:Get:Return",
                                 { id: msg.id, error: error, result: result });
           }, options);
           return;
         }
       }
 
@@ -303,55 +315,53 @@ this.NetworkStatsService = {
       return;
     }
 
     // Call the update function for the next element.
     this.update(this.updateQueue[0].type, this.processQueue.bind(this));
   },
 
   update: function update(connectionType, callback) {
-    if (DEBUG) {
-      debug("Update stats for " + this._connectionTypes[connectionType]);
-    }
-
     // Check if connection type is valid.
     if (!this._connectionTypes[connectionType]) {
       if (callback) {
         callback(false, "Invalid network type " + connectionType);
       }
       return;
     }
 
+    if (DEBUG) {
+      debug("Update stats for " + this._connectionTypes[connectionType].name);
+    }
+
     // Request stats to NetworkManager, which will get stats from netd, passing
     // 'networkStatsAvailable' as a callback.
-    if (!networkManager.getNetworkInterfaceStats(connectionType,
-                                                 this.networkStatsAvailable
-                                                     .bind(this, callback))) {
-      if (DEBUG) {
-        debug("There is no interface registered for network type " +
-              this._connectionTypes[connectionType]);
-      }
-
-      // Interface is not registered (up), so nothing to do.
-      callback(true, "OK");
+    let networkName = this._connectionTypes[connectionType].network.name;
+    if (networkName) {
+      networkManager.getNetworkInterfaceStats(networkName,
+                this.networkStatsAvailable.bind(this, callback, connectionType));
+      return;
+    }
+    if (callback) {
+      callback(true, "ok");
     }
   },
 
   /*
    * Callback of request stats. Store stats in database.
    */
-  networkStatsAvailable: function networkStatsAvailable(callback, result, connType, rxBytes, txBytes, date) {
+  networkStatsAvailable: function networkStatsAvailable(callback, connType, result, rxBytes, txBytes, date) {
     if (!result) {
       if (callback) {
         callback(false, "Netd IPC error");
       }
       return;
     }
 
-    let stats = { connectionType: this._connectionTypes[connType],
+    let stats = { connectionType: this._connectionTypes[connType].name,
                   date:           date,
                   rxBytes:        txBytes,
                   txBytes:        rxBytes};
 
     if (DEBUG) {
       debug("Update stats for " + stats.connectionType + ": rx=" + stats.rxBytes +
             " tx=" + stats.txBytes + " timestamp=" + stats.date);
     }
--- a/dom/network/tests/unit_stats/test_networkstats_db.js
+++ b/dom/network/tests/unit_stats/test_networkstats_db.js
@@ -5,17 +5,17 @@ const {classes: Cc, interfaces: Ci, util
 
 Cu.import("resource://gre/modules/NetworkStatsDB.jsm");
 
 const netStatsDb = new NetworkStatsDB(this);
 
 function filterTimestamp(date) {
   var sampleRate = netStatsDb.sampleRate;
   var offset = date.getTimezoneOffset() * 60 * 1000;
-  return Math.floor((date.getTime() - offset) / sampleRate) * sampleRate + offset;
+  return Math.floor((date.getTime() - offset) / sampleRate) * sampleRate;
 }
 
 add_test(function test_sampleRate() {
   var sampleRate = netStatsDb.sampleRate;
   do_check_true(sampleRate > 0);
   netStatsDb.sampleRate = 0;
   sampleRate = netStatsDb.sampleRate;
   do_check_true(sampleRate > 0);
@@ -330,46 +330,46 @@ function prepareFind(stats, callback) {
   });
 }
 
 add_test(function test_find () {
   var samples = 5;
   var sampleRate = netStatsDb.sampleRate;
   var start = Date.now();
   var saveDate = filterTimestamp(new Date());
-  var end = start + (sampleRate * (samples - 1));
-  start -= sampleRate;
+  var end = new Date(start + (sampleRate * (samples - 1)));
+  start = new Date(start - sampleRate);
   var stats = [];
   for (var i = 0; i < samples; i++) {i
     stats.push({connectionType: "wifi", timestamp:    saveDate + (sampleRate * i),
                 rxBytes:             0, txBytes:      10,
                 rxTotalBytes:        0, txTotalBytes: 0});
 
     stats.push({connectionType: "mobile", timestamp:  saveDate + (sampleRate * i),
                 rxBytes:             0, txBytes:      10,
                 rxTotalBytes:        0, txTotalBytes: 0});
   }
 
   prepareFind(stats, function(error, result) {
     do_check_eq(error, null);
     netStatsDb.find(function (error, result) {
       do_check_eq(error, null);
       do_check_eq(result.connectionType, "wifi");
-      do_check_eq(result.start.getTime(), start);
-      do_check_eq(result.end.getTime(), end);
+      do_check_eq(result.start.getTime(), start.getTime());
+      do_check_eq(result.end.getTime(), end.getTime());
       do_check_eq(result.data.length, samples + 1);
       do_check_eq(result.data[0].rxBytes, null);
       do_check_eq(result.data[1].rxBytes, 0);
       do_check_eq(result.data[samples].rxBytes, 0);
 
       netStatsDb.findAll(function (error, result) {
         do_check_eq(error, null);
         do_check_eq(result.connectionType, null);
-        do_check_eq(result.start.getTime(), start);
-        do_check_eq(result.end.getTime(), end);
+        do_check_eq(result.start.getTime(), start.getTime());
+        do_check_eq(result.end.getTime(), end.getTime());
         do_check_eq(result.data.length, samples + 1);
         do_check_eq(result.data[0].rxBytes, null);
         do_check_eq(result.data[1].rxBytes, 0);
         do_check_eq(result.data[1].txBytes, 20);
         do_check_eq(result.data[samples].rxBytes, 0);
         run_next_test();
       }, {start: start, end: end});
     }, {start: start, end: end, connectionType: "wifi"});
--- a/dom/network/tests/unit_stats/test_networkstats_service.js
+++ b/dom/network/tests/unit_stats/test_networkstats_service.js
@@ -10,24 +10,24 @@ add_test(function test_clearDB() {
   });
 });
 
 
 add_test(function test_networkStatsAvailable_ok() {
   NetworkStatsService.networkStatsAvailable(function (success, msg) {
     do_check_eq(success, true);
     run_next_test();
-  }, true, Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, 1234, 4321, new Date());
+  }, Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, true, 1234, 4321, new Date());
 });
 
 add_test(function test_networkStatsAvailable_failure() {
   NetworkStatsService.networkStatsAvailable(function (success, msg) {
     do_check_eq(success, false);
     run_next_test();
-  }, false, Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, 1234, 4321, new Date());
+  }, Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, false, 1234, 4321, new Date());
 });
 
 add_test(function test_update_invalidConnection() {
   NetworkStatsService.update(-1, function (success, msg) {
     do_check_eq(success, false);
     do_check_eq(msg, "Invalid network type -1");
     run_next_test();
   });
@@ -72,34 +72,41 @@ add_test(function test_updateStats_ok() 
 add_test(function test_updateStats_failure() {
   NetworkStatsService.updateStats(-1, function(success, msg){
     do_check_eq(success, false);
     run_next_test();
   });
 });
 
 add_test(function test_queue() {
+  // Fill connections with fake network interfaces (wlan0 and rmnet0)
+  // to enable netd async requests
+  NetworkStatsService._connectionTypes[Ci.nsINetworkInterface.NETWORK_TYPE_WIFI]
+                     .network.name = 'wlan0';
+  NetworkStatsService._connectionTypes[Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE]
+                     .network.name = 'rmnet0';
+
   NetworkStatsService.updateStats(Ci.nsINetworkInterface.NETWORK_TYPE_WIFI);
   NetworkStatsService.updateStats(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE);
   do_check_eq(NetworkStatsService.updateQueue.length, 2);
   do_check_eq(NetworkStatsService.updateQueue[0].callbacks.length, 1);
 
-  NetworkStatsService.updateStats(Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, function(success, msg){
-    do_check_eq(NetworkStatsService.updateQueue.length, 1);
-  });
+  var callback = function(success, msg) {
+    return;
+  };
 
-  NetworkStatsService.updateStats(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, function(success, msg){
-    do_check_eq(NetworkStatsService.updateQueue.length, 0);
-    run_next_test();
-  });
+  NetworkStatsService.updateStats(Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, callback);
+  NetworkStatsService.updateStats(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, callback);
 
   do_check_eq(NetworkStatsService.updateQueue.length, 2);
   do_check_eq(NetworkStatsService.updateQueue[0].callbacks.length, 2);
   do_check_eq(NetworkStatsService.updateQueue[0].callbacks[0], null);
   do_check_neq(NetworkStatsService.updateQueue[0].callbacks[1], null);
+
+  run_next_test();
 });
 
 function run_test() {
   do_get_profile();
 
   Cu.import("resource://gre/modules/NetworkStatsService.jsm");
   run_next_test();
 }
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -401,41 +401,33 @@ NetworkManager.prototype = {
   // Clone network info so we can still get information when network is disconnected
   _activeInfo: null,
 
   overrideActive: function overrideActive(network) {
     this._overriddenActive = network;
     this.setAndConfigureActive();
   },
 
-  getNetworkInterfaceStats: function getNetworkInterfaceStats(connectionType, callback) {
-    let iface = this.getNetworkInterface(connectionType);
-
-    if (!iface) {
-      debug("There is no interface registered for network type " + connectionType);
-      return false;
-    }
-
-    debug("getNetworkInterfaceStats for " + iface.name);
+  getNetworkInterfaceStats: function getNetworkInterfaceStats(networkName, callback) {
+    debug("getNetworkInterfaceStats for " + networkName);
 
     let params = {
       cmd: "getNetworkInterfaceStats",
-      ifname: iface.name,
-      connType: connectionType
+      ifname: networkName
     };
 
     params.report = true;
     params.isAsync = true;
 
     this.controlMessage(params, function(result) {
-      let success = result.resultCode >= NETD_COMMAND_OKAY && result.resultCode < NETD_COMMAND_ERROR;
-      callback.networkStatsAvailable(success, result.connType, result.rxBytes, result.txBytes, result.date);
+      let success = result.resultCode >= NETD_COMMAND_OKAY &&
+                    result.resultCode < NETD_COMMAND_ERROR;
+      callback.networkStatsAvailable(success, result.rxBytes,
+                                     result.txBytes, result.date);
     });
-
-    return true;
   },
 
   // Helpers
 
   controlMessage: function controlMessage(params, callback) {
     if (callback) {
       let id = callback.name;
       params.id = id;
--- a/dom/system/gonk/nsINetworkManager.idl
+++ b/dom/system/gonk/nsINetworkManager.idl
@@ -94,30 +94,29 @@ interface nsIWifiTetheringCallback : nsI
    *
    * @param error
    *        An error message if the operation wasn't successful,
    *        or `null` if it was.
    */
   void wifiTetheringEnabledChange(in jsval error);
 };
 
-[scriptable, function, uuid(9a887e18-b879-4bb1-8663-238bc4234ba0)]
+[scriptable, function, uuid(e079aa2a-ec0a-4bbd-b1a4-d81a9faae464)]
 interface nsINetworkStatsCallback : nsISupports
 {
   void networkStatsAvailable(in boolean success,
-                             in short connType,
                              in unsigned long rxBytes,
                              in unsigned long txBytes,
                              in jsval date);
 };
 
 /**
  * Manage network interfaces.
  */
-[scriptable, uuid(24f8ede0-c862-11e2-8b8b-0800200c9a66)]
+[scriptable, uuid(f39a0fb6-2752-47d2-943e-a0cdd3e43494)]
 interface nsINetworkManager : nsISupports
 {
   /**
    * Register the given network interface with the network manager.
    *
    * Consumers will be notified with the 'network-interface-registered'
    * observer notification.
    *
@@ -195,20 +194,18 @@ interface nsINetworkManager : nsISupport
   void setWifiTethering(in boolean enabled,
                         in nsINetworkInterface networkInterface,
                         in jsval config,
                         in nsIWifiTetheringCallback callback);
 
   /**
    * Retrieve network interface stats.
    *
-   * @param networkType
+   * @param networkName
    *        Select the Network interface to request estats.
    *
    * @param callback
    *        Callback to notify result and provide stats, connectionType
    *        and the date when stats are retrieved
-   *
-   * @return false if there is no interface registered for the networkType param.
    */
-  boolean getNetworkInterfaceStats(in short networkType, in nsINetworkStatsCallback callback);
+  void getNetworkInterfaceStats(in DOMString networkName, in nsINetworkStatsCallback callback);
 
 };
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -25,17 +25,19 @@
 #include <sys/ioctl.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
 
 #include "base/basictypes.h"
 #include "nscore.h"
+#ifdef MOZ_OMX_DECODER
 #include "MediaResourceManagerService.h"
+#endif
 #include "mozilla/FileUtils.h"
 #include "mozilla/Hal.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Services.h"
 #include "nsAppShell.h"
 #include "mozilla/dom/Touch.h"
 #include "nsGkAtoms.h"
 #include "nsGUIEvent.h"
@@ -635,20 +637,21 @@ nsAppShell::Init()
     int ret = pipe2(signalfds, O_NONBLOCK);
     NS_ENSURE_FALSE(ret, NS_ERROR_UNEXPECTED);
 
     rv = AddFdHandler(signalfds[0], pipeHandler, "");
     NS_ENSURE_SUCCESS(rv, rv);
 
     InitGonkMemoryPressureMonitoring();
 
+#ifdef MOZ_OMX_DECODER
     if (XRE_GetProcessType() == GeckoProcessType_Default) {
       android::MediaResourceManagerService::instantiate();
     }
-
+#endif
     nsCOMPtr<nsIObserverService> obsServ = GetObserverService();
     if (obsServ) {
         obsServ->AddObserver(this, "browser-ui-startup-complete", false);
     }
 
     // Delay initializing input devices until the screen has been
     // initialized (and we know the resolution).
     return rv;