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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 void ChannelDispatcherBase::OnChannelReady( | 36 void ChannelDispatcherBase::OnChannelReady( |
37 scoped_ptr<P2PStreamSocket> socket) { | 37 scoped_ptr<P2PStreamSocket> socket) { |
38 if (!socket.get()) { | 38 if (!socket.get()) { |
39 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); | 39 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); |
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_.Init( | 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::OnReadWriteFailed, | 50 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed, |
51 base::Unretained(this))); | 51 base::Unretained(this))); |
52 | 52 |
53 event_handler_->OnChannelInitialized(this); | 53 event_handler_->OnChannelInitialized(this); |
54 } | 54 } |
55 | 55 |
56 void ChannelDispatcherBase::OnReadWriteFailed(int error) { | 56 void ChannelDispatcherBase::OnReadWriteFailed(int error) { |
57 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); | 57 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); |
58 } | 58 } |
59 | 59 |
60 } // namespace protocol | 60 } // namespace protocol |
61 } // namespace remoting | 61 } // namespace remoting |
OLD | NEW |