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