OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/client/chromoting_client.h" | 5 #include "remoting/client/chromoting_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "jingle/glue/thread_wrapper.h" |
9 #include "remoting/base/tracer.h" | 10 #include "remoting/base/tracer.h" |
10 #include "remoting/client/chromoting_view.h" | 11 #include "remoting/client/chromoting_view.h" |
11 #include "remoting/client/client_context.h" | 12 #include "remoting/client/client_context.h" |
12 #include "remoting/client/input_handler.h" | 13 #include "remoting/client/input_handler.h" |
13 #include "remoting/client/rectangle_update_decoder.h" | 14 #include "remoting/client/rectangle_update_decoder.h" |
14 #include "remoting/protocol/connection_to_host.h" | 15 #include "remoting/protocol/connection_to_host.h" |
15 #include "remoting/protocol/session_config.h" | 16 #include "remoting/protocol/session_config.h" |
16 | 17 |
17 namespace remoting { | 18 namespace remoting { |
18 | 19 |
(...skipping 20 matching lines...) Expand all Loading... |
39 } | 40 } |
40 | 41 |
41 void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) { | 42 void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) { |
42 if (message_loop() != MessageLoop::current()) { | 43 if (message_loop() != MessageLoop::current()) { |
43 message_loop()->PostTask( | 44 message_loop()->PostTask( |
44 FROM_HERE, | 45 FROM_HERE, |
45 NewRunnableMethod(this, &ChromotingClient::Start, xmpp_proxy)); | 46 NewRunnableMethod(this, &ChromotingClient::Start, xmpp_proxy)); |
46 return; | 47 return; |
47 } | 48 } |
48 | 49 |
| 50 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); |
| 51 |
49 connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid, | 52 connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid, |
50 config_.host_public_key, config_.access_code, | 53 config_.host_public_key, config_.access_code, |
51 this, this, this); | 54 this, this, this); |
52 | 55 |
53 if (!view_->Initialize()) { | 56 if (!view_->Initialize()) { |
54 ClientDone(); | 57 ClientDone(); |
55 } | 58 } |
56 } | 59 } |
57 | 60 |
58 void ChromotingClient::Stop(const base::Closure& shutdown_task) { | 61 void ChromotingClient::Stop(const base::Closure& shutdown_task) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 VLOG(1) << "ChromotingClient::OnConnectionClosed"; | 176 VLOG(1) << "ChromotingClient::OnConnectionClosed"; |
174 SetConnectionState(DISCONNECTED); | 177 SetConnectionState(DISCONNECTED); |
175 } | 178 } |
176 | 179 |
177 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { | 180 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { |
178 VLOG(1) << "ChromotingClient::OnConnectionFailed"; | 181 VLOG(1) << "ChromotingClient::OnConnectionFailed"; |
179 SetConnectionState(FAILED); | 182 SetConnectionState(FAILED); |
180 } | 183 } |
181 | 184 |
182 MessageLoop* ChromotingClient::message_loop() { | 185 MessageLoop* ChromotingClient::message_loop() { |
183 return context_->jingle_thread()->message_loop(); | 186 return context_->network_message_loop(); |
184 } | 187 } |
185 | 188 |
186 void ChromotingClient::SetConnectionState(ConnectionState s) { | 189 void ChromotingClient::SetConnectionState(ConnectionState s) { |
187 // TODO(ajwong): We actually may want state to be a shared variable. Think | 190 // TODO(ajwong): We actually may want state to be a shared variable. Think |
188 // through later. | 191 // through later. |
189 if (message_loop() != MessageLoop::current()) { | 192 if (message_loop() != MessageLoop::current()) { |
190 message_loop()->PostTask( | 193 message_loop()->PostTask( |
191 FROM_HERE, | 194 FROM_HERE, |
192 NewRunnableMethod(this, &ChromotingClient::SetConnectionState, s)); | 195 NewRunnableMethod(this, &ChromotingClient::SetConnectionState, s)); |
193 return; | 196 return; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (msg->success()) { | 269 if (msg->success()) { |
267 connection_->OnClientAuthenticated(); | 270 connection_->OnClientAuthenticated(); |
268 } | 271 } |
269 | 272 |
270 view_->UpdateLoginStatus(msg->success(), msg->error_info()); | 273 view_->UpdateLoginStatus(msg->success(), msg->error_info()); |
271 done->Run(); | 274 done->Run(); |
272 delete done; | 275 delete done; |
273 } | 276 } |
274 | 277 |
275 } // namespace remoting | 278 } // namespace remoting |
OLD | NEW |