Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: remoting/protocol/channel_multiplexer.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/channel_multiplexer.h ('k') | remoting/protocol/channel_multiplexer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/channel_multiplexer.cc
diff --git a/remoting/protocol/channel_multiplexer.cc b/remoting/protocol/channel_multiplexer.cc
index 1ac07ffdf83537de5b99fa52ce24eab41541f840..4ea40151acff2cc1f4ea2946863a5294074ef8f3 100644
--- a/remoting/protocol/channel_multiplexer.cc
+++ b/remoting/protocol/channel_multiplexer.cc
@@ -30,7 +30,7 @@ const int kMaxPacketSize = 1024;
class PendingPacket {
public:
- PendingPacket(scoped_ptr<MultiplexPacket> packet)
+ PendingPacket(std::unique_ptr<MultiplexPacket> packet)
: packet(std::move(packet)) {}
~PendingPacket() {}
@@ -44,7 +44,7 @@ class PendingPacket {
}
private:
- scoped_ptr<MultiplexPacket> packet;
+ std::unique_ptr<MultiplexPacket> packet;
size_t pos = 0U;
DISALLOW_COPY_AND_ASSIGN(PendingPacket);
@@ -74,13 +74,13 @@ class ChannelMultiplexer::MuxChannel {
void set_receive_id(int id) { receive_id_ = id; }
// Called by ChannelMultiplexer.
- scoped_ptr<P2PStreamSocket> CreateSocket();
- void OnIncomingPacket(scoped_ptr<MultiplexPacket> packet);
+ std::unique_ptr<P2PStreamSocket> CreateSocket();
+ void OnIncomingPacket(std::unique_ptr<MultiplexPacket> packet);
void OnBaseChannelError(int error);
// Called by MuxSocket.
void OnSocketDestroyed();
- void DoWrite(scoped_ptr<MultiplexPacket> packet,
+ void DoWrite(std::unique_ptr<MultiplexPacket> packet,
const base::Closure& done_task);
int DoRead(const scoped_refptr<net::IOBuffer>& buffer, int buffer_len);
@@ -148,15 +148,16 @@ ChannelMultiplexer::MuxChannel::~MuxChannel() {
STLDeleteElements(&pending_packets_);
}
-scoped_ptr<P2PStreamSocket> ChannelMultiplexer::MuxChannel::CreateSocket() {
+std::unique_ptr<P2PStreamSocket>
+ChannelMultiplexer::MuxChannel::CreateSocket() {
DCHECK(!socket_); // Can't create more than one socket per channel.
- scoped_ptr<MuxSocket> result(new MuxSocket(this));
+ std::unique_ptr<MuxSocket> result(new MuxSocket(this));
socket_ = result.get();
return std::move(result);
}
void ChannelMultiplexer::MuxChannel::OnIncomingPacket(
- scoped_ptr<MultiplexPacket> packet) {
+ std::unique_ptr<MultiplexPacket> packet) {
DCHECK_EQ(packet->channel_id(), receive_id_);
if (packet->data().size() > 0) {
pending_packets_.push_back(new PendingPacket(std::move(packet)));
@@ -178,7 +179,7 @@ void ChannelMultiplexer::MuxChannel::OnSocketDestroyed() {
}
void ChannelMultiplexer::MuxChannel::DoWrite(
- scoped_ptr<MultiplexPacket> packet,
+ std::unique_ptr<MultiplexPacket> packet,
const base::Closure& done_task) {
packet->set_channel_id(send_id_);
if (!id_sent_) {
@@ -246,7 +247,7 @@ int ChannelMultiplexer::MuxSocket::Write(
if (base_channel_error_ != net::OK)
return base_channel_error_;
- scoped_ptr<MultiplexPacket> packet(new MultiplexPacket());
+ std::unique_ptr<MultiplexPacket> packet(new MultiplexPacket());
size_t size = std::min(kMaxPacketSize, buffer_len);
packet->mutable_data()->assign(buffer->data(), size);
@@ -350,7 +351,7 @@ void ChannelMultiplexer::CancelChannelCreation(const std::string& name) {
}
void ChannelMultiplexer::OnBaseChannelReady(
- scoped_ptr<P2PStreamSocket> socket) {
+ std::unique_ptr<P2PStreamSocket> socket) {
base_channel_factory_ = nullptr;
base_channel_ = std::move(socket);
@@ -384,7 +385,7 @@ void ChannelMultiplexer::DoCreatePendingChannels() {
PendingChannel c = pending_channels_.front();
pending_channels_.erase(pending_channels_.begin());
- scoped_ptr<P2PStreamSocket> socket;
+ std::unique_ptr<P2PStreamSocket> socket;
if (base_channel_.get())
socket = GetOrCreateChannel(c.name)->CreateSocket();
c.callback.Run(std::move(socket));
@@ -422,8 +423,9 @@ void ChannelMultiplexer::NotifyBaseChannelError(const std::string& name,
it->second->OnBaseChannelError(error);
}
-void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<CompoundBuffer> buffer) {
- scoped_ptr<MultiplexPacket> packet =
+void ChannelMultiplexer::OnIncomingPacket(
+ std::unique_ptr<CompoundBuffer> buffer) {
+ std::unique_ptr<MultiplexPacket> packet =
ParseMessage<MultiplexPacket>(buffer.get());
if (!packet)
return;
@@ -455,7 +457,7 @@ void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<CompoundBuffer> buffer) {
channel->OnIncomingPacket(std::move(packet));
}
-void ChannelMultiplexer::DoWrite(scoped_ptr<MultiplexPacket> packet,
+void ChannelMultiplexer::DoWrite(std::unique_ptr<MultiplexPacket> packet,
const base::Closure& done_task) {
writer_.Write(SerializeAndFrameMessage(*packet), done_task);
}
« no previous file with comments | « remoting/protocol/channel_multiplexer.h ('k') | remoting/protocol/channel_multiplexer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698