OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/protocol/channel_multiplexer.h" | 5 #include "remoting/protocol/channel_multiplexer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 name_(name), | 138 name_(name), |
139 send_id_(send_id), | 139 send_id_(send_id), |
140 id_sent_(false), | 140 id_sent_(false), |
141 receive_id_(kChannelIdUnknown), | 141 receive_id_(kChannelIdUnknown), |
142 socket_(nullptr) { | 142 socket_(nullptr) { |
143 } | 143 } |
144 | 144 |
145 ChannelMultiplexer::MuxChannel::~MuxChannel() { | 145 ChannelMultiplexer::MuxChannel::~MuxChannel() { |
146 // Socket must be destroyed before the channel. | 146 // Socket must be destroyed before the channel. |
147 DCHECK(!socket_); | 147 DCHECK(!socket_); |
148 STLDeleteElements(&pending_packets_); | 148 base::STLDeleteElements(&pending_packets_); |
149 } | 149 } |
150 | 150 |
151 std::unique_ptr<P2PStreamSocket> | 151 std::unique_ptr<P2PStreamSocket> |
152 ChannelMultiplexer::MuxChannel::CreateSocket() { | 152 ChannelMultiplexer::MuxChannel::CreateSocket() { |
153 DCHECK(!socket_); // Can't create more than one socket per channel. | 153 DCHECK(!socket_); // Can't create more than one socket per channel. |
154 std::unique_ptr<MuxSocket> result(new MuxSocket(this)); | 154 std::unique_ptr<MuxSocket> result(new MuxSocket(this)); |
155 socket_ = result.get(); | 155 socket_ = result.get(); |
156 return std::move(result); | 156 return std::move(result); |
157 } | 157 } |
158 | 158 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 ChannelMultiplexer::ChannelMultiplexer(StreamChannelFactory* factory, | 304 ChannelMultiplexer::ChannelMultiplexer(StreamChannelFactory* factory, |
305 const std::string& base_channel_name) | 305 const std::string& base_channel_name) |
306 : base_channel_factory_(factory), | 306 : base_channel_factory_(factory), |
307 base_channel_name_(base_channel_name), | 307 base_channel_name_(base_channel_name), |
308 next_channel_id_(0), | 308 next_channel_id_(0), |
309 weak_factory_(this) {} | 309 weak_factory_(this) {} |
310 | 310 |
311 ChannelMultiplexer::~ChannelMultiplexer() { | 311 ChannelMultiplexer::~ChannelMultiplexer() { |
312 DCHECK(pending_channels_.empty()); | 312 DCHECK(pending_channels_.empty()); |
313 STLDeleteValues(&channels_); | 313 base::STLDeleteValues(&channels_); |
314 | 314 |
315 // Cancel creation of the base channel if it hasn't finished. | 315 // Cancel creation of the base channel if it hasn't finished. |
316 if (base_channel_factory_) | 316 if (base_channel_factory_) |
317 base_channel_factory_->CancelChannelCreation(base_channel_name_); | 317 base_channel_factory_->CancelChannelCreation(base_channel_name_); |
318 } | 318 } |
319 | 319 |
320 void ChannelMultiplexer::CreateChannel(const std::string& name, | 320 void ChannelMultiplexer::CreateChannel(const std::string& name, |
321 const ChannelCreatedCallback& callback) { | 321 const ChannelCreatedCallback& callback) { |
322 if (base_channel_.get()) { | 322 if (base_channel_.get()) { |
323 // Already have |base_channel_|. Create new multiplexed channel | 323 // Already have |base_channel_|. Create new multiplexed channel |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 channel->OnIncomingPacket(std::move(packet)); | 457 channel->OnIncomingPacket(std::move(packet)); |
458 } | 458 } |
459 | 459 |
460 void ChannelMultiplexer::DoWrite(std::unique_ptr<MultiplexPacket> packet, | 460 void ChannelMultiplexer::DoWrite(std::unique_ptr<MultiplexPacket> packet, |
461 const base::Closure& done_task) { | 461 const base::Closure& done_task) { |
462 writer_.Write(SerializeAndFrameMessage(*packet), done_task); | 462 writer_.Write(SerializeAndFrameMessage(*packet), done_task); |
463 } | 463 } |
464 | 464 |
465 } // namespace protocol | 465 } // namespace protocol |
466 } // namespace remoting | 466 } // namespace remoting |
OLD | NEW |