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 "chrome/service/remoting/chromoting_host_manager.h" | 5 #include "chrome/service/remoting/chromoting_host_manager.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
9 #include "chrome/common/guid.h" | 9 #include "chrome/common/guid.h" |
10 #include "chrome/common/remoting/chromoting_host_info.h" | 10 #include "chrome/common/remoting/chromoting_host_info.h" |
11 #include "net/base/net_util.h" | 11 #include "net/base/net_util.h" |
12 #include "remoting/base/constants.h" | 12 #include "remoting/base/constants.h" |
13 #include "remoting/host/chromoting_host_context.h" | 13 #include "remoting/host/chromoting_host_context.h" |
14 #include "remoting/host/json_host_config.h" | 14 #include "remoting/host/json_host_config.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 ChromotingHostManager::ChromotingHostManager(Observer* observer) | 18 ChromotingHostManager::ChromotingHostManager(Observer* observer) |
19 : observer_(observer) { | 19 : observer_(observer) { |
20 } | 20 } |
21 | 21 |
22 void ChromotingHostManager::Initialize( | 22 void ChromotingHostManager::Initialize( |
23 MessageLoop* main_message_loop, | 23 MessageLoopForUI* main_message_loop, |
24 base::MessageLoopProxy* file_message_loop) { | 24 base::MessageLoopProxy* file_message_loop) { |
25 FilePath user_data_dir; | 25 FilePath user_data_dir; |
26 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 26 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
27 FilePath chromoting_config_path = | 27 FilePath chromoting_config_path = |
28 user_data_dir.Append(FILE_PATH_LITERAL(".ChromotingConfig.json")); | 28 user_data_dir.Append(FILE_PATH_LITERAL(".ChromotingConfig.json")); |
29 remoting::JsonHostConfig* config = new remoting::JsonHostConfig( | 29 remoting::JsonHostConfig* config = new remoting::JsonHostConfig( |
30 chromoting_config_path, file_message_loop); | 30 chromoting_config_path, file_message_loop); |
31 if (!config->Read()) { | 31 if (!config->Read()) { |
32 VLOG(1) << "Failed to read chromoting config file."; | 32 VLOG(1) << "Failed to read chromoting config file."; |
33 } | 33 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 enabled); | 158 enabled); |
159 chromoting_config_->Save(); | 159 chromoting_config_->Save(); |
160 } | 160 } |
161 | 161 |
162 void ChromotingHostManager::Start() { | 162 void ChromotingHostManager::Start() { |
163 // Don't do anything if we already started. | 163 // Don't do anything if we already started. |
164 if (chromoting_host_.get()) | 164 if (chromoting_host_.get()) |
165 return; | 165 return; |
166 | 166 |
167 // Start the chromoting context first. | 167 // Start the chromoting context first. |
168 chromoting_context_.reset(new remoting::ChromotingHostContext()); | 168 chromoting_context_.reset( |
| 169 new remoting::ChromotingHostContext(main_message_loop_)); |
169 chromoting_context_->Start(); | 170 chromoting_context_->Start(); |
170 | 171 |
171 // Create a chromoting host object. | 172 // Create a chromoting host object. |
172 chromoting_host_ = remoting::ChromotingHost::Create(chromoting_context_.get(), | 173 chromoting_host_ = remoting::ChromotingHost::Create(chromoting_context_.get(), |
173 chromoting_config_); | 174 chromoting_config_); |
174 | 175 |
175 // Then start the chromoting host. | 176 // Then start the chromoting host. |
176 // When ChromotingHost is shutdown because of failure or a request that | 177 // When ChromotingHost is shutdown because of failure or a request that |
177 // we made OnChromotingShutdown() is calls. | 178 // we made OnChromotingShutdown() is calls. |
178 chromoting_host_->Start( | 179 chromoting_host_->Start( |
(...skipping 10 matching lines...) Expand all Loading... |
189 chromoting_context_.reset(); | 190 chromoting_context_.reset(); |
190 chromoting_host_ = NULL; | 191 chromoting_host_ = NULL; |
191 | 192 |
192 if (shutdown_task_.get()) { | 193 if (shutdown_task_.get()) { |
193 shutdown_task_->Run(); | 194 shutdown_task_->Run(); |
194 shutdown_task_.reset(); | 195 shutdown_task_.reset(); |
195 } | 196 } |
196 } | 197 } |
197 | 198 |
198 } // namespace remoting | 199 } // namespace remoting |
OLD | NEW |