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/session.h" | 9 #include "remoting/protocol/session.h" |
10 #include "remoting/protocol/session_config.h" | 10 #include "remoting/protocol/session_config.h" |
11 #include "remoting/protocol/stream_channel_factory.h" | 11 #include "remoting/protocol/stream_channel_factory.h" |
12 #include "remoting/protocol/transport.h" | |
13 | 12 |
14 namespace remoting { | 13 namespace remoting { |
15 namespace protocol { | 14 namespace protocol { |
16 | 15 |
17 ChannelDispatcherBase::ChannelDispatcherBase(const char* channel_name) | 16 ChannelDispatcherBase::ChannelDispatcherBase(const char* channel_name) |
18 : channel_name_(channel_name), | 17 : channel_name_(channel_name), |
19 channel_factory_(nullptr), | 18 channel_factory_(nullptr), |
20 event_handler_(nullptr) { | 19 event_handler_(nullptr) { |
21 } | 20 } |
22 | 21 |
23 ChannelDispatcherBase::~ChannelDispatcherBase() { | 22 ChannelDispatcherBase::~ChannelDispatcherBase() { |
24 if (channel_factory_) | 23 if (channel_factory_) |
25 channel_factory_->CancelChannelCreation(channel_name_); | 24 channel_factory_->CancelChannelCreation(channel_name_); |
26 } | 25 } |
27 | 26 |
28 void ChannelDispatcherBase::Init(Session* session, | 27 void ChannelDispatcherBase::Init(Session* session, |
29 const ChannelConfig& config, | 28 const ChannelConfig& config, |
30 EventHandler* event_handler) { | 29 EventHandler* event_handler) { |
31 DCHECK(session); | 30 DCHECK(session); |
32 switch (config.transport) { | 31 switch (config.transport) { |
33 case ChannelConfig::TRANSPORT_MUX_STREAM: | 32 case ChannelConfig::TRANSPORT_MUX_STREAM: |
34 channel_factory_ = | 33 channel_factory_ = session->GetMultiplexedChannelFactory(); |
35 session->GetTransportSession()->GetMultiplexedChannelFactory(); | |
36 break; | 34 break; |
37 | 35 |
38 case ChannelConfig::TRANSPORT_QUIC_STREAM: | 36 case ChannelConfig::TRANSPORT_QUIC_STREAM: |
39 channel_factory_ = session->GetQuicChannelFactory(); | 37 channel_factory_ = session->GetQuicChannelFactory(); |
40 break; | 38 break; |
41 | 39 |
42 case ChannelConfig::TRANSPORT_STREAM: | 40 case ChannelConfig::TRANSPORT_STREAM: |
43 channel_factory_ = | 41 channel_factory_ = session->GetTransportChannelFactory(); |
44 session->GetTransportSession()->GetStreamChannelFactory(); | |
45 break; | 42 break; |
46 | 43 |
47 default: | 44 default: |
48 LOG(FATAL) << "Unknown transport type: " << config.transport; | 45 LOG(FATAL) << "Unknown transport type: " << config.transport; |
49 } | 46 } |
50 | 47 |
51 event_handler_ = event_handler; | 48 event_handler_ = event_handler; |
52 | 49 |
53 channel_factory_->CreateChannel(channel_name_, base::Bind( | 50 channel_factory_->CreateChannel(channel_name_, base::Bind( |
54 &ChannelDispatcherBase::OnChannelReady, base::Unretained(this))); | 51 &ChannelDispatcherBase::OnChannelReady, base::Unretained(this))); |
(...skipping 18 matching lines...) Expand all Loading... |
73 | 70 |
74 event_handler_->OnChannelInitialized(this); | 71 event_handler_->OnChannelInitialized(this); |
75 } | 72 } |
76 | 73 |
77 void ChannelDispatcherBase::OnReadWriteFailed(int error) { | 74 void ChannelDispatcherBase::OnReadWriteFailed(int error) { |
78 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); | 75 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); |
79 } | 76 } |
80 | 77 |
81 } // namespace protocol | 78 } // namespace protocol |
82 } // namespace remoting | 79 } // namespace remoting |
OLD | NEW |