Bug 1019194 part 1. Get rid of nsIIndexedDatabaseManager. r=paul,khuey,mossop
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 17 Jun 2014 15:01:47 -0400
changeset 189156 94b80abc44b5e109af335b23bd26d47c180781de
parent 189155 76486dd239b0aa0ec9aafea92f0ac6b0f4e10f79
child 189157 4b4e5289a82a20c968347ec690c4ed3806562efb
push id26977
push userkwierso@gmail.com
push dateWed, 18 Jun 2014 01:21:03 +0000
treeherdermozilla-central@73679988dd7f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul, khuey, mossop
bugs1019194
milestone33.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 1019194 part 1. Get rid of nsIIndexedDatabaseManager. r=paul,khuey,mossop
addon-sdk/source/lib/sdk/indexed-db.js
b2g/installer/package-manifest.in
browser/devtools/app-manager/app-projects.js
browser/installer/package-manifest.in
dom/indexedDB/IndexedDatabaseManager.cpp
dom/indexedDB/IndexedDatabaseManager.h
dom/indexedDB/moz.build
dom/indexedDB/nsIIndexedDatabaseManager.idl
js/xpconnect/src/dom_quickstubs.qsconf
mobile/android/installer/package-manifest.in
toolkit/devtools/server/actors/storage.js
--- a/addon-sdk/source/lib/sdk/indexed-db.js
+++ b/addon-sdk/source/lib/sdk/indexed-db.js
@@ -22,37 +22,26 @@ let sanitizeId = function(id){
     replace(/\./g, "-dot-").
     replace(uuidRe, "$1");
 
   return domain
 };
 
 const PSEUDOURI = "indexeddb://" + sanitizeId(id) // https://bugzilla.mozilla.org/show_bug.cgi?id=779197
 
-// Firefox 26 and earlier releases don't support `indexedDB` in sandboxes
-// automatically, so we need to inject `indexedDB` to `this` scope ourselves.
-if (typeof(indexedDB) === "undefined") {
-  Cc["@mozilla.org/dom/indexeddb/manager;1"].
-    getService(Ci.nsIIndexedDatabaseManager).
-    initWindowless(this);
-
-  // Firefox 14 gets this with a prefix
-  if (typeof(indexedDB) === "undefined")
-    this.indexedDB = mozIndexedDB;
-}
-
 // Use XPCOM because `require("./url").URL` doesn't expose the raw uri object.
 let principaluri = Cc["@mozilla.org/network/io-service;1"].
               getService(Ci.nsIIOService).
               newURI(PSEUDOURI, null, null);
 
 let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
 	               getService(Ci.nsIScriptSecurityManager).
 	               getCodebasePrincipal(principaluri);
 
 exports.indexedDB = Object.freeze({
   open: indexedDB.openForPrincipal.bind(indexedDB, principal),
+  openForPrincipal: indexedDB.openForPrincipal.bind(indexedDB),
   deleteDatabase: indexedDB.deleteForPrincipal.bind(indexedDB, principal),
-  cmp: indexedDB.cmp
+  cmp: indexedDB.cmp.bind(indexedDB)
 });
 
 exports.IDBKeyRange = IDBKeyRange;
 exports.DOMException = Ci.nsIDOMDOMException;
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -183,17 +183,16 @@
 @BINPATH@/components/dom_geolocation.xpt
 @BINPATH@/components/dom_media.xpt
 @BINPATH@/components/dom_network.xpt
 #ifdef MOZ_NFC
 @BINPATH@/components/dom_nfc.xpt
 #endif
 @BINPATH@/components/dom_notification.xpt
 @BINPATH@/components/dom_html.xpt
-@BINPATH@/components/dom_indexeddb.xpt
 @BINPATH@/components/dom_offline.xpt
 @BINPATH@/components/dom_payment.xpt
 @BINPATH@/components/dom_json.xpt
 @BINPATH@/components/dom_messages.xpt
 @BINPATH@/components/dom_power.xpt
 @BINPATH@/components/dom_quota.xpt
 @BINPATH@/components/dom_range.xpt
 @BINPATH@/components/dom_settings.xpt
--- a/browser/devtools/app-manager/app-projects.js
+++ b/browser/devtools/app-manager/app-projects.js
@@ -1,34 +1,31 @@
 const {Cc,Ci,Cu,Cr} = require("chrome");
 const ObservableObject = require("devtools/shared/observable-object");
 const promise = require("devtools/toolkit/deprecated-sync-thenables");
 
 const {EventEmitter} = Cu.import("resource://gre/modules/devtools/event-emitter.js");
 const {generateUUID} = Cc['@mozilla.org/uuid-generator;1'].getService(Ci.nsIUUIDGenerator);
 const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
