Remove RTC_DISALLOW_COPY_AND_ASSIGN usages completely

Bug: webrtc:13555, webrtc:13082
Change-Id: Iff2cda6f516739419e97e975e03f77a98f74be03
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249260
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: (Daniel.L) Byoungchan Lee <daniel.l@hpcnt.com>
Cr-Commit-Position: refs/heads/main@{#35805}
This commit is contained in:
Byoungchan Lee
2022-01-26 09:36:49 +09:00
committed by WebRTC LUCI CQ
parent 38c762c0ab
commit 5f0eb93d2a
77 changed files with 257 additions and 232 deletions

View File

@ -57,6 +57,9 @@ class Iterable {
~Iterable();
Iterable(const Iterable&) = delete;
Iterable& operator=(const Iterable&) = delete;
class Iterator {
public:
// Creates an iterator representing the end of any collection.
@ -71,6 +74,9 @@ class Iterable {
~Iterator();
Iterator(const Iterator&) = delete;
Iterator& operator=(const Iterator&) = delete;
// Move assignment should not be used.
Iterator& operator=(Iterator&&) = delete;
@ -96,8 +102,6 @@ class Iterable {
ScopedJavaLocalRef<jobject> iterator_;
ScopedJavaLocalRef<jobject> value_;
SequenceChecker thread_checker_;
RTC_DISALLOW_COPY_AND_ASSIGN(Iterator);
};
Iterable::Iterator begin() { return Iterable::Iterator(jni_, iterable_); }
@ -106,8 +110,6 @@ class Iterable {
private:
JNIEnv* jni_;
ScopedJavaLocalRef<jobject> iterable_;
RTC_DISALLOW_COPY_AND_ASSIGN(Iterable);
};
// Returns true if `obj` == null in Java.

View File

@ -15,9 +15,9 @@
#define SDK_ANDROID_NATIVE_API_JNI_SCOPED_JAVA_REF_H_
#include <jni.h>
#include <utility>
#include "rtc_base/constructor_magic.h"
#include "sdk/android/native_api/jni/jvm.h"
namespace webrtc {
@ -34,6 +34,9 @@ class JavaRef;
template <>
class JavaRef<jobject> {
public:
JavaRef(const JavaRef&) = delete;
JavaRef& operator=(const JavaRef&) = delete;
jobject obj() const { return obj_; }
bool is_null() const {
// This is not valid for weak references. For weak references you need to
@ -49,22 +52,19 @@ class JavaRef<jobject> {
constexpr JavaRef() : obj_(nullptr) {}
explicit JavaRef(jobject obj) : obj_(obj) {}
jobject obj_;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(JavaRef);
};
template <typename T>
class JavaRef : public JavaRef<jobject> {
public:
JavaRef(const JavaRef&) = delete;
JavaRef& operator=(const JavaRef&) = delete;
T obj() const { return static_cast<T>(obj_); }
protected:
JavaRef() : JavaRef<jobject>(nullptr) {}
explicit JavaRef(T obj) : JavaRef<jobject>(obj) {}
private:
RTC_DISALLOW_COPY_AND_ASSIGN(JavaRef);
};
// Holds a local reference to a JNI method parameter.
@ -79,8 +79,8 @@ class JavaParamRef : public JavaRef<T> {
explicit JavaParamRef(T obj) : JavaRef<T>(obj) {}
JavaParamRef(JNIEnv*, T obj) : JavaRef<T>(obj) {}
private:
RTC_DISALLOW_COPY_AND_ASSIGN(JavaParamRef);
JavaParamRef(const JavaParamRef&) = delete;
JavaParamRef& operator=(const JavaParamRef&) = delete;
};
// Holds a local reference to a Java object. The local reference is scoped
@ -186,6 +186,9 @@ class ScopedJavaGlobalRef : public JavaRef<T> {
AttachCurrentThreadIfNeeded()->DeleteGlobalRef(obj_);
}
ScopedJavaGlobalRef(const ScopedJavaGlobalRef&) = delete;
ScopedJavaGlobalRef& operator=(const ScopedJavaGlobalRef&) = delete;
void operator=(const JavaRef<T>& other) {
JNIEnv* env = AttachCurrentThreadIfNeeded();
if (obj_ != nullptr) {
@ -209,9 +212,6 @@ class ScopedJavaGlobalRef : public JavaRef<T> {
obj_ = nullptr;
return obj;
}
private:
RTC_DISALLOW_COPY_AND_ASSIGN(ScopedJavaGlobalRef);
};
template <typename T>