Commit 0765c49a authored by dcheng's avatar dcheng Committed by Commit bot

Convert //remoting to use std::unique_ptr

BUG=554298
R=wez@chromium.org,rdevlin.cronin@chromium.org

Review URL: https://codereview.chromium.org/1864213002

Cr-Commit-Position: refs/heads/master@{#385571}
parent 45e5face
......@@ -6,6 +6,7 @@
#define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
namespace base {
class Value;
......
......@@ -22,9 +22,9 @@ namespace remoting {
namespace {
#if defined(OS_WIN)
scoped_ptr<base::win::ScopedCOMInitializer> CreateComInitializer(
std::unique_ptr<base::win::ScopedCOMInitializer> CreateComInitializer(
AutoThread::ComInitType type) {
scoped_ptr<base::win::ScopedCOMInitializer> initializer;
std::unique_ptr<base::win::ScopedCOMInitializer> initializer;
if (type == AutoThread::COM_INIT_MTA) {
initializer.reset(new base::win::ScopedCOMInitializer(
base::win::ScopedCOMInitializer::kMTA));
......@@ -202,7 +202,7 @@ void AutoThread::ThreadMain() {
#if defined(OS_WIN)
// Initialize COM on the thread, if requested.
scoped_ptr<base::win::ScopedCOMInitializer> com_initializer(
std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer(
CreateComInitializer(com_init_type_));
#endif
......
......@@ -5,9 +5,10 @@
#ifndef REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_
#define REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_
#include <memory>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
......
......@@ -10,6 +10,8 @@
#include "remoting/base/breakpad.h"
#include <windows.h>
#include <memory>
#include <string>
#include "base/atomicops.h"
......@@ -17,7 +19,6 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/current_module.h"
#include "base/win/wrapped_window_proc.h"
......@@ -77,7 +78,7 @@ class BreakpadWin {
static int OnWindowProcedureException(EXCEPTION_POINTERS* exinfo);
// Breakpad's exception handler.
scoped_ptr<google_breakpad::ExceptionHandler> breakpad_;
std::unique_ptr<google_breakpad::ExceptionHandler> breakpad_;
// This flag is used to indicate that an exception is already being handled.
volatile AtomicWord handling_exception_;
......@@ -144,7 +145,7 @@ BreakpadWin* BreakpadWin::GetInstance() {
// Returns the Custom information to be used for crash reporting.
google_breakpad::CustomClientInfo* BreakpadWin::GetCustomInfo() {
scoped_ptr<FileVersionInfo> version_info(
std::unique_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForModule(CURRENT_MODULE()));
static wchar_t version[64];
......
......@@ -3,12 +3,13 @@
// found in the LICENSE file.
#include <stdio.h>
#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/environment.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "breakpad/src/client/windows/crash_generation/client_info.h"
......@@ -74,8 +75,8 @@ class BreakpadWinDeathTest : public testing::Test {
void SetUp() override;
protected:
scoped_ptr<google_breakpad::CrashGenerationServer> crash_server_;
scoped_ptr<MockCrashServerCallbacks> callbacks_;
std::unique_ptr<google_breakpad::CrashGenerationServer> crash_server_;
std::unique_ptr<MockCrashServerCallbacks> callbacks_;
std::wstring pipe_name_;
};
......@@ -86,7 +87,7 @@ BreakpadWinDeathTest::~BreakpadWinDeathTest() {
}
void BreakpadWinDeathTest::SetUp() {
scoped_ptr<base::Environment> environment(base::Environment::Create());
std::unique_ptr<base::Environment> environment(base::Environment::Create());
std::string pipe_name;
if (environment->GetVar(kPipeVariableName, &pipe_name)) {
// This is a child process. Initialize crash dump reporting to the crash
......
......@@ -36,10 +36,10 @@ struct BufferedSocketWriter::PendingPacket {
};
// static
scoped_ptr<BufferedSocketWriter> BufferedSocketWriter::CreateForSocket(
std::unique_ptr<BufferedSocketWriter> BufferedSocketWriter::CreateForSocket(
net::Socket* socket,
const WriteFailedCallback& write_failed_callback) {
scoped_ptr<BufferedSocketWriter> result(new BufferedSocketWriter());
std::unique_ptr<BufferedSocketWriter> result(new BufferedSocketWriter());
result->Start(base::Bind(&WriteNetSocket, socket), write_failed_callback);
return result;
}
......
......@@ -29,7 +29,7 @@ class BufferedSocketWriter {
WriteCallback;
typedef base::Callback<void(int)> WriteFailedCallback;
static scoped_ptr<BufferedSocketWriter> CreateForSocket(
static std::unique_ptr<BufferedSocketWriter> CreateForSocket(
net::Socket* socket,
const WriteFailedCallback& write_failed_callback);
......
......@@ -153,8 +153,8 @@ class BufferedSocketWriterTest : public testing::Test {
base::MessageLoop message_loop_;
net::NetLog net_log_;
SocketDataProvider socket_data_provider_;
scoped_ptr<net::StreamSocket> socket_;
scoped_ptr<BufferedSocketWriter> writer_;
std::unique_ptr<net::StreamSocket> socket_;
std::unique_ptr<BufferedSocketWriter> writer_;
scoped_refptr<net::IOBufferWithSize> test_buffer_;
scoped_refptr<net::IOBufferWithSize> test_buffer_2_;
int write_error_;
......
......@@ -5,6 +5,7 @@
#include "remoting/base/chromium_url_request.h"
#include "base/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
......@@ -67,10 +68,10 @@ ChromiumUrlRequestFactory::ChromiumUrlRequestFactory(
: url_context_(url_context) {}
ChromiumUrlRequestFactory::~ChromiumUrlRequestFactory() {}
scoped_ptr<UrlRequest> ChromiumUrlRequestFactory::CreateUrlRequest(
std::unique_ptr<UrlRequest> ChromiumUrlRequestFactory::CreateUrlRequest(
UrlRequest::Type type,
const std::string& url) {
return make_scoped_ptr(new ChromiumUrlRequest(url_context_, type, url));
return base::WrapUnique(new ChromiumUrlRequest(url_context_, type, url));
}
} // namespace remoting
......@@ -36,7 +36,7 @@ class ChromiumUrlRequest : public UrlRequest, public net::URLFetcherDelegate {
// net::URLFetcherDelegate interface.
void OnURLFetchComplete(const net::URLFetcher* url_fetcher) override;
scoped_ptr<net::URLFetcher> url_fetcher_;
std::unique_ptr<net::URLFetcher> url_fetcher_;
OnResultCallback on_result_callback_;
};
......@@ -47,8 +47,8 @@ class ChromiumUrlRequestFactory : public UrlRequestFactory {
~ChromiumUrlRequestFactory() override;
// UrlRequestFactory interface.
scoped_ptr<UrlRequest> CreateUrlRequest(UrlRequest::Type type,
const std::string& url) override;
std::unique_ptr<UrlRequest> CreateUrlRequest(UrlRequest::Type type,
const std::string& url) override;
private:
scoped_refptr<net::URLRequestContextGetter> url_context_;
......
......@@ -2,16 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/base/compound_buffer.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include "base/bind.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "net/base/io_buffer.h"
#include "remoting/base/compound_buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
using net::IOBuffer;
......@@ -140,14 +141,14 @@ class CompoundBufferTest : public testing::Test {
static void ReadString(CompoundBufferInputStream* input,
const std::string& str) {
SCOPED_TRACE(str);
scoped_ptr<char[]> buffer(new char[str.size() + 1]);
std::unique_ptr<char[]> buffer(new char[str.size() + 1]);
buffer[str.size()] = '\0';
EXPECT_EQ(ReadFromInput(input, buffer.get(), str.size()), str.size());
EXPECT_STREQ(str.data(), buffer.get());
}
// Construct and prepare data in the |buffer|.
static void PrepareData(scoped_ptr<CompoundBuffer>* buffer) {
static void PrepareData(std::unique_ptr<CompoundBuffer>* buffer) {
static const std::string kTestData =
"Hello world!"
"This is testing"
......@@ -261,7 +262,7 @@ TEST_F(CompoundBufferTest, CopyFrom) {
}
TEST_F(CompoundBufferTest, InputStream) {
scoped_ptr<CompoundBuffer> buffer;
std::unique_ptr<CompoundBuffer> buffer;
PrepareData(&buffer);
CompoundBufferInputStream stream(buffer.get());
......
......@@ -21,8 +21,8 @@
namespace remoting {
RsaKeyPair::RsaKeyPair(scoped_ptr<crypto::RSAPrivateKey> key)
: key_(std::move(key)){
RsaKeyPair::RsaKeyPair(std::unique_ptr<crypto::RSAPrivateKey> key)
: key_(std::move(key)) {
DCHECK(key_);
}
......@@ -30,7 +30,8 @@ RsaKeyPair::~RsaKeyPair() {}
// static
scoped_refptr<RsaKeyPair> RsaKeyPair::Generate() {
scoped_ptr<crypto::RSAPrivateKey> key(crypto::RSAPrivateKey::Create(2048));
std::unique_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::Create(2048));
if (!key) {
LOG(ERROR) << "Cannot generate private key.";
return NULL;
......@@ -48,7 +49,7 @@ scoped_refptr<RsaKeyPair> RsaKeyPair::FromString(
}
std::vector<uint8_t> key_buf(key_str.begin(), key_str.end());
scoped_ptr<crypto::RSAPrivateKey> key(
std::unique_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_buf));
if (!key) {
LOG(ERROR) << "Invalid private key.";
......@@ -80,7 +81,7 @@ std::string RsaKeyPair::GetPublicKey() const {
}
std::string RsaKeyPair::SignMessage(const std::string& message) const {
scoped_ptr<crypto::SignatureCreator> signature_creator(
std::unique_ptr<crypto::SignatureCreator> signature_creator(
crypto::SignatureCreator::Create(key_.get(),
crypto::SignatureCreator::SHA1));
signature_creator->Update(reinterpret_cast<const uint8_t*>(message.c_str()),
......
......@@ -5,11 +5,11 @@
#ifndef REMOTING_BASE_RSA_KEY_PAIR_H_
#define REMOTING_BASE_RSA_KEY_PAIR_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
namespace crypto {
class RSAPrivateKey;
......@@ -43,10 +43,10 @@ class RsaKeyPair : public base::RefCountedThreadSafe<RsaKeyPair> {
private:
friend class base::RefCountedThreadSafe<RsaKeyPair>;
RsaKeyPair(scoped_ptr<crypto::RSAPrivateKey> key);
RsaKeyPair(std::unique_ptr<crypto::RSAPrivateKey> key);
virtual ~RsaKeyPair();
scoped_ptr<crypto::RSAPrivateKey> key_;
std::unique_ptr<crypto::RSAPrivateKey> key_;
DISALLOW_COPY_AND_ASSIGN(RsaKeyPair);
};
......
......@@ -5,10 +5,10 @@
#ifndef REMOTING_BASE_URL_REQUEST_H_
#define REMOTING_BASE_URL_REQUEST_H_
#include <memory>
#include <string>
#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
namespace remoting {
......@@ -59,8 +59,9 @@ class UrlRequest {
class UrlRequestFactory {
public:
virtual ~UrlRequestFactory() {}
virtual scoped_ptr<UrlRequest> CreateUrlRequest(UrlRequest::Type type,
const std::string& url) = 0;
virtual std::unique_ptr<UrlRequest> CreateUrlRequest(
UrlRequest::Type type,
const std::string& url) = 0;
};
} // namespace remoting
......
......@@ -5,8 +5,9 @@
#ifndef REMOTING_BASE_URL_REQUEST_CONTEXT_GETTER_H_
#define REMOTING_BASE_URL_REQUEST_CONTEXT_GETTER_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "net/url_request/url_request_context_getter.h"
namespace base {
......@@ -37,9 +38,9 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
private:
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<net::NetLog> net_log_;
scoped_ptr<net::URLRequestContext> url_request_context_;
std::unique_ptr<net::ProxyConfigService> proxy_config_service_;
std::unique_ptr<net::NetLog> net_log_;
std::unique_ptr<net::URLRequestContext> url_request_context_;
DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
};
......
......@@ -4,10 +4,11 @@
#include "remoting/base/vlog_net_log.h"
#include <memory>
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "base/values.h"
......@@ -34,7 +35,7 @@ VlogNetLog::Observer::~Observer() {
void VlogNetLog::Observer::OnAddEntry(const net::NetLog::Entry& entry) {
if (VLOG_IS_ON(4)) {
scoped_ptr<base::Value> value(entry.ToValue());
std::unique_ptr<base::Value> value(entry.ToValue());
std::string json;
base::JSONWriter::Write(*value, &json);
VLOG(4) << json;
......
......@@ -5,8 +5,9 @@
#ifndef REMOTING_BASE_VLOG_NET_LOG_H_
#define REMOTING_BASE_VLOG_NET_LOG_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "net/log/net_log.h"
namespace remoting {
......@@ -22,7 +23,7 @@ class VlogNetLog : public net::NetLog {
private:
class Observer;
scoped_ptr<Observer> observer_;
std::unique_ptr<Observer> observer_;
DISALLOW_COPY_AND_ASSIGN(VlogNetLog);
};
......
......@@ -20,10 +20,10 @@ class AudioDecodeScheduler::Core : public base::RefCountedThreadSafe<Core> {
public:
Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner,
scoped_ptr<AudioPlayer> audio_player);
std::unique_ptr<AudioPlayer> audio_player);
void Initialize(const protocol::SessionConfig& config);
void ProcessAudioPacket(scoped_ptr<AudioPacket> packet,
void ProcessAudioPacket(std::unique_ptr<AudioPacket> packet,
const base::Closure& done);
// Called by AudioDecodeScheduler when it is destroyed.
......@@ -35,16 +35,17 @@ class AudioDecodeScheduler::Core : public base::RefCountedThreadSafe<Core> {
virtual ~Core();
// Called on the audio decoder thread.
void DecodePacket(scoped_ptr<AudioPacket> packet, const base::Closure& done);
void DecodePacket(std::unique_ptr<AudioPacket> packet,
const base::Closure& done);
// Called on the main thread.
void ProcessDecodedPacket(scoped_ptr<AudioPacket> packet,
void ProcessDecodedPacket(std::unique_ptr<AudioPacket> packet,
const base::Closure& done);
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner_;
scoped_ptr<AudioDecoder> decoder_;
scoped_ptr<AudioPlayer> audio_player_;
std::unique_ptr<AudioDecoder> decoder_;
std::unique_ptr<AudioPlayer> audio_player_;
DISALLOW_COPY_AND_ASSIGN(Core);
};
......@@ -52,7 +53,7 @@ class AudioDecodeScheduler::Core : public base::RefCountedThreadSafe<Core> {
AudioDecodeScheduler::Core::Core(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner,
scoped_ptr<AudioPlayer> audio_player)
std::unique_ptr<AudioPlayer> audio_player)
: main_task_runner_(main_task_runner),
audio_decode_task_runner_(audio_decode_task_runner),
audio_player_(std::move(audio_player)) {}
......@@ -66,7 +67,7 @@ void AudioDecodeScheduler::Core::Initialize(
}
void AudioDecodeScheduler::Core::ProcessAudioPacket(
scoped_ptr<AudioPacket> packet,
std::unique_ptr<AudioPacket> packet,
const base::Closure& done) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
audio_decode_task_runner_->PostTask(FROM_HERE, base::Bind(
......@@ -80,10 +81,11 @@ void AudioDecodeScheduler::Core::Detach() {
}
void AudioDecodeScheduler::Core::DecodePacket(
scoped_ptr<AudioPacket> packet,