+const { indexedDB } = require("sdk/indexed-db");
 
 /**
  * IndexedDB wrapper that just save project objects
  *
  * The only constraint is that project objects have to have
  * a unique `location` object.
  */
 
 const global = this;
 const IDB = {
   _db: null,
 
   open: function () {
     let deferred = promise.defer();
 
-    var idbManager = Cc["@mozilla.org/dom/indexeddb/manager;1"]
-                       .getService(Ci.nsIIndexedDatabaseManager);
-    idbManager.initWindowless(global);
-
     let request = global.indexedDB.open("AppProjects", 5);
     request.onerror = function(event) {
       deferred.reject("Unable to open AppProjects indexedDB. " +
                       "Error code: " + event.target.errorCode);
     };
     request.onupgradeneeded = function(event) {
       let db = event.target.result;
       db.createObjectStore("projects", { keyPath: "location" });
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -197,17 +197,16 @@
 @BINPATH@/components/dom_css.xpt
 @BINPATH@/components/dom_devicestorage.xpt
 @BINPATH@/components/dom_events.xpt
 @BINPATH@/components/dom_geolocation.xpt
 @BINPATH@/components/dom_media.xpt
 @BINPATH@/components/dom_network.xpt
 @BINPATH@/components/dom_notification.xpt
 @BINPATH@/components/dom_html.xpt
-@BINPATH@/components/dom_indexeddb.xpt
 @BINPATH@/components/dom_offline.xpt
 @BINPATH@/components/dom_json.xpt
 @BINPATH@/components/dom_power.xpt
 @BINPATH@/components/dom_quota.xpt
 @BINPATH@/components/dom_range.xpt
 @BINPATH@/components/dom_settings.xpt
 @BINPATH@/components/dom_permissionsettings.xpt
 @BINPATH@/components/dom_sidebar.xpt
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -641,46 +641,17 @@ IndexedDatabaseManager::BlockAndGetFileR
                                                         aSliceRefCnt, aResult);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 NS_IMPL_ADDREF(IndexedDatabaseManager)
 NS_IMPL_RELEASE_WITH_DESTROY(IndexedDatabaseManager, Destroy())
-NS_IMPL_QUERY_INTERFACE(IndexedDatabaseManager, nsIIndexedDatabaseManager,
-                        nsIObserver)
-
-NS_IMETHODIMP
-IndexedDatabaseManager::InitWindowless(JS::Handle<JS::Value> aGlobal, JSContext* aCx)
-{
-  NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
-
-  JS::Rooted<JSObject*> global(aCx, aGlobal.toObjectOrNull());
-  if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
-    NS_WARNING("Passed object is not a global object!");
-    return NS_ERROR_FAILURE;
-  }
-
-  bool hasIndexedDB;
-  if (!JS_HasProperty(aCx, global, IDB_STR, &hasIndexedDB)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  if (hasIndexedDB) {
-    NS_WARNING("Passed object already has an 'indexedDB' property!");
-    return NS_ERROR_FAILURE;
-  }
-
-  if (!DefineIndexedDB(aCx, global)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  return NS_OK;
-}
+NS_IMPL_QUERY_INTERFACE(IndexedDatabaseManager, nsIObserver)
 
 NS_IMETHODIMP
 IndexedDatabaseManager::Observe(nsISupports* aSubject, const char* aTopic,
                                 const char16_t* aData)
 {
   NS_ASSERTION(IsMainProcess(), "Wrong process!");
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
--- a/dom/indexedDB/IndexedDatabaseManager.h
+++ b/dom/indexedDB/IndexedDatabaseManager.h
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_indexeddb_indexeddatabasemanager_h__
 #define mozilla_dom_indexeddb_indexeddatabasemanager_h__
 
 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
 
-#include "nsIIndexedDatabaseManager.h"
 #include "nsIObserver.h"
 
 #include "js/TypeDecls.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/dom/quota/PersistenceType.h"
 #include "mozilla/Mutex.h"
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
@@ -33,25 +32,23 @@ class OriginOrPatternString;
 }
 }
 
 BEGIN_INDEXEDDB_NAMESPACE
 
 class FileManager;
 class FileManagerInfo;
 
-class IndexedDatabaseManager MOZ_FINAL : public nsIIndexedDatabaseManager,
-                                         public nsIObserver
+class IndexedDatabaseManager MOZ_FINAL : public nsIObserver
 {
   typedef mozilla::dom::quota::OriginOrPatternString OriginOrPatternString;
   typedef mozilla::dom::quota::PersistenceType PersistenceType;
 
 public:
   NS_DECL_ISUPPORTS
-  NS_DECL_NSIINDEXEDDATABASEMANAGER
   NS_DECL_NSIOBSERVER
 
   // Returns a non-owning reference.
   static IndexedDatabaseManager*
   GetOrCreate();
 
   // Returns a non-owning reference.
   static IndexedDatabaseManager*
--- a/dom/indexedDB/moz.build
+++ b/dom/indexedDB/moz.build
@@ -2,22 +2,16 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DIRS += ['ipc']
 TEST_DIRS += ['test']
 
-XPIDL_SOURCES += [
-    'nsIIndexedDatabaseManager.idl',
-]
-
-XPIDL_MODULE = 'dom_indexeddb'
-
 EXPORTS.mozilla.dom.indexedDB += [
     'Client.h',
     'DatabaseInfo.h',
     'FileInfo.h',
     'FileManager.h',
     'IDBCursor.h',
     'IDBDatabase.h',
     'IDBEvents.h',
deleted file mode 100644
--- a/dom/indexedDB/nsIIndexedDatabaseManager.idl
+++ /dev/null
@@ -1,25 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-[scriptable, builtinclass, uuid(538d1085-517e-405a-a0f0-eb575cb0b8e5)]
-interface nsIIndexedDatabaseManager : nsISupports
-{
-  /**
-   * Defines indexedDB and IDBKeyRange with its static functions on aGlobal.
-   *
-   * This method might go away some time in the future, indexedDB and
-   * IDBKeyRange should now be defined in all the spots (content windows,
-   * chrome windows, xpcshell, JS modules, JS components, JS sandboxes,
-   * ipcshell, bootstrapped extensions and Jetpack)
-   *
-   * @param aGlobal
-   *        The global object, indexedDB and IDBKeyRange should be defined on.
-   */
-  [implicit_jscontext]
-  void initWindowless(in jsval aGlobal);
-};
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -56,31 +56,27 @@ members = [
     # layout/xul/base/public
     'nsIBoxObject.x',
     'nsIBoxObject.y',
     'nsIBoxObject.screenX',
     'nsIBoxObject.screenY',
     'nsIBoxObject.width',
     'nsIBoxObject.height',
 
-    # dom/indexedDB
-    'nsIIndexedDatabaseManager.*',
     ]
 
 # Most interfaces can be found by searching the includePath; to find
 # nsIDOMEvent, for example, just look for nsIDOMEvent.idl.  But IDL filenames
 # for very long interface names are slightly abbreviated, and many interfaces
 # don't have their own files, just for extra wackiness.  So qsgen.py needs
 # a little help.
 #
 irregularFilenames = {
     # stowaways
     'nsIDOMBlob': 'nsIDOMFile',
-    'nsIIndexedDatabaseUsageCallback': 'nsIIndexedDatabaseManager',
-    'nsITelephoneCallback': 'nsITelephone',
     }
 
 customIncludes = [
     'mozilla/dom/BindingUtils.h',
     'mozilla/dom/EventTargetBinding.h',
     'mozilla/dom/WindowBinding.h',
     ]
 
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -142,17 +142,16 @@
 @BINPATH@/components/dom_devicestorage.xpt
 @BINPATH@/components/dom_events.xpt
 @BINPATH@/components/dom_geolocation.xpt
 @BINPATH@/components/dom_media.xpt
 @BINPATH@/components/dom_messages.xpt
 @BINPATH@/components/dom_network.xpt
 @BINPATH@/components/dom_notification.xpt
 @BINPATH@/components/dom_html.xpt
-@BINPATH@/components/dom_indexeddb.xpt
 @BINPATH@/components/dom_offline.xpt
 @BINPATH@/components/dom_json.xpt
 @BINPATH@/components/dom_payment.xpt
 @BINPATH@/components/dom_power.xpt
 @BINPATH@/components/dom_quota.xpt
 @BINPATH@/components/dom_range.xpt
 @BINPATH@/components/dom_settings.xpt
 @BINPATH@/components/dom_permissionsettings.xpt
--- a/toolkit/devtools/server/actors/storage.js
+++ b/toolkit/devtools/server/actors/storage.js
@@ -2,16 +2,22 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {Cu, Cc, Ci} = require("chrome");
 const events = require("sdk/event/core");
 const protocol = require("devtools/server/protocol");
+try {
+    const { indexedDB } = require("sdk/indexed-db");
+} catch (e) {
+    // In xpcshell tests, we can't actually have indexedDB, which is OK:
+    // we don't use it there anyway.
+}
 const {async} = require("devtools/async-utils");
 const {Arg, Option, method, RetVal, types} = protocol;
 const {LongStringActor, ShortLongString} = require("devtools/server/actors/string");
 
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
@@ -925,21 +931,16 @@ DatabaseMetadata.prototype = {
 };
 
 StorageActors.createActor({
   typeName: "indexedDB",
   storeObjectType: "idbstoreobject"
 }, {
   initialize: function(storageActor) {
     protocol.Actor.prototype.initialize.call(this, null);
-    if (!global.indexedDB) {
-      let idbManager = Cc["@mozilla.org/dom/indexeddb/manager;1"]
-                         .getService(Ci.nsIIndexedDatabaseManager);
-      idbManager.initWindowless(global);
-    }
     this.objectsSize = {};
     this.storageActor = storageActor;
     this.onWindowReady = this.onWindowReady.bind(this);
     this.onWindowDestroyed = this.onWindowDestroyed.bind(this);
     events.on(this.storageActor, "window-ready", this.onWindowReady);
     events.on(this.storageActor, "window-destroyed", this.onWindowDestroyed);
   },