Revert "Remove RTC_DISALLOW_COPY_AND_ASSIGN usages completely"

This reverts commit 5f0eb93d2a44cec2102fc8c3757d5bb814bd145f.

Reason for revert: Breaks downstream project. I'm going to fix that one and create a reland of this CL after.

Original change's description:
> 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}

TBR=hta@webrtc.org,titovartem@webrtc.org,daniel.l@hpcnt.com,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I33d497f1132adfe6d151023195a388d9b7d548f9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:13555, webrtc:13082
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249364
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Owners-Override: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35807}
This commit is contained in:
Artem Titov
2022-01-26 14:51:53 +00:00
committed by WebRTC LUCI CQ
parent d3b3a3b6bb
commit 3f87250a4f
77 changed files with 232 additions and 257 deletions

View File

@ -57,9 +57,6 @@ class Iterable {
~Iterable();
Iterable(const Iterable&) = delete;
Iterable& operator=(const Iterable&) = delete;
class Iterator {
public:
// Creates an iterator representing the end of any collection.
@ -74,9 +71,6 @@ class Iterable {
~Iterator();
Iterator(const Iterator&) = delete;
Iterator& operator=(const Iterator&) = delete;
// Move assignment should not be used.
Iterator& operator=(Iterator&&) = delete;
@ -102,6 +96,8 @@ 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_); }
@ -110,6 +106,8 @@ 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,9 +34,6 @@ 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
@ -52,19 +49,22 @@ 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) {}
JavaParamRef(const JavaParamRef&) = delete;
JavaParamRef& operator=(const JavaParamRef&) = delete;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(JavaParamRef);
};
// Holds a local reference to a Java object. The local reference is scoped
@ -186,9 +186,6 @@ 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) {
@ -212,6 +209,9 @@ class ScopedJavaGlobalRef : public JavaRef<T> {
obj_ = nullptr;
return obj;
}
private:
RTC_DISALLOW_COPY_AND_ASSIGN(ScopedJavaGlobalRef);
};
template <typename T>