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_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 Loading... |
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 |
OLD | NEW |