author | Bobby Holley <bobbyholley@gmail.com> |
Thu, 18 Apr 2013 11:36:05 -0400 | |
changeset 140996 | dd382d615402a519130ac52d50cfebed5cec8041 |
parent 140995 | c14d7d33f3e7871120be9e1f6f5a2d3ac3f2fe06 |
child 140997 | 4be115c79b5074791fa76d6faab66f90a9c9849a |
push id | 350 |
push user | bbajaj@mozilla.com |
push date | Mon, 29 Jul 2013 23:00:49 +0000 |
treeherder | mozilla-release@064965b37dbd [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gabor |
bugs | 860438 |
milestone | 23.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
|
ipc/testshell/XPCShellEnvironment.cpp | file | annotate | diff | comparison | revisions | |
ipc/testshell/XPCShellEnvironment.h | file | annotate | diff | comparison | revisions |
--- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -21,24 +21,24 @@ #include "XPCShellEnvironment.h" #include "mozilla/XPCOM.h" #include "nsIChannel.h" #include "nsIClassInfo.h" #include "nsIDirectoryService.h" -#include "nsIJSContextStack.h" #include "nsIJSRuntimeService.h" #include "nsIPrincipal.h" #include "nsIScriptSecurityManager.h" #include "nsIURI.h" #include "nsIXPConnect.h" #include "nsIXPCScriptable.h" +#include "nsContentUtils.h" #include "nsJSUtils.h" #include "nsJSPrincipals.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" #include "BackstagePass.h" #include "TestShellChild.h" @@ -524,17 +524,18 @@ typedef enum JSShellErrNum static void ProcessFile(JSContext *cx, JSObject *obj, const char *filename, FILE *file, JSBool forceTTY) { XPCShellEnvironment* env = Environment(cx); - XPCShellEnvironment::AutoContextPusher pusher(env); + nsCxPusher pusher; + pusher.Push(env->GetContext()); JSScript *script; JS::Value result; int lineno, startline; JSBool ok, hitEOF; char *bufp, buffer[4096]; JSString *str; @@ -877,36 +878,16 @@ XPCShellDirProvider::GetFile(const char *persistent = true; NS_ADDREF(*result = mGREDir); return NS_OK; } return NS_ERROR_FAILURE; } -XPCShellEnvironment:: -AutoContextPusher::AutoContextPusher(XPCShellEnvironment* aEnv) -{ - NS_ASSERTION(aEnv->mCx, "Null context?!"); - - if (NS_SUCCEEDED(aEnv->mCxStack->Push(aEnv->mCx))) { - mEnv = aEnv; - } -} - -XPCShellEnvironment:: -AutoContextPusher::~AutoContextPusher() -{ - if (mEnv) { - JSContext* cx; - mEnv->mCxStack->Pop(&cx); - NS_ASSERTION(cx == mEnv->mCx, "Wrong context on the stack!"); - } -} - // static XPCShellEnvironment* XPCShellEnvironment::CreateEnvironment() { XPCShellEnvironment* env = new XPCShellEnvironment(); if (env && !env->Init()) { delete env; env = nullptr; @@ -933,18 +914,16 @@ XPCShellEnvironment::~XPCShellEnvironmen if (global) { JS_SetAllNonReservedSlotsToUndefined(mCx, global); } mGlobalHolder.Release(); JSRuntime *rt = JS_GetRuntime(mCx); JS_GC(rt); - mCxStack = nullptr; - if (mJSPrincipals) { JS_DropPrincipals(rt, mJSPrincipals); } JS_EndRequest(mCx); JS_DestroyContext(mCx); if (gOldContextCallback) { @@ -1022,25 +1001,18 @@ XPCShellEnvironment::Init() mJSPrincipals = nsJSPrincipals::get(principal); JS_HoldPrincipals(mJSPrincipals); secman->SetSystemPrincipal(principal); } } else { fprintf(stderr, "+++ Failed to get ScriptSecurityManager service, running without principals"); } - nsCOMPtr<nsIJSContextStack> cxStack = - do_GetService("@mozilla.org/js/xpc/ContextStack;1"); - if (!cxStack) { - NS_ERROR("failed to get the nsThreadJSContextStack service!"); - return false; - } - mCxStack = cxStack; - - AutoContextPusher pusher(this); + nsCxPusher pusher; + pusher.Push(mCx); nsRefPtr<BackstagePass> backstagePass; rv = NS_NewBackstagePass(getter_AddRefs(backstagePass)); if (NS_FAILED(rv)) { NS_ERROR("Failed to create backstage pass!"); return false; } @@ -1088,17 +1060,18 @@ XPCShellEnvironment::Init() return true; } bool XPCShellEnvironment::EvaluateString(const nsString& aString, nsString* aResult) { XPCShellEnvironment* env = Environment(mCx); - XPCShellEnvironment::AutoContextPusher pusher(env); + nsCxPusher pusher; + pusher.Push(env->GetContext()); JSAutoRequest ar(mCx); JS_ClearPendingException(mCx); JSObject* global = GetGlobalObject(); JSAutoCompartment ac(mCx, global);
--- a/ipc/testshell/XPCShellEnvironment.h +++ b/ipc/testshell/XPCShellEnvironment.h @@ -68,33 +68,23 @@ public: void SetShouldCompoleOnly(JSBool aCompileOnly) { mCompileOnly = aCompileOnly; } JSBool ShouldCompileOnly() { return mCompileOnly; } - class AutoContextPusher - { - public: - AutoContextPusher(XPCShellEnvironment* aEnv); - ~AutoContextPusher(); - private: - XPCShellEnvironment* mEnv; - }; - protected: XPCShellEnvironment(); bool Init(); private: JSContext* mCx; nsAutoJSValHolder mGlobalHolder; - nsCOMPtr<nsIJSContextStack> mCxStack; JSPrincipals* mJSPrincipals; int mExitCode; JSBool mQuitting; JSBool mReportWarnings; JSBool mCompileOnly; };