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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "remoting/protocol/p2p_stream_socket.h" | 8 #include "remoting/protocol/p2p_stream_socket.h" |
9 #include "remoting/protocol/stream_channel_factory.h" | 9 #include "remoting/protocol/stream_channel_factory.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 void ChannelDispatcherBase::OnChannelReady( | 34 void ChannelDispatcherBase::OnChannelReady( |
35 scoped_ptr<P2PStreamSocket> socket) { | 35 scoped_ptr<P2PStreamSocket> socket) { |
36 if (!socket.get()) { | 36 if (!socket.get()) { |
37 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); | 37 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); |
38 return; | 38 return; |
39 } | 39 } |
40 | 40 |
41 channel_factory_ = nullptr; | 41 channel_factory_ = nullptr; |
42 channel_ = socket.Pass(); | 42 channel_ = std::move(socket); |
43 writer_.Init( | 43 writer_.Init( |
44 base::Bind(&P2PStreamSocket::Write, base::Unretained(channel_.get())), | 44 base::Bind(&P2PStreamSocket::Write, base::Unretained(channel_.get())), |
45 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed, | 45 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed, |
46 base::Unretained(this))); | 46 base::Unretained(this))); |
47 reader_.StartReading(channel_.get(), | 47 reader_.StartReading(channel_.get(), |
48 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed, | 48 base::Bind(&ChannelDispatcherBase::OnReadWriteFailed, |
49 base::Unretained(this))); | 49 base::Unretained(this))); |
50 | 50 |
51 event_handler_->OnChannelInitialized(this); | 51 event_handler_->OnChannelInitialized(this); |
52 } | 52 } |
53 | 53 |
54 void ChannelDispatcherBase::OnReadWriteFailed(int error) { | 54 void ChannelDispatcherBase::OnReadWriteFailed(int error) { |
55 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); | 55 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); |
56 } | 56 } |
57 | 57 |
58 } // namespace protocol | 58 } // namespace protocol |
59 } // namespace remoting | 59 } // namespace remoting |
OLD | NEW |