From cc7a1f5b9b324b0afc6b3ca237b9ddfa3b249031 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Wed, 10 May 2017 14:42:49 -0700 Subject: [PATCH] Backed out 2 changesets (bug 1362800) for eslint failures a=backout Backed out changeset 0492e6f16df1 (bug 1362800) Backed out changeset 785cf0c4b67b (bug 1362800) MozReview-Commit-ID: EY2RYz7lwtI --- .../extensions/ext-geckoProfiler.js | 11 +--- .../extensions/schemas/geckoProfiler.json | 7 -- .../test_ext_geckoProfiler_control.js | 15 ----- tools/profiler/gecko/nsIProfiler.idl | 3 - tools/profiler/gecko/nsProfiler.cpp | 64 +------------------ 5 files changed, 4 insertions(+), 96 deletions(-) diff --git a/browser/components/extensions/ext-geckoProfiler.js b/browser/components/extensions/ext-geckoProfiler.js index 6326896417a7..8d38c4cca756 100644 --- a/browser/components/extensions/ext-geckoProfiler.js +++ b/browser/components/extensions/ext-geckoProfiler.js @@ -295,22 +295,13 @@ this.geckoProfiler = class extends ExtensionAPI { async getProfile() { if (!Services.profiler.IsActive()) { - throw new ExtensionError("The profiler is stopped. " + + throw new Error("The profiler is stopped. " + "You need to start the profiler before you can capture a profile."); } return Services.profiler.getProfileDataAsync(); }, - async getProfileAsArrayBuffer() { - if (!Services.profiler.IsActive()) { - throw new ExtensionError("The profiler is stopped. " + - "You need to start the profiler before you can capture a profile."); - } - - return Services.profiler.getProfileDataAsArrayBuffer(); - }, - async getSymbols(debugName, breakpadId) { if (symbolCache.size === 0) { primeSymbolStore(Services.profiler.sharedLibraries); diff --git a/browser/components/extensions/schemas/geckoProfiler.json b/browser/components/extensions/schemas/geckoProfiler.json index 12766e3ef1d4..af22f3c985c2 100644 --- a/browser/components/extensions/schemas/geckoProfiler.json +++ b/browser/components/extensions/schemas/geckoProfiler.json @@ -92,13 +92,6 @@ "async": true, "parameters": [] }, - { - "name": "getProfileAsArrayBuffer", - "type": "function", - "description": "Gathers the profile data from the current profiling session. The returned promise resolves to an array buffer that contains a JSON string.", - "async": true, - "parameters": [] - }, { "name": "getSymbols", "type": "function", diff --git a/browser/components/extensions/test/xpcshell/test_ext_geckoProfiler_control.js b/browser/components/extensions/test/xpcshell/test_ext_geckoProfiler_control.js index 8e8882601676..65c99d3059b5 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_geckoProfiler_control.js +++ b/browser/components/extensions/test/xpcshell/test_ext_geckoProfiler_control.js @@ -48,18 +48,6 @@ let getExtension = () => { "The profile contains a GeckoMain thread."); browser.test.sendMessage("tested profile"); break; - case "test profile as array buffer": - let arrayBuffer = await browser.geckoProfiler.getProfileAsArrayBuffer(); - browser.test.assertTrue(arrayBuffer.byteLength >= 2, "The profile array buffer contains data."); - let textDecoder = new TextDecoder(); - let profile = JSON.parse(textDecoder.decode(arrayBuffer)); - browser.test.assertTrue("libs" in profile, "The profile contains libs."); - browser.test.assertTrue("meta" in profile, "The profile contains meta."); - browser.test.assertTrue("threads" in profile, "The profile contains threads."); - browser.test.assertTrue(profile.threads.some(t => t.name == "GeckoMain"), - "The profile contains a GeckoMain thread."); - browser.test.sendMessage("tested profile as array buffer"); - break; case "remove runningListener": browser.geckoProfiler.onRunning.removeListener(runningListener); browser.test.sendMessage("removed runningListener"); @@ -98,9 +86,6 @@ add_task(async function testProfilerControl() { extension.sendMessage("test profile"); await extension.awaitMessage("tested profile"); - extension.sendMessage("test profile as array buffer"); - await extension.awaitMessage("tested profile as array buffer"); - extension.sendMessage("pause"); await extension.awaitMessage("paused"); diff --git a/tools/profiler/gecko/nsIProfiler.idl b/tools/profiler/gecko/nsIProfiler.idl index e305ac7b84fa..c6edbdc9feac 100644 --- a/tools/profiler/gecko/nsIProfiler.idl +++ b/tools/profiler/gecko/nsIProfiler.idl @@ -57,9 +57,6 @@ interface nsIProfiler : nsISupports [implicit_jscontext] nsISupports getProfileDataAsync([optional] in double aSinceTime); - [implicit_jscontext] - nsISupports getProfileDataAsArrayBuffer([optional] in double aSinceTime); - void dumpProfileToFileAsync(in ACString aFilename, [optional] in double aSinceTime); diff --git a/tools/profiler/gecko/nsProfiler.cpp b/tools/profiler/gecko/nsProfiler.cpp index 5c07e2169f09..f5afbdff80d6 100644 --- a/tools/profiler/gecko/nsProfiler.cpp +++ b/tools/profiler/gecko/nsProfiler.cpp @@ -22,7 +22,6 @@ #include "js/Value.h" #include "mozilla/ErrorResult.h" #include "mozilla/dom/Promise.h" -#include "mozilla/dom/TypedArray.h" #include "ProfileGatherer.h" #include "nsLocalFile.h" #include "platform.h" @@ -261,15 +260,14 @@ nsProfiler::GetProfileDataAsync(double aSinceTime, JSContext* aCx, return NS_ERROR_FAILURE; } - nsIGlobalObject* globalObject = - xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx)); + nsIGlobalObject* go = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx)); - if (NS_WARN_IF(!globalObject)) { + if (NS_WARN_IF(!go)) { return NS_ERROR_FAILURE; } ErrorResult result; - RefPtr promise = Promise::Create(globalObject, result); + RefPtr promise = Promise::Create(go, result); if (NS_WARN_IF(result.Failed())) { return result.StealNSResult(); } @@ -315,62 +313,6 @@ nsProfiler::GetProfileDataAsync(double aSinceTime, JSContext* aCx, return NS_OK; } -NS_IMETHODIMP -nsProfiler::GetProfileDataAsArrayBuffer(double aSinceTime, JSContext* aCx, - nsISupports** aPromise) -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (!mGatherer) { - return NS_ERROR_FAILURE; - } - - if (NS_WARN_IF(!aCx)) { - return NS_ERROR_FAILURE; - } - - nsIGlobalObject* globalObject = - xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx)); - - if (NS_WARN_IF(!globalObject)) { - return NS_ERROR_FAILURE; - } - - ErrorResult result; - RefPtr promise = Promise::Create(globalObject, result); - if (NS_WARN_IF(result.Failed())) { - return result.StealNSResult(); - } - - mGatherer->Start(aSinceTime)->Then( - AbstractThread::MainThread(), __func__, - [promise](nsCString aResult) { - AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.Init(promise->GlobalJSObject()))) { - // We're really hosed if we can't get a JS context for some reason. - promise->MaybeReject(NS_ERROR_DOM_UNKNOWN_ERR); - return; - } - - JSContext* cx = jsapi.cx(); - JSObject* typedArray = - dom::ArrayBuffer::Create(cx, aResult.Length(), - reinterpret_cast(aResult.Data())); - if (typedArray) { - JS::RootedValue val(cx, JS::ObjectValue(*typedArray)); - promise->MaybeResolve(val); - } else { - promise->MaybeReject(NS_ERROR_OUT_OF_MEMORY); - } - }, - [promise](nsresult aRv) { - promise->MaybeReject(aRv); - }); - - promise.forget(aPromise); - return NS_OK; -} - NS_IMETHODIMP nsProfiler::DumpProfileToFileAsync(const nsACString& aFilename, double aSinceTime)