summaryrefslogtreecommitdiffstats
path: root/widget/android
diff options
context:
space:
mode:
Diffstat (limited to 'widget/android')
-rw-r--r--widget/android/GeckoTelemetryDelegate.h100
-rw-r--r--widget/android/jni/Utils.cpp13
-rw-r--r--widget/android/moz.build2
-rw-r--r--widget/android/nsAppShell.cpp3
-rw-r--r--widget/android/nsClipboard.cpp2
5 files changed, 13 insertions, 107 deletions
diff --git a/widget/android/GeckoTelemetryDelegate.h b/widget/android/GeckoTelemetryDelegate.h
deleted file mode 100644
index 43b20d4ad6..0000000000
--- a/widget/android/GeckoTelemetryDelegate.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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/. */
-
-#ifndef GeckoTelemetryDelegate_h__
-#define GeckoTelemetryDelegate_h__
-
-#include "geckoview/streaming/GeckoViewStreamingTelemetry.h"
-
-#include <jni.h>
-
-#include "mozilla/java/RuntimeTelemetryNatives.h"
-#include "mozilla/jni/Natives.h"
-
-namespace mozilla {
-namespace widget {
-
-class GeckoTelemetryDelegate final
- : public GeckoViewStreamingTelemetry::StreamingTelemetryDelegate,
- public mozilla::java::RuntimeTelemetry::Proxy::Natives<
- GeckoTelemetryDelegate> {
- public:
- // Implement Proxy native.
- static void RegisterDelegateProxy(
- mozilla::java::RuntimeTelemetry::Proxy::Param aProxy) {
- MOZ_ASSERT(aProxy);
-
- GeckoViewStreamingTelemetry::RegisterDelegate(
- new GeckoTelemetryDelegate(aProxy));
- }
-
- explicit GeckoTelemetryDelegate(
- mozilla::java::RuntimeTelemetry::Proxy::Param aProxy)
- : mProxy(aProxy) {}
-
- private:
- void DispatchHistogram(bool aIsCategorical, const nsCString& aName,
- const nsTArray<uint32_t>& aSamples) {
- if (!mozilla::jni::IsAvailable() || !mProxy || aSamples.Length() < 1) {
- return;
- }
-
- // Convert aSamples to an array of int64_t. We know |samples| required
- // capacity needs to match |aSamples.Length()|.
- nsTArray<int64_t> samples(aSamples.Length());
- for (size_t i = 0, l = aSamples.Length(); i < l; ++i) {
- samples.AppendElement(static_cast<int64_t>(aSamples[i]));
- }
-
- // LongArray::From *copies* the elements
- mProxy->DispatchHistogram(aIsCategorical, aName,
- mozilla::jni::LongArray::From(samples));
- }
-
- // Implement StreamingTelemetryDelegate.
- void ReceiveHistogramSamples(const nsCString& aName,
- const nsTArray<uint32_t>& aSamples) override {
- DispatchHistogram(/* isCategorical */ false, aName, aSamples);
- }
-
- void ReceiveCategoricalHistogramSamples(
- const nsCString& aName, const nsTArray<uint32_t>& aSamples) override {
- DispatchHistogram(/* isCategorical */ true, aName, aSamples);
- }
-
- void ReceiveBoolScalarValue(const nsCString& aName, bool aValue) override {
- if (!mozilla::jni::IsAvailable() || !mProxy) {
- return;
- }
-
- mProxy->DispatchBooleanScalar(aName, aValue);
- }
-
- void ReceiveStringScalarValue(const nsCString& aName,
- const nsCString& aValue) override {
- if (!mozilla::jni::IsAvailable() || !mProxy) {
- return;
- }
-
- mProxy->DispatchStringScalar(aName, aValue);
- }
-
- void ReceiveUintScalarValue(const nsCString& aName,
- uint32_t aValue) override {
- if (!mozilla::jni::IsAvailable() || !mProxy) {
- return;
- }
-
- mProxy->DispatchLongScalar(aName, static_cast<int64_t>(aValue));
- }
-
- mozilla::java::RuntimeTelemetry::Proxy::GlobalRef mProxy;
-};
-
-} // namespace widget
-} // namespace mozilla
-
-#endif // GeckoTelemetryDelegate_h__
diff --git a/widget/android/jni/Utils.cpp b/widget/android/jni/Utils.cpp
index 8d3800fd03..78e1ab647a 100644
--- a/widget/android/jni/Utils.cpp
+++ b/widget/android/jni/Utils.cpp
@@ -9,6 +9,7 @@
#include <android/log.h>
#include <pthread.h>
+#include <sys/prctl.h>
#include "mozilla/Assertions.h"
#include "mozilla/java/GeckoAppShellWrappers.h"
@@ -164,10 +165,20 @@ JNIEnv* GetEnvForThread() {
return env;
}
+ // By default the VM has a nasty habit of overwriting our lovely
+ // thread names with "Thread-<n>" making them hard to identify in a debugger,
+ // so we pass the name in AttachArgs below to prevent that from happening.
+ // PR_GET_NAME requires a 16 byte buffer: https://linux.die.net/man/2/prctl.
+ // JNI_VERSION_1_4 is required for NewDirectByteBuffer.
+ char threadName[16] = {'\0'};
+ prctl(PR_GET_NAME, threadName);
+ JavaVMAttachArgs attachArgs{
+ .version = JNI_VERSION_1_4, .name = threadName, .group = nullptr};
+
// We don't have a saved JNIEnv, so try to get one.
// AttachCurrentThread() does the same thing as GetEnv() when a thread is
// already attached, so we don't have to call GetEnv() at all.
- if (!sJavaVM->AttachCurrentThread(&env, nullptr)) {
+ if (!sJavaVM->AttachCurrentThread(&env, &attachArgs)) {
MOZ_ASSERT(env);
MOZ_ALWAYS_TRUE(!pthread_setspecific(sThreadEnvKey, env));
return env;
diff --git a/widget/android/moz.build b/widget/android/moz.build
index e4525bb747..2623442020 100644
--- a/widget/android/moz.build
+++ b/widget/android/moz.build
@@ -69,7 +69,6 @@ classes_with_WrapForJNI = [
"ImageDecoder",
"MediaDrmProxy",
"PanZoomController",
- "RuntimeTelemetry",
"Sample",
"SampleBuffer",
"ScreenManagerHelper",
@@ -193,7 +192,6 @@ LOCAL_INCLUDES += [
"/layout/forms",
"/layout/painting",
"/netwerk/base",
- "/toolkit/components/telemetry",
"/widget",
"/widget/headless",
"/xpcom/threads",
diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp
index 4d396945c4..c42f025b2c 100644
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -69,7 +69,6 @@
#include "GeckoNetworkManager.h"
#include "GeckoProcessManager.h"
#include "GeckoSystemStateListener.h"
-#include "GeckoTelemetryDelegate.h"
#include "GeckoVRManager.h"
#include "ImageDecoderSupport.h"
#include "JavaBuiltins.h"
@@ -412,7 +411,6 @@ nsAppShell::nsAppShell()
GeckoAppShellSupport::Init();
XPCOMEventTargetWrapper::Init();
mozilla::widget::Telemetry::Init();
- mozilla::widget::GeckoTelemetryDelegate::Init();
if (XRE_IsGPUProcess()) {
mozilla::gl::AndroidSurfaceTexture::Init();
@@ -443,7 +441,6 @@ nsAppShell::nsAppShell()
mozilla::widget::Base64UtilsSupport::Init();
nsWindow::InitNatives();
mozilla::gl::AndroidSurfaceTexture::Init();
- mozilla::widget::GeckoTelemetryDelegate::Init();
java::GeckoThread::SetState(java::GeckoThread::State::JNI_READY());
diff --git a/widget/android/nsClipboard.cpp b/widget/android/nsClipboard.cpp
index c2a03dd540..3c94b89c01 100644
--- a/widget/android/nsClipboard.cpp
+++ b/widget/android/nsClipboard.cpp
@@ -164,7 +164,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable,
}
}
- return NS_ERROR_FAILURE;
+ return NS_OK;
}
nsresult nsClipboard::EmptyNativeClipboardData(int32_t aWhichClipboard) {