OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/jingle_connection_to_host.h" | 5 #include "remoting/protocol/jingle_connection_to_host.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
10 // TODO(hclam): Remove this header once MessageDispatcher is used. | 10 // TODO(hclam): Remove this header once MessageDispatcher is used. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 video_reader_->Close(); | 57 video_reader_->Close(); |
58 | 58 |
59 if (session_) { | 59 if (session_) { |
60 session_->Close( | 60 session_->Close( |
61 NewRunnableMethod(this, &JingleConnectionToHost::OnDisconnected)); | 61 NewRunnableMethod(this, &JingleConnectionToHost::OnDisconnected)); |
62 } else { | 62 } else { |
63 OnDisconnected(); | 63 OnDisconnected(); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void JingleConnectionToHost::OnControlMessage(ChromotingHostMessage* msg) { | 67 void JingleConnectionToHost::OnControlMessage(ControlMessage* msg) { |
68 event_callback_->HandleMessage(this, msg); | 68 // TODO(sergeyu): Remove this method and pass ClientStub to the control |
| 69 // stream dispatcher. |
| 70 delete msg; |
69 } | 71 } |
70 | 72 |
71 void JingleConnectionToHost::InitSession() { | 73 void JingleConnectionToHost::InitSession() { |
72 DCHECK_EQ(message_loop(), MessageLoop::current()); | 74 DCHECK_EQ(message_loop(), MessageLoop::current()); |
73 | 75 |
74 // Initialize chromotocol |session_manager_|. | 76 // Initialize chromotocol |session_manager_|. |
75 protocol::JingleSessionManager* session_manager = | 77 protocol::JingleSessionManager* session_manager = |
76 new protocol::JingleSessionManager(thread_); | 78 new protocol::JingleSessionManager(thread_); |
77 // TODO(ajwong): Make this a command switch when we're more stable. | 79 // TODO(ajwong): Make this a command switch when we're more stable. |
78 session_manager->set_allow_local_ips(true); | 80 session_manager->set_allow_local_ips(true); |
(...skipping 26 matching lines...) Expand all Loading... |
105 } | 107 } |
106 | 108 |
107 void JingleConnectionToHost::OnServerClosed() { | 109 void JingleConnectionToHost::OnServerClosed() { |
108 session_manager_ = NULL; | 110 session_manager_ = NULL; |
109 if (jingle_client_) { | 111 if (jingle_client_) { |
110 jingle_client_->Close(); | 112 jingle_client_->Close(); |
111 jingle_client_ = NULL; | 113 jingle_client_ = NULL; |
112 } | 114 } |
113 } | 115 } |
114 | 116 |
| 117 const SessionConfig* JingleConnectionToHost::config() { |
| 118 return session_->config(); |
| 119 } |
| 120 |
115 void JingleConnectionToHost::SendEvent(const ChromotingClientMessage& msg) { | 121 void JingleConnectionToHost::SendEvent(const ChromotingClientMessage& msg) { |
116 // This drops the message if we are not connected yet. | 122 // This drops the message if we are not connected yet. |
117 event_writer_.SendMessage(msg); | 123 event_writer_.SendMessage(msg); |
118 } | 124 } |
119 | 125 |
120 // JingleClient::Callback interface. | 126 // JingleClient::Callback interface. |
121 void JingleConnectionToHost::OnStateChange(JingleClient* client, | 127 void JingleConnectionToHost::OnStateChange(JingleClient* client, |
122 JingleClient::State state) { | 128 JingleClient::State state) { |
123 DCHECK_EQ(message_loop(), MessageLoop::current()); | 129 DCHECK_EQ(message_loop(), MessageLoop::current()); |
124 DCHECK(client); | 130 DCHECK(client); |
(...skipping 24 matching lines...) Expand all Loading... |
149 case protocol::Session::FAILED: | 155 case protocol::Session::FAILED: |
150 event_callback_->OnConnectionFailed(this); | 156 event_callback_->OnConnectionFailed(this); |
151 break; | 157 break; |
152 | 158 |
153 case protocol::Session::CLOSED: | 159 case protocol::Session::CLOSED: |
154 event_callback_->OnConnectionClosed(this); | 160 event_callback_->OnConnectionClosed(this); |
155 break; | 161 break; |
156 | 162 |
157 case protocol::Session::CONNECTED: | 163 case protocol::Session::CONNECTED: |
158 // Initialize reader and writer. | 164 // Initialize reader and writer. |
159 control_reader_.Init<ChromotingHostMessage>( | 165 control_reader_.Init<ControlMessage>( |
160 session_->control_channel(), | 166 session_->control_channel(), |
161 NewCallback(this, &JingleConnectionToHost::OnControlMessage)); | 167 NewCallback(this, &JingleConnectionToHost::OnControlMessage)); |
162 event_writer_.Init(session_->event_channel()); | 168 event_writer_.Init(session_->event_channel()); |
163 video_reader_.reset(VideoReader::Create(session_->config())); | 169 video_reader_.reset(VideoReader::Create(session_->config())); |
164 video_reader_->Init(session_, video_stub_); | 170 video_reader_->Init(session_, video_stub_); |
165 event_callback_->OnConnectionOpened(this); | 171 event_callback_->OnConnectionOpened(this); |
166 break; | 172 break; |
167 | 173 |
168 default: | 174 default: |
169 // Ignore the other states by default. | 175 // Ignore the other states by default. |
170 break; | 176 break; |
171 } | 177 } |
172 } | 178 } |
173 | 179 |
174 MessageLoop* JingleConnectionToHost::message_loop() { | 180 MessageLoop* JingleConnectionToHost::message_loop() { |
175 return thread_->message_loop(); | 181 return thread_->message_loop(); |
176 } | 182 } |
177 | 183 |
178 } // namespace protocol | 184 } // namespace protocol |
179 } // namespace remoting | 185 } // namespace remoting |
OLD | NEW |