OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void DeleteGlobalRef(JNIEnv* jni, jobject o) { | 80 void DeleteGlobalRef(JNIEnv* jni, jobject o) { |
81 jni->DeleteGlobalRef(o); | 81 jni->DeleteGlobalRef(o); |
82 CHECK_EXCEPTION(jni) << "Error during DeleteGlobalRef"; | 82 CHECK_EXCEPTION(jni) << "Error during DeleteGlobalRef"; |
83 } | 83 } |
84 | 84 |
85 std::string GetThreadId() { | 85 std::string GetThreadId() { |
86 char buf[21]; // Big enough to hold a kuint64max plus terminating NULL. | 86 char buf[21]; // Big enough to hold a kuint64max plus terminating NULL. |
87 int thread_id = gettid(); | 87 int thread_id = gettid(); |
88 RTC_CHECK_LT(snprintf(buf, sizeof(buf), "%i", thread_id), | 88 RTC_CHECK_LT(snprintf(buf, sizeof(buf), "%i", thread_id), |
89 static_cast<int>(sizeof(buf))) | 89 static_cast<int>(sizeof(buf))) |
90 << "Thread id is bigger than uint64??"; | 90 << "Thread id is bigger than uint64_t??"; |
91 return std::string(buf); | 91 return std::string(buf); |
92 } | 92 } |
93 | 93 |
94 std::string GetThreadInfo() { | 94 std::string GetThreadInfo() { |
95 return "@[tid=" + GetThreadId() + "]"; | 95 return "@[tid=" + GetThreadId() + "]"; |
96 } | 96 } |
97 | 97 |
98 AttachThreadScoped::AttachThreadScoped(JavaVM* jvm) | 98 AttachThreadScoped::AttachThreadScoped(JavaVM* jvm) |
99 : attached_(false), jvm_(jvm), env_(NULL) { | 99 : attached_(false), jvm_(jvm), env_(NULL) { |
100 env_ = GetEnv(jvm); | 100 env_ = GetEnv(jvm); |
(...skipping 13 matching lines...) Expand all Loading... |
114 ALOGD("Detaching thread from JVM%s", GetThreadInfo().c_str()); | 114 ALOGD("Detaching thread from JVM%s", GetThreadInfo().c_str()); |
115 jint res = jvm_->DetachCurrentThread(); | 115 jint res = jvm_->DetachCurrentThread(); |
116 RTC_CHECK(res == JNI_OK) << "DetachCurrentThread failed: " << res; | 116 RTC_CHECK(res == JNI_OK) << "DetachCurrentThread failed: " << res; |
117 RTC_CHECK(!GetEnv(jvm_)); | 117 RTC_CHECK(!GetEnv(jvm_)); |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 JNIEnv* AttachThreadScoped::env() { return env_; } | 121 JNIEnv* AttachThreadScoped::env() { return env_; } |
122 | 122 |
123 } // namespace webrtc | 123 } // namespace webrtc |
OLD | NEW |