Bug 687134 - Get at the JSContext through IDL for pccount methods; r=bholley

This commit is contained in:
Ms2ger 2011-12-24 09:21:26 +01:00
parent a6b482e711
commit 83e8b4f774
2 changed files with 13 additions and 51 deletions

View File

@ -1982,77 +1982,37 @@ nsDOMWindowUtils::GetFileReferences(const nsAString& aDatabaseName,
return NS_OK;
}
static inline JSContext *
GetJSContext()
{
nsCOMPtr<nsIXPConnect> xpc = nsContentUtils::XPConnect();
// get the xpconnect native call context
nsAXPCNativeCallContext *cc = nsnull;
xpc->GetCurrentNativeCallContext(&cc);
if(!cc)
return NULL;
// Get JSContext of current call
JSContext* cx;
nsresult rv = cc->GetJSContext(&cx);
if(NS_FAILED(rv) || !cx)
return NULL;
return cx;
}
NS_IMETHODIMP
nsDOMWindowUtils::StartPCCountProfiling()
nsDOMWindowUtils::StartPCCountProfiling(JSContext* cx)
{
JSContext *cx = GetJSContext();
if (!cx)
return NS_ERROR_FAILURE;
js::StartPCCountProfiling(cx);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::StopPCCountProfiling()
nsDOMWindowUtils::StopPCCountProfiling(JSContext* cx)
{
JSContext *cx = GetJSContext();
if (!cx)
return NS_ERROR_FAILURE;
js::StopPCCountProfiling(cx);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::PurgePCCounts()
nsDOMWindowUtils::PurgePCCounts(JSContext* cx)
{
JSContext *cx = GetJSContext();
if (!cx)
return NS_ERROR_FAILURE;
js::PurgePCCounts(cx);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetPCCountScriptCount(PRInt32 *result)
nsDOMWindowUtils::GetPCCountScriptCount(JSContext* cx, PRInt32 *result)
{
JSContext *cx = GetJSContext();
if (!cx)
return NS_ERROR_FAILURE;
*result = js::GetPCCountScriptCount(cx);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetPCCountScriptSummary(PRInt32 script, nsAString& result)
nsDOMWindowUtils::GetPCCountScriptSummary(PRInt32 script, JSContext* cx, nsAString& result)
{
JSContext *cx = GetJSContext();
if (!cx)
return NS_ERROR_FAILURE;
JSString *text = js::GetPCCountScriptSummary(cx, script);
if (!text)
return NS_ERROR_FAILURE;
@ -2066,12 +2026,8 @@ nsDOMWindowUtils::GetPCCountScriptSummary(PRInt32 script, nsAString& result)
}
NS_IMETHODIMP
nsDOMWindowUtils::GetPCCountScriptContents(PRInt32 script, nsAString& result)
nsDOMWindowUtils::GetPCCountScriptContents(PRInt32 script, JSContext* cx, nsAString& result)
{
JSContext *cx = GetJSContext();
if (!cx)
return NS_ERROR_FAILURE;
JSString *text = js::GetPCCountScriptContents(cx, script);
if (!text)
return NS_ERROR_FAILURE;

View File

@ -69,7 +69,7 @@ interface nsIDOMBlob;
interface nsIDOMFile;
interface nsIFile;
[scriptable, uuid(3af3c5ce-6f2a-47e7-acd0-555ed576fa82)]
[scriptable, uuid(9df58cf3-7094-4c8d-96f2-bebd765099fe)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -945,28 +945,33 @@ interface nsIDOMWindowUtils : nsISupports {
* Begin opcode-level profiling of all JavaScript execution in the window's
* runtime.
*/
[implicit_jscontext]
void startPCCountProfiling();
/**
* Stop opcode-level profiling of JavaScript execution in the runtime, and
* collect all counts for use by getPCCount methods.
*/
[implicit_jscontext]
void stopPCCountProfiling();
/**
* Purge collected PC counters.
*/
[implicit_jscontext]
void purgePCCounts();
/**
* Get the number of scripts with opcode-level profiling information.
*/
[implicit_jscontext]
long getPCCountScriptCount();
/**
* Get a JSON string for a short summary of a script and the PC counts
* accumulated for it.
*/
[implicit_jscontext]
AString getPCCountScriptSummary(in long script);
/**
@ -974,5 +979,6 @@ interface nsIDOMWindowUtils : nsISupports {
* including the decompilation of the script and placement of decompiled
* operations within it, and PC counts for each operation.
*/
[implicit_jscontext]
AString getPCCountScriptContents(in long script);
};