Replace the remaining scoped_ptr with unique_ptr in webrtc/modules/
BUG=webrtc:5520
Review URL: https://codereview.webrtc.org/1921233002
Cr-Commit-Position: refs/heads/master@{#12511}
diff --git a/webrtc/modules/utility/include/jvm_android.h b/webrtc/modules/utility/include/jvm_android.h
index f527dff..574c977 100644
--- a/webrtc/modules/utility/include/jvm_android.h
+++ b/webrtc/modules/utility/include/jvm_android.h
@@ -12,9 +12,10 @@
#define WEBRTC_MODULES_UTILITY_INCLUDE_JVM_ANDROID_H_
#include <jni.h>
+
+#include <memory>
#include <string>
-#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/modules/utility/include/helpers_android.h"
@@ -76,7 +77,7 @@
NativeRegistration(JNIEnv* jni, jclass clazz);
~NativeRegistration();
- rtc::scoped_ptr<GlobalRef> NewObject(
+ std::unique_ptr<GlobalRef> NewObject(
const char* name, const char* signature, ...);
private:
@@ -96,7 +97,7 @@
// Note that the class name must be one of the names in the static
// |loaded_classes| array defined in jvm_android.cc.
// This method must be called on the construction thread.
- rtc::scoped_ptr<NativeRegistration> RegisterNatives(
+ std::unique_ptr<NativeRegistration> RegisterNatives(
const char* name, const JNINativeMethod *methods, int num_methods);
// Converts from Java string to std::string.
@@ -120,9 +121,9 @@
// webrtc::JVM::Initialize(jvm, context);
//
// // Header (.h) file of example class called User.
-// rtc::scoped_ptr<JNIEnvironment> env;
-// rtc::scoped_ptr<NativeRegistration> reg;
-// rtc::scoped_ptr<GlobalRef> obj;
+// std::unique_ptr<JNIEnvironment> env;
+// std::unique_ptr<NativeRegistration> reg;
+// std::unique_ptr<GlobalRef> obj;
//
// // Construction (in .cc file) of User class.
// User::User() {
@@ -156,7 +157,7 @@
// Creates a JNIEnvironment object.
// This method returns a NULL pointer if AttachCurrentThread() has not been
// called successfully. Use the AttachCurrentThreadIfNeeded class if needed.
- rtc::scoped_ptr<JNIEnvironment> environment();
+ std::unique_ptr<JNIEnvironment> environment();
// Returns a JavaClass object given class |name|.
// Note that the class name must be one of the names in the static
diff --git a/webrtc/modules/utility/include/mock/mock_process_thread.h b/webrtc/modules/utility/include/mock/mock_process_thread.h
index 9560e40..3d39307 100644
--- a/webrtc/modules/utility/include/mock/mock_process_thread.h
+++ b/webrtc/modules/utility/include/mock/mock_process_thread.h
@@ -31,7 +31,7 @@
// MOCK_METHOD1 gets confused with mocking this method, so we work around it
// by overriding the method from the interface and forwarding the call to a
// mocked, simpler method.
- void PostTask(rtc::scoped_ptr<ProcessTask> task) override {
+ void PostTask(std::unique_ptr<ProcessTask> task) override {
PostTask(task.get());
}
};
diff --git a/webrtc/modules/utility/include/process_thread.h b/webrtc/modules/utility/include/process_thread.h
index 285a5ea..f6913ea 100644
--- a/webrtc/modules/utility/include/process_thread.h
+++ b/webrtc/modules/utility/include/process_thread.h
@@ -11,8 +11,9 @@
#ifndef WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
+#include <memory>
+
#include "webrtc/typedefs.h"
-#include "webrtc/base/scoped_ptr.h"
namespace webrtc {
class Module;
@@ -29,7 +30,7 @@
public:
virtual ~ProcessThread();
- static rtc::scoped_ptr<ProcessThread> Create(const char* thread_name);
+ static std::unique_ptr<ProcessThread> Create(const char* thread_name);
// Starts the worker thread. Must be called from the construction thread.
virtual void Start() = 0;
@@ -50,7 +51,7 @@
// construction thread of the ProcessThread instance, if the task did not
// get a chance to run (e.g. posting the task while shutting down or when
// the thread never runs).
- virtual void PostTask(rtc::scoped_ptr<ProcessTask> task) = 0;
+ virtual void PostTask(std::unique_ptr<ProcessTask> task) = 0;
// Adds a module that will start to receive callbacks on the worker thread.
// Can be called from any thread.
diff --git a/webrtc/modules/utility/source/jvm_android.cc b/webrtc/modules/utility/source/jvm_android.cc
index eb37fda..d53d1b5 100644
--- a/webrtc/modules/utility/source/jvm_android.cc
+++ b/webrtc/modules/utility/source/jvm_android.cc
@@ -10,6 +10,8 @@
#include <android/log.h>
+#include <memory>
+
#include "webrtc/modules/utility/include/jvm_android.h"
#include "webrtc/base/checks.h"
@@ -139,7 +141,7 @@
CHECK_EXCEPTION(jni_) << "Error during UnregisterNatives";
}
-rtc::scoped_ptr<GlobalRef> NativeRegistration::NewObject(
+std::unique_ptr<GlobalRef> NativeRegistration::NewObject(
const char* name, const char* signature, ...) {
ALOGD("NativeRegistration::NewObject%s", GetThreadInfo().c_str());
va_list args;
@@ -149,7 +151,7 @@
args);
CHECK_EXCEPTION(jni_) << "Error during NewObjectV";
va_end(args);
- return rtc::scoped_ptr<GlobalRef>(new GlobalRef(jni_, obj));
+ return std::unique_ptr<GlobalRef>(new GlobalRef(jni_, obj));
}
// JavaClass implementation.
@@ -181,14 +183,14 @@
RTC_DCHECK(thread_checker_.CalledOnValidThread());
}
-rtc::scoped_ptr<NativeRegistration> JNIEnvironment::RegisterNatives(
+std::unique_ptr<NativeRegistration> JNIEnvironment::RegisterNatives(
const char* name, const JNINativeMethod *methods, int num_methods) {
ALOGD("JNIEnvironment::RegisterNatives(%s)", name);
RTC_DCHECK(thread_checker_.CalledOnValidThread());
jclass clazz = LookUpClass(name);
jni_->RegisterNatives(clazz, methods, num_methods);
CHECK_EXCEPTION(jni_) << "Error during RegisterNatives";
- return rtc::scoped_ptr<NativeRegistration>(
+ return std::unique_ptr<NativeRegistration>(
new NativeRegistration(jni_, clazz));
}
@@ -240,7 +242,7 @@
DeleteGlobalRef(jni(), context_);
}
-rtc::scoped_ptr<JNIEnvironment> JVM::environment() {
+std::unique_ptr<JNIEnvironment> JVM::environment() {
ALOGD("JVM::environment%s", GetThreadInfo().c_str());
// The JNIEnv is used for thread-local storage. For this reason, we cannot
// share a JNIEnv between threads. If a piece of code has no other way to get
@@ -250,9 +252,9 @@
JNIEnv* jni = GetEnv(jvm_);
if (!jni) {
ALOGE("AttachCurrentThread() has not been called on this thread.");
- return rtc::scoped_ptr<JNIEnvironment>();
+ return std::unique_ptr<JNIEnvironment>();
}
- return rtc::scoped_ptr<JNIEnvironment>(new JNIEnvironment(jni));
+ return std::unique_ptr<JNIEnvironment>(new JNIEnvironment(jni));
}
JavaClass JVM::GetClass(const char* name) {
diff --git a/webrtc/modules/utility/source/process_thread_impl.cc b/webrtc/modules/utility/source/process_thread_impl.cc
index 8cdf016..68c7ab6 100644
--- a/webrtc/modules/utility/source/process_thread_impl.cc
+++ b/webrtc/modules/utility/source/process_thread_impl.cc
@@ -36,9 +36,9 @@
ProcessThread::~ProcessThread() {}
// static
-rtc::scoped_ptr<ProcessThread> ProcessThread::Create(
+std::unique_ptr<ProcessThread> ProcessThread::Create(
const char* thread_name) {
- return rtc::scoped_ptr<ProcessThread>(new ProcessThreadImpl(thread_name));
+ return std::unique_ptr<ProcessThread>(new ProcessThreadImpl(thread_name));
}
ProcessThreadImpl::ProcessThreadImpl(const char* thread_name)
@@ -119,7 +119,7 @@
wake_up_->Set();
}
-void ProcessThreadImpl::PostTask(rtc::scoped_ptr<ProcessTask> task) {
+void ProcessThreadImpl::PostTask(std::unique_ptr<ProcessTask> task) {
// Allowed to be called on any thread.
{
rtc::CritScope lock(&lock_);
diff --git a/webrtc/modules/utility/source/process_thread_impl.h b/webrtc/modules/utility/source/process_thread_impl.h
index 2855ed9..330aec9 100644
--- a/webrtc/modules/utility/source/process_thread_impl.h
+++ b/webrtc/modules/utility/source/process_thread_impl.h
@@ -33,7 +33,7 @@
void Stop() override;
void WakeUp(Module* module) override;
- void PostTask(rtc::scoped_ptr<ProcessTask> task) override;
+ void PostTask(std::unique_ptr<ProcessTask> task) override;
void RegisterModule(Module* module) override;
void DeRegisterModule(Module* module) override;