Use native httpd instead of httpd.js (bug 728695, r=cjones).
authorAndreas Gal <gal@mozilla.com>
Sun, 19 Feb 2012 18:07:43 +0100
changeset 87156 88c69fa60ec2639cf1cedd7b8e40a55a4f08bd32
parent 87155 4d47329bb02ec69afbddaa9034abd5a15516840e
child 87157 f4010ca5f049f3dd50d9117079a89490ca13af05
push id22087
push useragal@mozilla.com
push dateSun, 19 Feb 2012 17:08:04 +0000
treeherdermozilla-central@88c69fa60ec2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs728695
milestone13.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
Use native httpd instead of httpd.js (bug 728695, r=cjones).
b2g/chrome/content/shell.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -32,31 +32,16 @@ XPCOMUtils.defineLazyGetter(Services, 'i
            .getService(Ci.nsIIdleService);
 });
 
 XPCOMUtils.defineLazyServiceGetter(Services, 'fm', function(){
   return Cc['@mozilla.org/focus-managr;1']
            .getService(Ci.nsFocusManager);
 });
 
-
-// In order to use http:// scheme instead of file:// scheme
-// (that is much more restricted) the following code kick-off
-// a local http server listening on http://127.0.0.1:7777 and
-// http://localhost:7777.
-function startupHttpd(baseDir, port) {
-  const httpdURL = 'chrome://browser/content/httpd.js';
-  let httpd = {};
-  Services.scriptloader.loadSubScript(httpdURL, httpd);
-  let server = new httpd.nsHttpServer();
-  server.registerDirectory('/', new LocalFile(baseDir));
-  server.registerContentType('appcache', 'text/cache-manifest');
-  server.start(port);
-}
-
 // FIXME Bug 707625
 // until we have a proper security model, add some rights to
 // the pre-installed web applications
 // XXX never grant 'content-camera' to non-gaia apps
 function addPermissions(urls) {
   let permissions = [
     'indexedDB', 'indexedDB-unlimited', 'webapps-manage', 'offline-app', 'content-camera'
   ];
@@ -65,17 +50,16 @@ function addPermissions(urls) {
     let allow = Ci.nsIPermissionManager.ALLOW_ACTION;
 
     permissions.forEach(function(permission) {
       Services.perms.add(uri, permission, allow);
     });
   });
 }
 
-
 var shell = {
   // FIXME/bug 678695: this should be a system setting
   preferredScreenBrightness: 1.0,
   
   isDebug: false,
 
   get contentBrowser() {
     delete this.contentBrowser;
@@ -116,40 +100,30 @@ var shell = {
     window.addEventListener('mozfullscreenchange', this);
     this.contentBrowser.addEventListener('load', this, true);
 
     try {
       Services.io.offline = false;
 
       let fileScheme = 'file://';
       if (homeURL.substring(0, fileScheme.length) == fileScheme) {
-        homeURL = homeURL.replace(fileScheme, '');
-
-        let baseDir = homeURL.split('/');
-        baseDir.pop();
-        baseDir = baseDir.join('/');
-
-        const SERVER_PORT = 6666;
-        startupHttpd(baseDir, SERVER_PORT);
-
-        let baseHost = 'http://localhost';
-        homeURL = homeURL.replace(baseDir, baseHost + ':' + SERVER_PORT);
+        homeURL = 'http://localhost:7777' + homeURL.replace(fileScheme, '');
       }
       addPermissions([homeURL]);
     } catch (e) {
       let msg = 'Fatal error during startup: [' + e + '[' + homeURL + ']';
       return alert(msg);
     }
 
-    // Load webapi+apps.js as a frame script
+    // Load webapi.js as a frame script
     let frameScriptUrl = 'chrome://browser/content/webapi.js';
     try {
       messageManager.loadFrameScript(frameScriptUrl, true);
     } catch (e) {
-      dump('Error when loading ' + frameScriptUrl + ' as a frame script: ' + e + '\n');
+      dump('Error loading ' + frameScriptUrl + ' as a frame script: ' + e + '\n');
     }
 
     let browser = this.contentBrowser;
     browser.homePage = homeURL;
     browser.goHome();
   },
 
   stop: function shell_stop() {