Backout changeset 592bfc94e628 for X orange.

This commit is contained in:
Ms2ger 2012-07-14 11:23:52 +02:00
Родитель 37b72d7ab0
Коммит dc5ed62122
17 изменённых файлов: 22 добавлений и 306 удалений

Просмотреть файл

@ -9,16 +9,9 @@
#include "IDBFactory.h"
#include "nsIFile.h"
#include "nsIJSContextStack.h"
#include "nsIPrincipal.h"
#include "nsIScriptContext.h"
#include "nsIXPConnect.h"
#include "nsIXPCScriptable.h"
#include "jsdbgapi.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/PBrowserChild.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/storage.h"
#include "nsComponentManagerUtils.h"
#include "nsIScriptSecurityManager.h"
@ -41,13 +34,14 @@
#include "IndexedDatabaseManager.h"
#include "Key.h"
#include "mozilla/dom/PBrowserChild.h"
#include "mozilla/dom/TabChild.h"
using mozilla::dom::TabChild;
#include "ipc/IndexedDBChild.h"
USING_INDEXEDDB_NAMESPACE
using mozilla::dom::ContentChild;
using mozilla::dom::TabChild;
namespace {
struct ObjectStoreInfoMap
@ -62,8 +56,7 @@ struct ObjectStoreInfoMap
} // anonymous namespace
IDBFactory::IDBFactory()
: mOwningObject(nsnull), mActorChild(nsnull), mActorParent(nsnull),
mRootedOwningObject(false)
: mOwningObject(nsnull), mActorChild(nsnull), mActorParent(nsnull)
{
}
@ -75,9 +68,6 @@ IDBFactory::~IDBFactory()
mActorChild->Send__delete__(mActorChild);
NS_ASSERTION(!mActorChild, "Should have cleared in Send__delete__!");
}
if (mRootedOwningObject) {
NS_DROP_JS_OBJECTS(this, IDBFactory);
}
}
// static
@ -163,92 +153,6 @@ IDBFactory::Create(JSContext* aCx,
factory->mASCIIOrigin = origin;
factory->mOwningObject = aOwningObject;
if (!IndexedDatabaseManager::IsMainProcess()) {
ContentChild* contentChild = ContentChild::GetSingleton();
NS_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IndexedDBChild* actor = new IndexedDBChild(origin);
contentChild->SendPIndexedDBConstructor(actor);
actor->SetFactory(factory);
}
factory.forget(aFactory);
return NS_OK;
}
// static
nsresult
IDBFactory::Create(IDBFactory** aFactory)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
NS_ASSERTION(nsContentUtils::IsCallerChrome(), "Only for chrome!");
#ifdef DEBUG
{
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
NS_ASSERTION(cxStack, "Couldn't get ThreadJSContextStack!");
JSContext* lastCx;
if (NS_SUCCEEDED(cxStack->Peek(&lastCx))) {
NS_ASSERTION(!lastCx, "We should only be called from C++!");
}
else {
NS_ERROR("nsIThreadJSContextStack::Peek should never fail!");
}
}
#endif
nsCString origin;
nsresult rv =
IndexedDatabaseManager::GetASCIIOriginFromWindow(nsnull, origin);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal =
do_CreateInstance("@mozilla.org/nullprincipal;1");
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
JSContext* cx = nsContentUtils::GetSafeJSContext();
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
nsCxPusher pusher;
if (!pusher.Push(cx)) {
NS_WARNING("Failed to push safe JS context!");
return NS_ERROR_FAILURE;
}
JSAutoRequest ar(cx);
nsIXPConnect* xpc = nsContentUtils::XPConnect();
NS_ASSERTION(xpc, "This should never be null!");
nsCOMPtr<nsIXPConnectJSObjectHolder> globalHolder;
rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(globalHolder));
NS_ENSURE_SUCCESS(rv, rv);
JSObject* global;
rv = globalHolder->GetJSObject(&global);
NS_ENSURE_SUCCESS(rv, rv);
// The CreateSandbox call returns a proxy to the actual sandbox object. We
// don't need a proxy here.
global = JS_UnwrapObject(global);
JSAutoEnterCompartment ac;
if (!ac.enter(cx, global)) {
NS_WARNING("Failed to enter compartment!");
return NS_ERROR_FAILURE;
}
nsRefPtr<IDBFactory> factory;
rv = Create(cx, global, getter_AddRefs(factory));
NS_ENSURE_SUCCESS(rv, rv);
NS_HOLD_JS_OBJECTS(factory, IDBFactory);
factory->mRootedOwningObject = true;
factory.forget(aFactory);
return NS_OK;
}
@ -485,10 +389,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBFactory)
if (tmp->mOwningObject) {
tmp->mOwningObject = nsnull;
}
if (tmp->mRootedOwningObject) {
NS_DROP_JS_OBJECTS(tmp, IDBFactory);
tmp->mRootedOwningObject = false;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mWindow)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

