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

Unified Diff: remoting/protocol/channel_multiplexer.cc

Issue 1654513003: Simplify message parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_done
Patch Set: Created 4 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 side-by-side diff with in-line comments
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 »
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 65d29c029f35f58c626eb4c4a515c2b9b013ec40..1ac07ffdf83537de5b99fa52ce24eab41541f840 100644
--- a/remoting/protocol/channel_multiplexer.cc
+++ b/remoting/protocol/channel_multiplexer.cc
@@ -305,11 +305,7 @@ ChannelMultiplexer::ChannelMultiplexer(StreamChannelFactory* factory,
: base_channel_factory_(factory),
base_channel_name_(base_channel_name),
next_channel_id_(0),
- parser_(base::Bind(&ChannelMultiplexer::OnIncomingPacket,
- base::Unretained(this)),
- &reader_),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
ChannelMultiplexer::~ChannelMultiplexer() {
DCHECK(pending_channels_.empty());
@@ -361,6 +357,8 @@ void ChannelMultiplexer::OnBaseChannelReady(
if (base_channel_.get()) {
// Initialize reader and writer.
reader_.StartReading(base_channel_.get(),
+ base::Bind(&ChannelMultiplexer::OnIncomingPacket,
+ base::Unretained(this)),
base::Bind(&ChannelMultiplexer::OnBaseChannelError,
base::Unretained(this)));
writer_.Start(base::Bind(&P2PStreamSocket::Write,
@@ -424,7 +422,12 @@ void ChannelMultiplexer::NotifyBaseChannelError(const std::string& name,
it->second->OnBaseChannelError(error);
}
-void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<MultiplexPacket> packet) {
+void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<CompoundBuffer> buffer) {
+ scoped_ptr<MultiplexPacket> packet =
+ ParseMessage<MultiplexPacket>(buffer.get());
+ if (!packet)
+ return;
+
DCHECK(packet->has_channel_id());
if (!packet->has_channel_id()) {
LOG(ERROR) << "Received packet without channel_id.";
« 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