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

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

Issue 1654513003: Simplify message parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_done
Patch Set: Created 4 years, 10 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
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_dispatcher_base.h" 5 #include "remoting/protocol/channel_dispatcher_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "remoting/protocol/p2p_stream_socket.h" 10 #include "remoting/protocol/p2p_stream_socket.h"
(...skipping 29 matching lines...) Expand all
40 return; 40 return;
41 } 41 }
42 42
43 channel_factory_ = nullptr; 43 channel_factory_ = nullptr;
44 channel_ = std::move(socket); 44 channel_ = std::move(socket);
45 writer_.Start( 45 writer_.Start(
46 base::Bind(&P2PStreamSocket::Write, base::Unretained(channel_.get())), 46 base::Bind(&P2PStreamSocket::Write, base::Unretained(channel_.get())),
47 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed, 47 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed,
48 base::Unretained(this))); 48 base::Unretained(this)));
49 reader_.StartReading(channel_.get(), 49 reader_.StartReading(channel_.get(),
50 base::Bind(&ChannelDispatcherBase::OnIncomingMessage,
51 base::Unretained(this)),
50 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed, 52 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed,
51 base::Unretained(this))); 53 base::Unretained(this)));
52 54
53 event_handler_->OnChannelInitialized(this); 55 event_handler_->OnChannelInitialized(this);
54 } 56 }
55 57
58 void ChannelDispatcherBase::OnIncomingMessage(
59 scoped_ptr<CompoundBuffer> message) {
60 // By default incoming message are not expected. Child classes override
61 // OnIncomingMessage() if the want to handle incoming messages.
62 LOG(ERROR) << "Received unexpected message on " << channel_name();
63 }
64
56 void ChannelDispatcherBase::OnReadWriteFailed(int error) { 65 void ChannelDispatcherBase::OnReadWriteFailed(int error) {
57 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); 66 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR);
58 } 67 }
59 68
60 } // namespace protocol 69 } // namespace protocol
61 } // namespace remoting 70 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698