summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/sdk/android/src/jni/logging
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/libwebrtc/sdk/android/src/jni/logging
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/sdk/android/src/jni/logging')
-rw-r--r--third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.cc42
-rw-r--r--third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.h43
2 files changed, 85 insertions, 0 deletions
diff --git a/third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.cc b/third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.cc
new file mode 100644
index 0000000000..84394d8ee5
--- /dev/null
+++ b/third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+#include "sdk/android/src/jni/logging/log_sink.h"
+
+#include "absl/strings/string_view.h"
+#include "sdk/android/generated_logging_jni/JNILogging_jni.h"
+
+namespace webrtc {
+namespace jni {
+
+JNILogSink::JNILogSink(JNIEnv* env, const JavaRef<jobject>& j_logging)
+ : j_logging_(env, j_logging) {}
+JNILogSink::~JNILogSink() = default;
+
+void JNILogSink::OnLogMessage(const std::string& msg) {
+ RTC_DCHECK_NOTREACHED();
+}
+
+void JNILogSink::OnLogMessage(const std::string& msg,
+ rtc::LoggingSeverity severity,
+ const char* tag) {
+ OnLogMessage(absl::string_view{msg}, severity, tag);
+}
+
+void JNILogSink::OnLogMessage(absl::string_view msg,
+ rtc::LoggingSeverity severity,
+ const char* tag) {
+ JNIEnv* env = AttachCurrentThreadIfNeeded();
+ Java_JNILogging_logToInjectable(
+ env, j_logging_, NativeToJavaString(env, std::string(msg)),
+ NativeToJavaInteger(env, severity), NativeToJavaString(env, tag));
+}
+
+} // namespace jni
+} // namespace webrtc
diff --git a/third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.h b/third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.h
new file mode 100644
index 0000000000..8e681ac3ea
--- /dev/null
+++ b/third_party/libwebrtc/sdk/android/src/jni/logging/log_sink.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2018 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+#ifndef SDK_ANDROID_SRC_JNI_LOGGING_LOG_SINK_H_
+#define SDK_ANDROID_SRC_JNI_LOGGING_LOG_SINK_H_
+
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "rtc_base/logging.h"
+#include "sdk/android/native_api/jni/java_types.h"
+#include "sdk/android/src/jni/jni_helpers.h"
+
+namespace webrtc {
+namespace jni {
+
+class JNILogSink : public rtc::LogSink {
+ public:
+ JNILogSink(JNIEnv* env, const JavaRef<jobject>& j_logging);
+ ~JNILogSink() override;
+
+ void OnLogMessage(const std::string& msg) override;
+ void OnLogMessage(const std::string& msg,
+ rtc::LoggingSeverity severity,
+ const char* tag) override;
+ void OnLogMessage(absl::string_view msg,
+ rtc::LoggingSeverity severity,
+ const char* tag) override;
+
+ private:
+ const ScopedJavaGlobalRef<jobject> j_logging_;
+};
+
+} // namespace jni
+} // namespace webrtc
+
+#endif // SDK_ANDROID_SRC_JNI_LOGGING_LOG_SINK_H_