mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1019194 part 1. Get rid of nsIIndexedDatabaseManager. r=paul,khuey,mossop
This commit is contained in:
parent
cc2ba4f0a5
commit
3a5702d71d
@ -27,18 +27,6 @@ let sanitizeId = function(id){
|
||||
|
||||
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).
|
||||
@ -50,8 +38,9 @@ let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
|
||||
|
||||
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;
|
||||
|
@ -188,7 +188,6 @@
|
||||
#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
|
||||
|
@ -5,6 +5,7 @@ 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
|
||||
@ -20,10 +21,6 @@ const IDB = {
|
||||
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. " +
|
||||
|
@ -202,7 +202,6 @@
|
||||
@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
|
||||
|
@ -646,36 +646,7 @@ IndexedDatabaseManager::BlockAndGetFileReferences(
|
||||
|
||||
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,
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
||||
|
||||
#include "nsIIndexedDatabaseManager.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
@ -38,15 +37,13 @@ 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.
|
||||
|
@ -7,12 +7,6 @@
|
||||
DIRS += ['ipc']
|
||||
TEST_DIRS += ['test']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIIndexedDatabaseManager.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_indexeddb'
|
||||
|
||||
EXPORTS.mozilla.dom.indexedDB += [
|
||||
'Client.h',
|
||||
'DatabaseInfo.h',
|
||||
|
@ -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);
|
||||
};
|
@ -61,8 +61,6 @@ members = [
|
||||
'nsIBoxObject.width',
|
||||
'nsIBoxObject.height',
|
||||
|
||||
# dom/indexedDB
|
||||
'nsIIndexedDatabaseManager.*',
|
||||
]
|
||||
|
||||
# Most interfaces can be found by searching the includePath; to find
|
||||
@ -74,8 +72,6 @@ members = [
|
||||
irregularFilenames = {
|
||||
# stowaways
|
||||
'nsIDOMBlob': 'nsIDOMFile',
|
||||
'nsIIndexedDatabaseUsageCallback': 'nsIIndexedDatabaseManager',
|
||||
'nsITelephoneCallback': 'nsITelephone',
|
||||
}
|
||||
|
||||
customIncludes = [
|
||||
|
@ -147,7 +147,6 @@
|
||||
@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
|
||||
|
@ -7,6 +7,12 @@
|
||||
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");
|
||||
@ -930,11 +936,6 @@ StorageActors.createActor({
|
||||
}, {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user