Change return types of refcount methods.
AddRef() now returns void, and Release() returns an enum RefCountReleaseStatus, to indicate whether or not this Release call implied deletion. Bug: webrtc:8270 Change-Id: If2fb77f26118b61751b51c856af187c72112c630 Reviewed-on: https://webrtc-review.googlesource.com/3320 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20366}
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/refcount.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
|
||||
// Abort the process if |jni| has a Java exception pending.
|
||||
@ -33,8 +34,9 @@
|
||||
|
||||
// Helper that calls ptr->Release() and aborts the process with a useful
|
||||
// message if that didn't actually delete *ptr because of extra refcounts.
|
||||
#define CHECK_RELEASE(ptr) \
|
||||
RTC_CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount."
|
||||
#define CHECK_RELEASE(ptr) \
|
||||
RTC_CHECK((ptr)->Release() == rtc::RefCountReleaseStatus::kDroppedLastRef) \
|
||||
<< "Unexpected refcount."
|
||||
|
||||
// Convenience macro defining JNI-accessible methods in the org.webrtc package.
|
||||
// Eliminates unnecessary boilerplate and line-wraps, reducing visual clutter.
|
||||
|
||||
@ -110,8 +110,7 @@ JNI_FUNCTION_DECLARATION(jobject,
|
||||
nativeChannelPtr);
|
||||
CHECK_EXCEPTION(jni) << "error during NewObject";
|
||||
// Channel is now owned by Java object, and will be freed from there.
|
||||
int bumped_count = channel->AddRef();
|
||||
RTC_CHECK(bumped_count == 2) << "Unexpected refcount";
|
||||
channel->AddRef();
|
||||
return j_channel;
|
||||
}
|
||||
|
||||
|
||||
@ -304,8 +304,7 @@ void PeerConnectionObserverJni::OnDataChannel(
|
||||
// DataChannel.dispose(). Important that this be done _after_ the
|
||||
// CallVoidMethod above as Java code might call back into native code and be
|
||||
// surprised to see a refcount of 2.
|
||||
int bumped_count = channel->AddRef();
|
||||
RTC_CHECK(bumped_count == 2) << "Unexpected refcount OnDataChannel";
|
||||
channel->AddRef();
|
||||
|
||||
CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user