Skip to content

Commit

Permalink
Convert //jingle from scoped_ptr to std::unique_ptr
Browse files Browse the repository at this point in the history
BUG=554298
R=sergeyu@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#388857}
  • Loading branch information
zetafunction authored and Commit bot committed Apr 21, 2016
1 parent 22de42f commit 18e946f
Show file tree
Hide file tree
Showing 36 changed files with 150 additions and 139 deletions.
2 changes: 1 addition & 1 deletion jingle/glue/chrome_async_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ bool ChromeAsyncSocket::StartTls(const std::string& domain_name) {
weak_ptr_factory_.InvalidateWeakPtrs();

DCHECK(transport_socket_.get());
scoped_ptr<net::ClientSocketHandle> socket_handle(
std::unique_ptr<net::ClientSocketHandle> socket_handle(
new net::ClientSocketHandle());
socket_handle->SetSocket(std::move(transport_socket_));
transport_socket_ = resolving_client_socket_factory_->CreateSSLClientSocket(
Expand Down
7 changes: 4 additions & 3 deletions jingle/glue/chrome_async_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

#include <stddef.h>

#include <memory>
#include <string>
#include <vector>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/net_errors.h"
Expand Down Expand Up @@ -182,15 +182,16 @@ class ChromeAsyncSocket : public buzz::AsyncSocket {
// Close functions.
void DoClose();

scoped_ptr<ResolvingClientSocketFactory> resolving_client_socket_factory_;
std::unique_ptr<ResolvingClientSocketFactory>
resolving_client_socket_factory_;

// buzz::AsyncSocket state.
buzz::AsyncSocket::State state_;
buzz::AsyncSocket::Error error_;
net::Error net_error_;

// NULL iff state() == STATE_CLOSED.
scoped_ptr<net::StreamSocket> transport_socket_;
std::unique_ptr<net::StreamSocket> transport_socket_;

// State for the read loop. |read_start_| <= |read_end_| <=
// |read_buf_->size()|. There's a read in flight (i.e.,
Expand Down
32 changes: 16 additions & 16 deletions jingle/glue/chrome_async_socket_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
#include "jingle/glue/chrome_async_socket.h"

#include <stddef.h>

#include <deque>
#include <memory>
#include <string>
#include <utility>

#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_pump_default.h"
#include "jingle/glue/resolving_client_socket_factory.h"
Expand Down Expand Up @@ -124,14 +125,14 @@ class MockXmppClientSocketFactory : public ResolvingClientSocketFactory {
}

// ResolvingClientSocketFactory implementation.
scoped_ptr<net::StreamSocket> CreateTransportClientSocket(
std::unique_ptr<net::StreamSocket> CreateTransportClientSocket(
const net::HostPortPair& host_and_port) override {
return mock_client_socket_factory_->CreateTransportClientSocket(
address_list_, NULL, NULL, net::NetLog::Source());
}

scoped_ptr<net::SSLClientSocket> CreateSSLClientSocket(
scoped_ptr<net::ClientSocketHandle> transport_socket,
std::unique_ptr<net::SSLClientSocket> CreateSSLClientSocket(
std::unique_ptr<net::ClientSocketHandle> transport_socket,
const net::HostPortPair& host_and_port) override {
net::SSLClientSocketContext context;
context.cert_verifier = cert_verifier_.get();
Expand All @@ -141,11 +142,11 @@ class MockXmppClientSocketFactory : public ResolvingClientSocketFactory {
}

private:
scoped_ptr<net::ClientSocketFactory> mock_client_socket_factory_;
std::unique_ptr<net::ClientSocketFactory> mock_client_socket_factory_;
net::AddressList address_list_;
net::SSLConfig ssl_config_;
scoped_ptr<net::CertVerifier> cert_verifier_;
scoped_ptr<net::TransportSecurityState> transport_security_state_;
std::unique_ptr<net::CertVerifier> cert_verifier_;
std::unique_ptr<net::TransportSecurityState> transport_security_state_;
};

class ChromeAsyncSocketTest
Expand All @@ -160,14 +161,14 @@ class ChromeAsyncSocketTest
// __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__
// when called.
// Explicitly create a MessagePumpDefault which can run in this enivronment.
scoped_ptr<base::MessagePump> pump(new base::MessagePumpDefault());
std::unique_ptr<base::MessagePump> pump(new base::MessagePumpDefault());
message_loop_.reset(new base::MessageLoop(std::move(pump)));
}

~ChromeAsyncSocketTest() override {}

void SetUp() override {
scoped_ptr<net::MockClientSocketFactory> mock_client_socket_factory(
std::unique_ptr<net::MockClientSocketFactory> mock_client_socket_factory(
new net::MockClientSocketFactory());
mock_client_socket_factory->AddSocketDataProvider(
&async_socket_data_provider_);
Expand All @@ -177,10 +178,9 @@ class ChromeAsyncSocketTest
// Fake DNS resolution for |addr_| and pass it to the factory.
const net::AddressList address_list = net::AddressList::CreateFromIPAddress(
net::IPAddress::IPv4Localhost(), addr_.port());
scoped_ptr<MockXmppClientSocketFactory> mock_xmpp_client_socket_factory(
new MockXmppClientSocketFactory(
mock_client_socket_factory.release(),
address_list));
std::unique_ptr<MockXmppClientSocketFactory>
mock_xmpp_client_socket_factory(new MockXmppClientSocketFactory(
mock_client_socket_factory.release(), address_list));
chrome_async_socket_.reset(
new ChromeAsyncSocket(mock_xmpp_client_socket_factory.release(),
14, 20)),
Expand Down Expand Up @@ -414,7 +414,7 @@ class ChromeAsyncSocketTest

std::string DrainRead(size_t buf_size) {
std::string read;
scoped_ptr<char[]> buf(new char[buf_size]);
std::unique_ptr<char[]> buf(new char[buf_size]);
size_t len_read;
while (true) {
bool success =
Expand All @@ -432,12 +432,12 @@ class ChromeAsyncSocketTest
}

// ChromeAsyncSocket expects a message loop.
scoped_ptr<base::MessageLoop> message_loop_;
std::unique_ptr<base::MessageLoop> message_loop_;

AsyncSocketDataProvider async_socket_data_provider_;
net::SSLSocketDataProvider ssl_socket_data_provider_;

scoped_ptr<ChromeAsyncSocket> chrome_async_socket_;
std::unique_ptr<ChromeAsyncSocket> chrome_async_socket_;
std::deque<SignalSocketState> signal_socket_states_;
const rtc::SocketAddress addr_;

Expand Down
2 changes: 1 addition & 1 deletion jingle/glue/fake_ssl_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ base::StringPiece FakeSSLClientSocket::GetSslServerHello() {
}

FakeSSLClientSocket::FakeSSLClientSocket(
scoped_ptr<net::StreamSocket> transport_socket)
std::unique_ptr<net::StreamSocket> transport_socket)
: transport_socket_(std::move(transport_socket)),
next_handshake_state_(STATE_NONE),
handshake_completed_(false),
Expand Down
7 changes: 4 additions & 3 deletions jingle/glue/fake_ssl_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include <stdint.h>

#include <cstddef>
#include <memory>

#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "net/base/completion_callback.h"
#include "net/base/net_errors.h"
Expand All @@ -37,7 +37,8 @@ namespace jingle_glue {

class FakeSSLClientSocket : public net::StreamSocket {
public:
explicit FakeSSLClientSocket(scoped_ptr<net::StreamSocket> transport_socket);
explicit FakeSSLClientSocket(
std::unique_ptr<net::StreamSocket> transport_socket);

~FakeSSLClientSocket() override;

Expand Down Expand Up @@ -97,7 +98,7 @@ class FakeSSLClientSocket : public net::StreamSocket {
void OnVerifyServerHelloDone(int status);
net::Error ProcessVerifyServerHelloDone(size_t read);

scoped_ptr<net::StreamSocket> transport_socket_;
std::unique_ptr<net::StreamSocket> transport_socket_;

// During the handshake process, holds a value from HandshakeState.
// STATE_NONE otherwise.
Expand Down
9 changes: 5 additions & 4 deletions jingle/glue/fake_ssl_client_socket_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <memory>
#include <utility>
#include <vector>

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_address.h"
Expand Down Expand Up @@ -99,7 +100,7 @@ class FakeSSLClientSocketTest : public testing::Test {

~FakeSSLClientSocketTest() override {}

scoped_ptr<net::StreamSocket> MakeClientSocket() {
std::unique_ptr<net::StreamSocket> MakeClientSocket() {
return mock_client_socket_factory_.CreateTransportClientSocket(
net::AddressList(), NULL, NULL, net::NetLog::Source());
}
Expand Down Expand Up @@ -273,11 +274,11 @@ class FakeSSLClientSocketTest : public testing::Test {
base::MessageLoop message_loop_;

net::MockClientSocketFactory mock_client_socket_factory_;
scoped_ptr<net::StaticSocketDataProvider> static_socket_data_provider_;
std::unique_ptr<net::StaticSocketDataProvider> static_socket_data_provider_;
};

TEST_F(FakeSSLClientSocketTest, PassThroughMethods) {
scoped_ptr<MockClientSocket> mock_client_socket(new MockClientSocket());
std::unique_ptr<MockClientSocket> mock_client_socket(new MockClientSocket());
const int kReceiveBufferSize = 10;
const int kSendBufferSize = 20;
net::IPEndPoint ip_endpoint(net::IPAddress::IPv4AllZeros(), 80);
Expand Down
7 changes: 4 additions & 3 deletions jingle/glue/proxy_resolving_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

#include <stdint.h>

#include <memory>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/host_port_pair.h"
Expand Down Expand Up @@ -93,10 +94,10 @@ class ProxyResolvingClientSocket : public net::StreamSocket {
net::CompletionCallback proxy_resolve_callback_;
net::CompletionCallback connect_callback_;

scoped_ptr<net::HttpNetworkSession> network_session_;
std::unique_ptr<net::HttpNetworkSession> network_session_;

// The transport socket.
scoped_ptr<net::ClientSocketHandle> transport_;
std::unique_ptr<net::ClientSocketHandle> transport_;

const net::SSLConfig ssl_config_;
net::ProxyService::PacRequest* pac_request_;
Expand Down
2 changes: 1 addition & 1 deletion jingle/glue/proxy_resolving_client_socket_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ProxyResolvingClientSocketTest : public testing::Test {
ProxyResolvingClientSocketTest()
: url_request_context_getter_(new net::TestURLRequestContextGetter(
base::ThreadTaskRunnerHandle::Get(),
scoped_ptr<net::TestURLRequestContext>(
std::unique_ptr<net::TestURLRequestContext>(
new MyTestURLRequestContext))) {}

~ProxyResolvingClientSocketTest() override {}
Expand Down
8 changes: 4 additions & 4 deletions jingle/glue/resolving_client_socket_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef JINGLE_GLUE_RESOLVING_CLIENT_SOCKET_FACTORY_H_
#define JINGLE_GLUE_RESOLVING_CLIENT_SOCKET_FACTORY_H_

#include "base/memory/scoped_ptr.h"
#include <memory>

namespace net {
class ClientSocketHandle;
Expand All @@ -24,11 +24,11 @@ class ResolvingClientSocketFactory {
public:
virtual ~ResolvingClientSocketFactory() { }
// Method to create a transport socket using a HostPortPair.
virtual scoped_ptr<net::StreamSocket> CreateTransportClientSocket(
virtual std::unique_ptr<net::StreamSocket> CreateTransportClientSocket(
const net::HostPortPair& host_and_port) = 0;

virtual scoped_ptr<net::SSLClientSocket> CreateSSLClientSocket(
scoped_ptr<net::ClientSocketHandle> transport_socket,
virtual std::unique_ptr<net::SSLClientSocket> CreateSSLClientSocket(
std::unique_ptr<net::ClientSocketHandle> transport_socket,
const net::HostPortPair& host_and_port) = 0;
};

Expand Down
7 changes: 4 additions & 3 deletions jingle/glue/thread_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ base::LazyInstance<base::ThreadLocalPointer<JingleThreadWrapper> >
void JingleThreadWrapper::EnsureForCurrentMessageLoop() {
if (JingleThreadWrapper::current() == nullptr) {
base::MessageLoop* message_loop = base::MessageLoop::current();
scoped_ptr<JingleThreadWrapper> wrapper =
std::unique_ptr<JingleThreadWrapper> wrapper =
JingleThreadWrapper::WrapTaskRunner(message_loop->task_runner());
message_loop->AddDestructionObserver(wrapper.release());
}

DCHECK_EQ(rtc::Thread::Current(), current());
}

scoped_ptr<JingleThreadWrapper> JingleThreadWrapper::WrapTaskRunner(
std::unique_ptr<JingleThreadWrapper> JingleThreadWrapper::WrapTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
DCHECK(!JingleThreadWrapper::current());
DCHECK(task_runner->BelongsToCurrentThread());

scoped_ptr<JingleThreadWrapper> result(new JingleThreadWrapper(task_runner));
std::unique_ptr<JingleThreadWrapper> result(
new JingleThreadWrapper(task_runner));
g_jingle_thread_wrapper.Get().Set(result.get());
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions jingle/glue/thread_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include <list>
#include <map>
#include <memory>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
Expand Down Expand Up @@ -41,7 +41,7 @@ class JingleThreadWrapper : public base::MessageLoop::DestructionObserver,

// Creates JingleThreadWrapper for |task_runner| that runs tasks on the
// current thread.
static scoped_ptr<JingleThreadWrapper> WrapTaskRunner(
static std::unique_ptr<JingleThreadWrapper> WrapTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);

// Returns thread wrapper for the current thread or nullptr if it doesn't
Expand Down
5 changes: 3 additions & 2 deletions jingle/glue/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

#include <stdint.h>

#include <memory>

#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
Expand Down Expand Up @@ -69,7 +70,7 @@ std::string SerializeP2PCandidate(const cricket::Candidate& candidate) {

bool DeserializeP2PCandidate(const std::string& candidate_str,
cricket::Candidate* candidate) {
scoped_ptr<base::Value> value(
std::unique_ptr<base::Value> value(
base::JSONReader::Read(candidate_str, base::JSON_ALLOW_TRAILING_COMMAS));
if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) {
return false;
Expand Down
17 changes: 7 additions & 10 deletions jingle/glue/xmpp_client_socket_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,22 @@ XmppClientSocketFactory::XmppClientSocketFactory(

XmppClientSocketFactory::~XmppClientSocketFactory() {}

scoped_ptr<net::StreamSocket>
std::unique_ptr<net::StreamSocket>
XmppClientSocketFactory::CreateTransportClientSocket(
const net::HostPortPair& host_and_port) {
// TODO(akalin): Use socket pools.
scoped_ptr<net::StreamSocket> transport_socket(
new ProxyResolvingClientSocket(
NULL,
request_context_getter_,
ssl_config_,
host_and_port));
std::unique_ptr<net::StreamSocket> transport_socket(
new ProxyResolvingClientSocket(NULL, request_context_getter_, ssl_config_,
host_and_port));
return (use_fake_ssl_client_socket_
? scoped_ptr<net::StreamSocket>(
? std::unique_ptr<net::StreamSocket>(
new FakeSSLClientSocket(std::move(transport_socket)))
: std::move(transport_socket));
}

scoped_ptr<net::SSLClientSocket>
std::unique_ptr<net::SSLClientSocket>
XmppClientSocketFactory::CreateSSLClientSocket(
scoped_ptr<net::ClientSocketHandle> transport_socket,
std::unique_ptr<net::ClientSocketHandle> transport_socket,
const net::HostPortPair& host_and_port) {
net::SSLClientSocketContext context;
context.cert_verifier =
Expand Down
Loading

0 comments on commit 18e946f

Please sign in to comment.