Просмотреть файл

@ -36,12 +36,10 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
NS_DECL_NSIIDBFACTORY
// Called when using IndexedDB from a window in a different process.
static nsresult Create(nsPIDOMWindow* aWindow,
const nsACString& aASCIIOrigin,
IDBFactory** aFactory);
// Called when using IndexedDB from a window in the current process.
static nsresult Create(nsPIDOMWindow* aWindow,
nsIIDBFactory** aFactory)
{
@ -53,16 +51,10 @@ public:
return NS_OK;
}
// Called when using IndexedDB from a JS component or a JSM in the current
// process.
static nsresult Create(JSContext* aCx,
JSObject* aOwningObject,
IDBFactory** aFactory);
// Called when using IndexedDB from a JS component or a JSM in a different
// process.
static nsresult Create(IDBFactory** aFactory);
static already_AddRefed<mozIStorageConnection>
GetConnection(const nsAString& aDatabaseFilePath);
@ -98,12 +90,6 @@ public:
mActorParent = aActorParent;
}
const nsCString&
GetASCIIOrigin() const
{
return mASCIIOrigin;
}
private:
IDBFactory();
~IDBFactory();
@ -117,8 +103,6 @@ private:
IndexedDBChild* mActorChild;
IndexedDBParent* mActorParent;
bool mRootedOwningObject;
};
END_INDEXEDDB_NAMESPACE

Просмотреть файл

