Replace the remaining scoped_ptr with unique_ptr in webrtc/modules/

(This is a re-land of https://codereview.webrtc.org/1921233002, which
got reverted for breaking Chromium.)

BUG=webrtc:5520

Review URL: https://codereview.webrtc.org/1923133002

Cr-Commit-Position: refs/heads/master@{#12522}
This commit is contained in:
kwiberg
2016-04-27 01:19:58 -07:00
committed by Commit bot
parent 90c335a100
commit 84be511ac0
60 changed files with 195 additions and 138 deletions

View File

@ -12,6 +12,8 @@
#define WEBRTC_MODULES_UTILITY_INCLUDE_JVM_ANDROID_H_
#include <jni.h>
#include <memory>
#include <string>
#include "webrtc/base/scoped_ptr.h"
@ -76,7 +78,7 @@ class NativeRegistration : public JavaClass {
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 +98,7 @@ class JNIEnvironment {
// 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 +122,9 @@ class JNIEnvironment {
// 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 +158,7 @@ class JVM {
// 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

View File

@ -31,7 +31,7 @@ class MockProcessThread : public ProcessThread {
// 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());
}
};

View File

@ -11,6 +11,8 @@
#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"
@ -29,7 +31,7 @@ class ProcessThread {
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 +52,7 @@ class ProcessThread {
// 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.