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

Side by Side Diff: remoting/protocol/channel_multiplexer.cc

Issue 841773005: Cleanup channel dispatchers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « remoting/protocol/channel_multiplexer.h ('k') | remoting/protocol/client_control_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 std::swap(cb, read_callback_); 341 std::swap(cb, read_callback_);
342 cb.Run(result); 342 cb.Run(result);
343 } 343 }
344 } 344 }
345 345
346 ChannelMultiplexer::ChannelMultiplexer(StreamChannelFactory* factory, 346 ChannelMultiplexer::ChannelMultiplexer(StreamChannelFactory* factory,
347 const std::string& base_channel_name) 347 const std::string& base_channel_name)
348 : base_channel_factory_(factory), 348 : base_channel_factory_(factory),
349 base_channel_name_(base_channel_name), 349 base_channel_name_(base_channel_name),
350 next_channel_id_(0), 350 next_channel_id_(0),
351 parser_(base::Bind(&ChannelMultiplexer::OnIncomingPacket,
352 base::Unretained(this)),
353 &reader_),
351 weak_factory_(this) { 354 weak_factory_(this) {
352 } 355 }
353 356
354 ChannelMultiplexer::~ChannelMultiplexer() { 357 ChannelMultiplexer::~ChannelMultiplexer() {
355 DCHECK(pending_channels_.empty()); 358 DCHECK(pending_channels_.empty());
356 STLDeleteValues(&channels_); 359 STLDeleteValues(&channels_);
357 360
358 // Cancel creation of the base channel if it hasn't finished. 361 // Cancel creation of the base channel if it hasn't finished.
359 if (base_channel_factory_) 362 if (base_channel_factory_)
360 base_channel_factory_->CancelChannelCreation(base_channel_name_); 363 base_channel_factory_->CancelChannelCreation(base_channel_name_);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 396 }
394 } 397 }
395 398
396 void ChannelMultiplexer::OnBaseChannelReady( 399 void ChannelMultiplexer::OnBaseChannelReady(
397 scoped_ptr<net::StreamSocket> socket) { 400 scoped_ptr<net::StreamSocket> socket) {
398 base_channel_factory_ = nullptr; 401 base_channel_factory_ = nullptr;
399 base_channel_ = socket.Pass(); 402 base_channel_ = socket.Pass();
400 403
401 if (base_channel_.get()) { 404 if (base_channel_.get()) {
402 // Initialize reader and writer. 405 // Initialize reader and writer.
403 reader_.Init(base_channel_.get(), 406 reader_.StartReading(base_channel_.get());
404 base::Bind(&ChannelMultiplexer::OnIncomingPacket,
405 base::Unretained(this)));
406 writer_.Init(base_channel_.get(), 407 writer_.Init(base_channel_.get(),
407 base::Bind(&ChannelMultiplexer::OnWriteFailed, 408 base::Bind(&ChannelMultiplexer::OnWriteFailed,
408 base::Unretained(this))); 409 base::Unretained(this)));
409 } 410 }
410 411
411 DoCreatePendingChannels(); 412 DoCreatePendingChannels();
412 } 413 }
413 414
414 void ChannelMultiplexer::DoCreatePendingChannels() { 415 void ChannelMultiplexer::DoCreatePendingChannels() {
415 if (pending_channels_.empty()) 416 if (pending_channels_.empty())
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 channel->OnIncomingPacket(packet.Pass(), done_task); 494 channel->OnIncomingPacket(packet.Pass(), done_task);
494 } 495 }
495 496
496 bool ChannelMultiplexer::DoWrite(scoped_ptr<MultiplexPacket> packet, 497 bool ChannelMultiplexer::DoWrite(scoped_ptr<MultiplexPacket> packet,
497 const base::Closure& done_task) { 498 const base::Closure& done_task) {
498 return writer_.Write(SerializeAndFrameMessage(*packet), done_task); 499 return writer_.Write(SerializeAndFrameMessage(*packet), done_task);
499 } 500 }
500 501
501 } // namespace protocol 502 } // namespace protocol
502 } // namespace remoting 503 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/channel_multiplexer.h ('k') | remoting/protocol/client_control_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698