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

Side by Side Diff: talk/app/webrtc/java/jni/jni_helpers.cc

Issue 1308733004: Android: Fix memory leak for remote MediaStream (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: use helper NewGlobalRef function instead Created 5 years, 3 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
« no previous file with comments | « talk/app/webrtc/java/jni/jni_helpers.h ('k') | talk/app/webrtc/java/jni/peerconnection_jni.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * libjingle 3 * libjingle
4 * Copyright 2015 Google Inc. 4 * Copyright 2015 Google Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright notice, 9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer. 10 * this list of conditions and the following disclaimer.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 CHECK_EXCEPTION(jni) << "error during NewGlobalRef"; 266 CHECK_EXCEPTION(jni) << "error during NewGlobalRef";
267 CHECK(ret); 267 CHECK(ret);
268 return ret; 268 return ret;
269 } 269 }
270 270
271 void DeleteGlobalRef(JNIEnv* jni, jobject o) { 271 void DeleteGlobalRef(JNIEnv* jni, jobject o) {
272 jni->DeleteGlobalRef(o); 272 jni->DeleteGlobalRef(o);
273 CHECK_EXCEPTION(jni) << "error during DeleteGlobalRef"; 273 CHECK_EXCEPTION(jni) << "error during DeleteGlobalRef";
274 } 274 }
275 275
276 WeakRef::WeakRef(JNIEnv* jni, jweak ref)
277 : jni_(jni), obj_(jni_->NewLocalRef(ref)) {
278 CHECK_EXCEPTION(jni) << "error during NewLocalRef";
279 }
280 WeakRef::~WeakRef() {
281 if (obj_) {
282 jni_->DeleteLocalRef(obj_);
283 CHECK_EXCEPTION(jni_) << "error during DeleteLocalRef";
284 }
285 }
286
287 // Scope Java local references to the lifetime of this object. Use in all C++ 276 // Scope Java local references to the lifetime of this object. Use in all C++
288 // callbacks (i.e. entry points that don't originate in a Java callstack 277 // callbacks (i.e. entry points that don't originate in a Java callstack
289 // through a "native" method call). 278 // through a "native" method call).
290 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) { 279 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) {
291 CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame"; 280 CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame";
292 } 281 }
293 ScopedLocalRefFrame::~ScopedLocalRefFrame() { 282 ScopedLocalRefFrame::~ScopedLocalRefFrame() {
294 jni_->PopLocalFrame(NULL); 283 jni_->PopLocalFrame(NULL);
295 } 284 }
296 285
297 } // namespace webrtc_jni 286 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/jni/jni_helpers.h ('k') | talk/app/webrtc/java/jni/peerconnection_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698