@ -22,7 +22,6 @@
namespace mozilla {
namespace dom {
class ContentParent;
class TabParent;
}
}
@ -130,7 +129,6 @@ public:
class IndexedDBParent : public PIndexedDBParent
{
friend class mozilla::dom::ContentParent;
friend class mozilla::dom::TabParent;
nsRefPtr<IDBFactory> mFactory;

Просмотреть файл

@ -31,20 +31,10 @@ LOCAL_INCLUDES += \
DEFINES += -D_IMPL_NS_LAYOUT
MOCHITEST_FILES = test_ipc.html
XPCSHELL_TESTS = unit
# We're copying tests from another directory so this check is wrong for us.
NO_XPCSHELL_MANIFEST_CHECK = 1
MOCHITEST_FILES = \
test_ipc.html \
$(NULL)
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk
# Copy all the normal xpcshell tests from the regular unit directory.
copy-xpcshell-tests:
$(DIR_INSTALL) $(wildcard $(topsrcdir)/dom/indexedDB/test/unit/test_*.js) \
$(testxpcobjdir)/$(relativesrcdir)/$(XPCSHELL_TESTS)
libs-xpcshell-tests: copy-xpcshell-tests

Просмотреть файл

@ -3,7 +3,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBrowser;
include protocol PContent;
include protocol PIndexedDBDatabase;
include protocol PIndexedDBDeleteDatabaseRequest;
@ -13,7 +12,7 @@ namespace indexedDB {
protocol PIndexedDB
{
manager PBrowser or PContent;
manager PBrowser;
manages PIndexedDBDatabase;
manages PIndexedDBDeleteDatabaseRequest;

Просмотреть файл

@ -1,18 +0,0 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const INDEXEDDB_UNIT_DIR = "../../test/unit/";
const INDEXEDDB_HEAD_FILE = INDEXEDDB_UNIT_DIR + "head.js";
function run_test() {
// IndexedDB needs a profile.
do_get_profile();
let thisTest = _TEST_FILE.toString().replace(/\\/g, "/");
thisTest = thisTest.substring(thisTest.lastIndexOf("/") + 1);
_HEAD_FILES.push(do_get_file(INDEXEDDB_HEAD_FILE).path.replace(/\\/g, "/"));
run_test_in_child(INDEXEDDB_UNIT_DIR + thisTest);
}

Просмотреть файл

@ -1,60 +0,0 @@
[DEFAULT]
head = head.js
tail =
# When adding files here please also update test/unit/xpcshell.ini!
[test_add_put.js]
[test_add_twice_failure.js]
[test_advance.js]
[test_autoIncrement_indexes.js]
[test_clear.js]
[test_complex_keyPaths.js]
[test_count.js]
[test_create_index.js]
[test_create_index_with_integer_keys.js]
[test_create_objectStore.js]
[test_cursor_mutation.js]
[test_cursor_update_updates_indexes.js]
[test_cursors.js]
[test_deleteDatabase.js]
[test_event_source.js]
[test_getAll.js]
[test_global_data.js]
[test_index_empty_keyPath.js]
[test_index_getAll.js]
[test_index_getAllObjects.js]
[test_index_object_cursors.js]
[test_index_update_delete.js]
[test_indexes.js]
[test_indexes_bad_values.js]
[test_key_requirements.js]
[test_keys.js]
[test_multientry.js]
[test_names_sorted.js]
[test_object_identity.js]
[test_objectCursors.js]
[test_objectStore_inline_autoincrement_key_added_on_put.js]
[test_objectStore_remove_values.js]
[test_odd_result_order.js]
[test_open_empty_db.js]
[test_open_objectStore.js]
[test_optionalArguments.js]
[test_overlapping_transactions.js]
[test_put_get_values.js]
[test_put_get_values_autoIncrement.js]
[test_remove_index.js]
[test_remove_objectStore.js]
[test_request_readyState.js]
[test_setVersion.js]
[test_setVersion_abort.js]
[test_setVersion_events.js]
[test_setVersion_exclusion.js]
[test_success_events_after_abort.js]
[test_traffic_jam.js]
[test_transaction_abort.js]
[test_transaction_lifetimes.js]
[test_transaction_lifetimes_nested.js]
[test_transaction_ordering.js]
# When adding files here please also update test/unit/xpcshell.ini!

Просмотреть файл

@ -7,11 +7,10 @@ topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/indexedDB/test
DIRS += unit
include $(DEPTH)/config/autoconf.mk
TEST_DIRS = unit
XPCSHELL_TESTS = unit
MOCHITEST_FILES = \
@ -126,3 +125,4 @@ MOCHITEST_BROWSER_FILES = \
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -16,6 +16,13 @@ const IDBIndex = Ci.nsIIDBIndex
const IDBObjectStore = Ci.nsIIDBObjectStore
const IDBRequest = Ci.nsIIDBRequest
// XPCShell does not get a profile by default.
do_get_profile();
var idbManager = Cc["@mozilla.org/dom/indexeddb/manager;1"].
getService(Ci.nsIIndexedDatabaseManager);
idbManager.initWindowless(this);
function is(a, b, msg) {
dump("is(" + a + ", " + b + ", \"" + msg + "\")");
do_check_eq(a, b, Components.stack.caller);
@ -45,13 +52,6 @@ function run_test() {
function runTest()
{
// XPCShell does not get a profile by default.
do_get_profile();
var idbManager = Cc["@mozilla.org/dom/indexeddb/manager;1"].
getService(Ci.nsIIndexedDatabaseManager);
idbManager.initWindowless(this);
do_test_pending();
testGenerator.next();
}

Просмотреть файл

@ -1,8 +1,6 @@
[DEFAULT]
head = head.js
tail =
# When adding files here please also update ipc/unit/xpcshell.ini!
head = head_idb.js
tail =
[test_add_put.js]
[test_add_twice_failure.js]
@ -55,6 +53,4 @@ tail =
[test_transaction_abort.js]
[test_transaction_lifetimes.js]
[test_transaction_lifetimes_nested.js]
[test_transaction_ordering.js]
# When adding files here please also update ipc/unit/xpcshell.ini!
[test_transaction_ordering.js]

Просмотреть файл

@ -88,7 +88,6 @@ using namespace mozilla::places;
using namespace mozilla::docshell;
using namespace mozilla::dom::devicestorage;
using namespace mozilla::dom::sms;
using namespace mozilla::dom::indexedDB;
namespace mozilla {
namespace dom {
@ -430,20 +429,6 @@ ContentChild::DeallocPHal(PHalChild* aHal)
return true;
}
PIndexedDBChild*
ContentChild::AllocPIndexedDB()
{
NS_NOTREACHED("Should never get here!");
return NULL;
}
bool
ContentChild::DeallocPIndexedDB(PIndexedDBChild* aActor)
{
delete aActor;
return true;
}
PTestShellChild*
ContentChild::AllocPTestShell()
{

Просмотреть файл

@ -71,9 +71,6 @@ public:
NS_OVERRIDE virtual PHalChild* AllocPHal();
NS_OVERRIDE virtual bool DeallocPHal(PHalChild*);
virtual PIndexedDBChild* AllocPIndexedDB();
virtual bool DeallocPIndexedDB(PIndexedDBChild* aActor);
virtual PMemoryReportRequestChild*
AllocPMemoryReportRequest();

Просмотреть файл

@ -79,10 +79,6 @@
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
#include "nsDebugImpl.h"
#include "IDBFactory.h"
#include "IndexedDatabaseManager.h"
#include "IndexedDBParent.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h"
#include "mozilla/Preferences.h"
@ -99,7 +95,6 @@ using mozilla::unused; // heh
using base::KillProcess;
using namespace mozilla::dom::devicestorage;
using namespace mozilla::dom::sms;
using namespace mozilla::dom::indexedDB;
namespace mozilla {
namespace dom {
@ -834,42 +829,6 @@ ContentParent::DeallocPHal(PHalParent* aHal)
return true;
}
PIndexedDBParent*
ContentParent::AllocPIndexedDB()
{
return new IndexedDBParent();
}
bool
ContentParent::DeallocPIndexedDB(PIndexedDBParent* aActor)
{
delete aActor;
return true;
}
bool
ContentParent::RecvPIndexedDBConstructor(PIndexedDBParent* aActor)
{
nsRefPtr<IndexedDatabaseManager> mgr = IndexedDatabaseManager::GetOrCreate();
NS_ENSURE_TRUE(mgr, false);
if (!IndexedDatabaseManager::IsMainProcess()) {
NS_RUNTIMEABORT("Not supported yet!");
}
nsRefPtr<IDBFactory> factory;
nsresult rv = IDBFactory::Create(getter_AddRefs(factory));
NS_ENSURE_SUCCESS(rv, false);
NS_ASSERTION(factory, "This should never be null!");
IndexedDBParent* actor = static_cast<IndexedDBParent*>(aActor);
actor->mFactory = factory;
actor->mASCIIOrigin = factory->GetASCIIOrigin();
return true;
}
PMemoryReportRequestParent*
ContentParent::AllocPMemoryReportRequest()
{

Просмотреть файл

@ -123,13 +123,6 @@ private:
NS_OVERRIDE virtual PHalParent* AllocPHal();
NS_OVERRIDE virtual bool DeallocPHal(PHalParent*);
virtual PIndexedDBParent* AllocPIndexedDB();
virtual bool DeallocPIndexedDB(PIndexedDBParent* aActor);
virtual bool
RecvPIndexedDBConstructor(PIndexedDBParent* aActor);
virtual PMemoryReportRequestParent* AllocPMemoryReportRequest();
virtual bool DeallocPMemoryReportRequest(PMemoryReportRequestParent* actor);

Просмотреть файл

@ -10,7 +10,6 @@ include protocol PCrashReporter;
include protocol PExternalHelperApp;
include protocol PDeviceStorageRequest;
include protocol PHal;
include protocol PIndexedDB;
include protocol PMemoryReportRequest;
include protocol PNecko;
include protocol PSms;
@ -103,7 +102,6 @@ rpc protocol PContent
manages PDeviceStorageRequest;
manages PExternalHelperApp;
manages PHal;
manages PIndexedDB;
manages PMemoryReportRequest;
manages PNecko;
manages PSms;
@ -169,8 +167,6 @@ parent:
PHal();
PIndexedDB();
PNecko();
PSms();

Просмотреть файл

@ -244,7 +244,7 @@ protected:
virtual PIndexedDBChild* AllocPIndexedDB(const nsCString& aASCIIOrigin,
bool* /* aAllowed */);
virtual bool DeallocPIndexedDB(PIndexedDBChild* aActor);
virtual bool DeallocPIndexedDB(PIndexedDBChild* actor);
private:
void ActorDestroy(ActorDestroyReason why);

Просмотреть файл

@ -128,6 +128,3 @@ run-if.config = ipc
skip-if = os == "android"
[include:tools/profiler/tests/xpcshell.ini]
[include:dom/indexedDB/ipc/unit/xpcshell.ini]
run-if.config = ipc && os != "mac"