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/host/simple_host.h" | 5 #include "remoting/host/simple_host.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "remoting/base/constants.h" | |
10 #include "remoting/base/protocol_decoder.h" | 9 #include "remoting/base/protocol_decoder.h" |
11 #include "remoting/host/session_manager.h" | 10 #include "remoting/host/session_manager.h" |
12 #include "remoting/jingle_glue/jingle_channel.h" | 11 #include "remoting/jingle_glue/jingle_channel.h" |
13 | 12 |
14 namespace remoting { | 13 namespace remoting { |
15 | 14 |
16 SimpleHost::SimpleHost(const std::string& username, | 15 SimpleHost::SimpleHost(const std::string& username, |
17 const std::string& auth_token, | 16 const std::string& password, |
18 Capturer* capturer, | 17 Capturer* capturer, |
19 Encoder* encoder, | 18 Encoder* encoder, |
20 EventExecutor* executor) | 19 EventExecutor* executor) |
21 : capture_thread_("CaptureThread"), | 20 : capture_thread_("CaptureThread"), |
22 encode_thread_("EncodeThread"), | 21 encode_thread_("EncodeThread"), |
23 username_(username), | 22 username_(username), |
24 auth_token_(auth_token), | 23 password_(password), |
25 capturer_(capturer), | 24 capturer_(capturer), |
26 encoder_(encoder), | 25 encoder_(encoder), |
27 executor_(executor) { | 26 executor_(executor) { |
28 } | 27 } |
29 | 28 |
30 void SimpleHost::Run() { | 29 void SimpleHost::Run() { |
31 DCHECK_EQ(&main_loop_, MessageLoop::current()); | 30 DCHECK_EQ(&main_loop_, MessageLoop::current()); |
32 | 31 |
33 // Submit a task to perform host registration. We'll also start | 32 // Submit a task to perform host registration. We'll also start |
34 // listening to connection if registration is done. | 33 // listening to connection if registration is done. |
(...skipping 18 matching lines...) Expand all Loading... |
53 } | 52 } |
54 | 53 |
55 // This method talks to the cloud to register the host process. If | 54 // This method talks to the cloud to register the host process. If |
56 // successful we will start listening to network requests. | 55 // successful we will start listening to network requests. |
57 void SimpleHost::RegisterHost() { | 56 void SimpleHost::RegisterHost() { |
58 DCHECK_EQ(&main_loop_, MessageLoop::current()); | 57 DCHECK_EQ(&main_loop_, MessageLoop::current()); |
59 DCHECK(!jingle_client_); | 58 DCHECK(!jingle_client_); |
60 | 59 |
61 // Connect to the talk network with a JingleClient. | 60 // Connect to the talk network with a JingleClient. |
62 jingle_client_ = new JingleClient(); | 61 jingle_client_ = new JingleClient(); |
63 jingle_client_->Init(username_, auth_token_, | 62 jingle_client_->Init(username_, password_, this); |
64 kChromotingTokenServiceName, this); | |
65 } | 63 } |
66 | 64 |
67 // This method is called if a client is connected to this object. | 65 // This method is called if a client is connected to this object. |
68 void SimpleHost::OnClientConnected(ClientConnection* client) { | 66 void SimpleHost::OnClientConnected(ClientConnection* client) { |
69 DCHECK_EQ(&main_loop_, MessageLoop::current()); | 67 DCHECK_EQ(&main_loop_, MessageLoop::current()); |
70 | 68 |
71 // Create a new RecordSession if there was none. | 69 // Create a new RecordSession if there was none. |
72 if (!session_) { | 70 if (!session_) { |
73 // The first we need to make sure capture and encode thread are | 71 // The first we need to make sure capture and encode thread are |
74 // running. | 72 // running. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 scoped_refptr<JingleChannel> channel) { | 192 scoped_refptr<JingleChannel> channel) { |
195 DCHECK_EQ(jingle_client_.get(), jingle_client); | 193 DCHECK_EQ(jingle_client_.get(), jingle_client); |
196 | 194 |
197 // Since the session manager has not started, it is still safe to access | 195 // Since the session manager has not started, it is still safe to access |
198 // the client directly. Note that we give the ownership of the channel | 196 // the client directly. Note that we give the ownership of the channel |
199 // to the client. | 197 // to the client. |
200 client_->set_jingle_channel(channel); | 198 client_->set_jingle_channel(channel); |
201 } | 199 } |
202 | 200 |
203 } // namespace remoting | 201 } // namespace remoting |
OLD | NEW |