Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: webrtc/sdk/android/src/jni/pc/logging_jni.cc

Issue 2992103002: Relanding: Break peerconnection_jni.cc into multiple files, in "pc" directory. (Closed)
Patch Set: Add jni/androidnetworkmonitor_jni.h include for backwards comaptibility. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/sdk/android/src/jni/ownedfactoryandthreads.h" 11 #include <memory>
12 12
13 #include "webrtc/rtc_base/logging.h" 13 #include "webrtc/rtc_base/logging.h"
14 #include "webrtc/sdk/android/src/jni/classreferenceholder.h"
15 #include "webrtc/sdk/android/src/jni/jni_helpers.h" 14 #include "webrtc/sdk/android/src/jni/jni_helpers.h"
15 #include "webrtc/system_wrappers/include/logcat_trace_context.h"
16 #include "webrtc/system_wrappers/include/trace.h"
16 17
17 namespace webrtc_jni { 18 namespace webrtc_jni {
18 19
19 PeerConnectionFactoryInterface* factoryFromJava(jlong j_p) { 20 JOW(void, Logging_nativeEnableTracing)
20 return reinterpret_cast<OwnedFactoryAndThreads*>(j_p)->factory(); 21 (JNIEnv* jni, jclass, jstring j_path, jint nativeLevels) {
21 } 22 std::string path = JavaToStdString(jni, j_path);
22 23 if (nativeLevels != webrtc::kTraceNone) {
23 OwnedFactoryAndThreads::~OwnedFactoryAndThreads() { 24 webrtc::Trace::set_level_filter(nativeLevels);
24 CHECK_RELEASE(factory_); 25 if (path != "logcat:") {
25 if (network_monitor_factory_ != nullptr) { 26 RTC_CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false))
26 rtc::NetworkMonitorFactory::ReleaseFactory(network_monitor_factory_); 27 << "SetTraceFile failed";
28 } else {
29 // Intentionally leak this to avoid needing to reason about its lifecycle.
30 // It keeps no state and functions only as a dispatch point.
31 static webrtc::LogcatTraceContext* g_trace_callback =
32 new webrtc::LogcatTraceContext();
33 }
27 } 34 }
28 } 35 }
29 36
30 void OwnedFactoryAndThreads::JavaCallbackOnFactoryThreads() { 37 JOW(void, Logging_nativeEnableLogToDebugOutput)
31 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 38 (JNIEnv* jni, jclass, jint nativeSeverity) {
32 ScopedLocalRefFrame local_ref_frame(jni); 39 if (nativeSeverity >= rtc::LS_SENSITIVE && nativeSeverity <= rtc::LS_NONE) {
33 jclass j_factory_class = FindClass(jni, "org/webrtc/PeerConnectionFactory"); 40 rtc::LogMessage::LogToDebug(
34 jmethodID m = nullptr; 41 static_cast<rtc::LoggingSeverity>(nativeSeverity));
35 if (network_thread_->IsCurrent()) {
36 LOG(LS_INFO) << "Network thread JavaCallback";
37 m = GetStaticMethodID(jni, j_factory_class, "onNetworkThreadReady", "()V");
38 }
39 if (worker_thread_->IsCurrent()) {
40 LOG(LS_INFO) << "Worker thread JavaCallback";
41 m = GetStaticMethodID(jni, j_factory_class, "onWorkerThreadReady", "()V");
42 }
43 if (signaling_thread_->IsCurrent()) {
44 LOG(LS_INFO) << "Signaling thread JavaCallback";
45 m = GetStaticMethodID(jni, j_factory_class, "onSignalingThreadReady",
46 "()V");
47 }
48 if (m != nullptr) {
49 jni->CallStaticVoidMethod(j_factory_class, m);
50 CHECK_EXCEPTION(jni) << "error during JavaCallback::CallStaticVoidMethod";
51 } 42 }
52 } 43 }
53 44
54 void OwnedFactoryAndThreads::InvokeJavaCallbacksOnFactoryThreads() { 45 JOW(void, Logging_nativeEnableLogThreads)(JNIEnv* jni, jclass) {
55 LOG(LS_INFO) << "InvokeJavaCallbacksOnFactoryThreads."; 46 rtc::LogMessage::LogThreads(true);
56 network_thread_->Invoke<void>(RTC_FROM_HERE, 47 }
57 [this] { JavaCallbackOnFactoryThreads(); }); 48
58 worker_thread_->Invoke<void>(RTC_FROM_HERE, 49 JOW(void, Logging_nativeEnableLogTimeStamps)(JNIEnv* jni, jclass) {
59 [this] { JavaCallbackOnFactoryThreads(); }); 50 rtc::LogMessage::LogTimestamps(true);
60 signaling_thread_->Invoke<void>(RTC_FROM_HERE, 51 }
61 [this] { JavaCallbackOnFactoryThreads(); }); 52
53 JOW(void, Logging_nativeLog)
54 (JNIEnv* jni, jclass, jint j_severity, jstring j_tag, jstring j_message) {
55 std::string message = JavaToStdString(jni, j_message);
56 std::string tag = JavaToStdString(jni, j_tag);
57 LOG_TAG(static_cast<rtc::LoggingSeverity>(j_severity), tag) << message;
62 } 58 }
63 59
64 } // namespace webrtc_jni 60 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « webrtc/sdk/android/src/jni/pc/java_native_conversion.cc ('k') | webrtc/sdk/android/src/jni/pc/media_jni.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698