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

Unified Diff: webrtc/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/sdk/android/src/jni/pc/audiotrack_jni.cc ('k') | webrtc/sdk/android/src/jni/pc/datachannel_jni.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc
diff --git a/webrtc/sdk/android/src/jni/ownedfactoryandthreads.cc b/webrtc/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc
similarity index 21%
copy from webrtc/sdk/android/src/jni/ownedfactoryandthreads.cc
copy to webrtc/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc
index a3aa45c4bead267acec36c6862cae84a9790d792..42763b608454abdfa58b0cae0c05cbef7a930c50 100644
--- a/webrtc/sdk/android/src/jni/ownedfactoryandthreads.cc
+++ b/webrtc/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc
@@ -8,57 +8,61 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/sdk/android/src/jni/ownedfactoryandthreads.h"
-
-#include "webrtc/rtc_base/logging.h"
-#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
+#include "webrtc/rtc_base/logsinks.h"
#include "webrtc/sdk/android/src/jni/jni_helpers.h"
namespace webrtc_jni {
-PeerConnectionFactoryInterface* factoryFromJava(jlong j_p) {
- return reinterpret_cast<OwnedFactoryAndThreads*>(j_p)->factory();
+JOW(jlong, CallSessionFileRotatingLogSink_nativeAddSink)
+(JNIEnv* jni, jclass, jstring j_dirPath, jint j_maxFileSize, jint j_severity) {
+ std::string dir_path = JavaToStdString(jni, j_dirPath);
+ rtc::CallSessionFileRotatingLogSink* sink =
+ new rtc::CallSessionFileRotatingLogSink(dir_path, j_maxFileSize);
+ if (!sink->Init()) {
+ LOG_V(rtc::LoggingSeverity::LS_WARNING)
+ << "Failed to init CallSessionFileRotatingLogSink for path "
+ << dir_path;
+ delete sink;
+ return 0;
+ }
+ rtc::LogMessage::AddLogToStream(
+ sink, static_cast<rtc::LoggingSeverity>(j_severity));
+ return (jlong)sink;
}
-OwnedFactoryAndThreads::~OwnedFactoryAndThreads() {
- CHECK_RELEASE(factory_);
- if (network_monitor_factory_ != nullptr) {
- rtc::NetworkMonitorFactory::ReleaseFactory(network_monitor_factory_);
- }
+JOW(void, CallSessionFileRotatingLogSink_nativeDeleteSink)
+(JNIEnv* jni, jclass, jlong j_sink) {
+ rtc::CallSessionFileRotatingLogSink* sink =
+ reinterpret_cast<rtc::CallSessionFileRotatingLogSink*>(j_sink);
+ rtc::LogMessage::RemoveLogToStream(sink);
+ delete sink;
}
-void OwnedFactoryAndThreads::JavaCallbackOnFactoryThreads() {
- JNIEnv* jni = AttachCurrentThreadIfNeeded();
- ScopedLocalRefFrame local_ref_frame(jni);
- jclass j_factory_class = FindClass(jni, "org/webrtc/PeerConnectionFactory");
- jmethodID m = nullptr;
- if (network_thread_->IsCurrent()) {
- LOG(LS_INFO) << "Network thread JavaCallback";
- m = GetStaticMethodID(jni, j_factory_class, "onNetworkThreadReady", "()V");
- }
- if (worker_thread_->IsCurrent()) {
- LOG(LS_INFO) << "Worker thread JavaCallback";
- m = GetStaticMethodID(jni, j_factory_class, "onWorkerThreadReady", "()V");
+JOW(jbyteArray, CallSessionFileRotatingLogSink_nativeGetLogData)
+(JNIEnv* jni, jclass, jstring j_dirPath) {
+ std::string dir_path = JavaToStdString(jni, j_dirPath);
+ std::unique_ptr<rtc::CallSessionFileRotatingStream> stream(
+ new rtc::CallSessionFileRotatingStream(dir_path));
+ if (!stream->Open()) {
+ LOG_V(rtc::LoggingSeverity::LS_WARNING)
+ << "Failed to open CallSessionFileRotatingStream for path " << dir_path;
+ return jni->NewByteArray(0);
}
- if (signaling_thread_->IsCurrent()) {
- LOG(LS_INFO) << "Signaling thread JavaCallback";
- m = GetStaticMethodID(jni, j_factory_class, "onSignalingThreadReady",
- "()V");
+ size_t log_size = 0;
+ if (!stream->GetSize(&log_size) || log_size == 0) {
+ LOG_V(rtc::LoggingSeverity::LS_WARNING)
+ << "CallSessionFileRotatingStream returns 0 size for path " << dir_path;
+ return jni->NewByteArray(0);
}
- if (m != nullptr) {
- jni->CallStaticVoidMethod(j_factory_class, m);
- CHECK_EXCEPTION(jni) << "error during JavaCallback::CallStaticVoidMethod";
- }
-}
-void OwnedFactoryAndThreads::InvokeJavaCallbacksOnFactoryThreads() {
- LOG(LS_INFO) << "InvokeJavaCallbacksOnFactoryThreads.";
- network_thread_->Invoke<void>(RTC_FROM_HERE,
- [this] { JavaCallbackOnFactoryThreads(); });
- worker_thread_->Invoke<void>(RTC_FROM_HERE,
- [this] { JavaCallbackOnFactoryThreads(); });
- signaling_thread_->Invoke<void>(RTC_FROM_HERE,
- [this] { JavaCallbackOnFactoryThreads(); });
+ size_t read = 0;
+ std::unique_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size)));
+ stream->ReadAll(buffer.get(), log_size, &read, nullptr);
+
+ jbyteArray result = jni->NewByteArray(read);
+ jni->SetByteArrayRegion(result, 0, read, buffer.get());
+
+ return result;
}
} // namespace webrtc_jni
« no previous file with comments | « webrtc/sdk/android/src/jni/pc/audiotrack_jni.cc ('k') | webrtc/sdk/android/src/jni/pc/datachannel_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698