Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(863)

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 10905081: Pass Me2Me config via stdin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed #include guard footer. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "remoting/host/log_to_server.h" 47 #include "remoting/host/log_to_server.h"
48 #include "remoting/host/network_settings.h" 48 #include "remoting/host/network_settings.h"
49 #include "remoting/host/policy_hack/policy_watcher.h" 49 #include "remoting/host/policy_hack/policy_watcher.h"
50 #include "remoting/host/session_manager_factory.h" 50 #include "remoting/host/session_manager_factory.h"
51 #include "remoting/host/signaling_connector.h" 51 #include "remoting/host/signaling_connector.h"
52 #include "remoting/host/usage_stats_consent.h" 52 #include "remoting/host/usage_stats_consent.h"
53 #include "remoting/host/video_frame_capturer.h" 53 #include "remoting/host/video_frame_capturer.h"
54 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 54 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
55 #include "remoting/protocol/me2me_host_authenticator_factory.h" 55 #include "remoting/protocol/me2me_host_authenticator_factory.h"
56 56
57 #if defined(OS_POSIX)
58 #include <signal.h>
alexeypa (please no reviews) 2012/09/05 21:41:25 This one is needed on Mac only.
Jamie 2012/09/06 00:18:50 I don't think that's true. <signal.h> is needed fo
59 #include "remoting/host/posix/signal_handler.h"
alexeypa (please no reviews) 2012/09/05 21:41:25 This is used only on Linux.
Jamie 2012/09/06 00:18:50 Ditto.
60 #endif // defined(OS_POSIX)
61
57 #if defined(OS_MACOSX) 62 #if defined(OS_MACOSX)
58 #include "base/mac/scoped_cftyperef.h" 63 #include "base/mac/scoped_cftyperef.h"
59 #include "base/mac/scoped_nsautorelease_pool.h" 64 #include "base/mac/scoped_nsautorelease_pool.h"
60 #include "remoting/host/curtain_mode_mac.h" 65 #include "remoting/host/curtain_mode_mac.h"
61 #endif // defined(OS_MACOSX) 66 #endif // defined(OS_MACOSX)
62 67
63 #if defined(OS_POSIX) 68 #if defined(OS_POSIX)
64 #include <signal.h> 69 #include <signal.h>
65 #endif // defined(OS_POSIX) 70 #endif // defined(OS_POSIX)
66 71
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 FilePath default_config_dir = remoting::GetConfigDir(); 149 FilePath default_config_dir = remoting::GetConfigDir();
145 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); 150 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile);
146 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 151 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
147 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 152 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
148 } 153 }
149 #endif // !defined(REMOTING_MULTI_PROCESS) 154 #endif // !defined(REMOTING_MULTI_PROCESS)
150 155
151 return true; 156 return true;
152 } 157 }
153 158
159 #if defined(OS_POSIX)
160 void SigTermHandler(int signum) {
alexeypa (please no reviews) 2012/09/05 21:41:25 This will blow up, if SIGTERM is received when shu
Jamie 2012/09/06 00:18:50 As of the latest revision, this will be called on
Lambros 2012/09/06 00:47:19 nit: signal or signal_number ?
Jamie 2012/09/06 17:31:01 Done.
161 DCHECK(signum == SIGTERM);
162 LOG(INFO) << "Caught SIGTERM: Shutting down...";
163 // base::Unretained is safe here because |this| is owned by the thread
alexeypa (please no reviews) 2012/09/05 21:41:25 nit: This comment is not really true. The network
Jamie 2012/09/06 00:18:50 This is no longer an issue with the latest revisio
164 // to which we're posting the task.
165 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
166 &HostProcess::Shutdown, base::Unretained(this), kSuccessExitCode));
167 }
168 #endif
169
154 virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE { 170 virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE {
155 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 171 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
156 172
157 LOG(INFO) << "Processing new host configuration."; 173 LOG(INFO) << "Processing new host configuration.";
158 174
159 if (!config_.SetSerializedData(serialized_config)) { 175 if (!config_.SetSerializedData(serialized_config)) {
160 LOG(ERROR) << "Invalid configuration."; 176 LOG(ERROR) << "Invalid configuration.";
161 OnConfigWatcherError(); 177 OnConfigWatcherError();
162 return; 178 return;
163 } 179 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 224
209 context_->network_task_runner()->PostTask( 225 context_->network_task_runner()->PostTask(
210 FROM_HERE, 226 FROM_HERE,
211 base::Bind(&HostProcess::Shutdown, base::Unretained(this), 227 base::Bind(&HostProcess::Shutdown, base::Unretained(this),
212 kInvalidHostConfigurationExitCode)); 228 kInvalidHostConfigurationExitCode));
213 } 229 }
214 230
215 void StartWatchingConfigChanges() { 231 void StartWatchingConfigChanges() {
216 #if !defined(REMOTING_MULTI_PROCESS) 232 #if !defined(REMOTING_MULTI_PROCESS)
217 233
218 #if defined(OS_POSIX) 234 #if defined(OS_POSIX)
alexeypa (please no reviews) 2012/09/05 21:41:25 Shouldn't it be #if defined(OS_MAC)?
Jamie 2012/09/06 00:18:50 Arguably, it isn't needed on either platform since
alexeypa (please no reviews) 2012/09/06 18:21:09 As per our discussion: either remove this code if
Jamie 2012/09/06 18:32:33 SIGHUP will never be sent to the host process by a
219 // Ignore SIGHUP sent by the daemon controller since we use 235 // Ignore SIGHUP sent by the daemon controller since we use
220 // |ConfigFileWatcher| instead. 236 // |ConfigFileWatcher| on Mac and read the config from stdin on UNIX.
alexeypa (please no reviews) 2012/09/05 21:41:25 nit: ...on Mac and Windows...
Jamie 2012/09/06 00:18:50 Done.
221 signal(SIGHUP, SIG_IGN); 237 signal(SIGHUP, SIG_IGN);
222 #endif // defined(OS_POSIX) 238 #endif // defined(OS_POSIX)
223 239
224 // Start watching the host configuration file. 240 // Start watching the host configuration file.
225 config_watcher_.reset(new ConfigFileWatcher(context_->ui_task_runner(), 241 config_watcher_.reset(new ConfigFileWatcher(context_->ui_task_runner(),
226 context_->file_task_runner(), 242 context_->file_task_runner(),
227 this)); 243 this));
228 config_watcher_->Watch(host_config_path_); 244 config_watcher_->Watch(host_config_path_);
229 #endif // !defined(REMOTING_MULTI_PROCESS) 245 #endif // !defined(REMOTING_MULTI_PROCESS)
230 } 246 }
231 247
248 #if defined(OS_POSIX)
249 void ListenForShutdownSignal() {
250 remoting::RegisterSignalHandler(
251 SIGTERM,
252 base::Bind(&HostProcess::SigTermHandler, base::Unretained(this)));
253 }
254 #endif // OS_POSIX
255
232 void CreateAuthenticatorFactory() { 256 void CreateAuthenticatorFactory() {
233 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 257 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
234 scoped_ptr<protocol::AuthenticatorFactory> factory( 258 scoped_ptr<protocol::AuthenticatorFactory> factory(
235 new protocol::Me2MeHostAuthenticatorFactory( 259 new protocol::Me2MeHostAuthenticatorFactory(
236 key_pair_.GenerateCertificate(), 260 key_pair_.GenerateCertificate(),
237 *key_pair_.private_key(), host_secret_hash_)); 261 *key_pair_.private_key(), host_secret_hash_));
238 host_->SetAuthenticatorFactory(factory.Pass()); 262 host_->SetAuthenticatorFactory(factory.Pass());
239 } 263 }
240 264
241 // IPC::Listener implementation. 265 // IPC::Listener implementation.
(...skipping 29 matching lines...) Expand all
271 private: 295 private:
272 void ShutdownHostProcess() { 296 void ShutdownHostProcess() {
273 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 297 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
274 298
275 #if !defined(REMOTING_MULTI_PROCESS) 299 #if !defined(REMOTING_MULTI_PROCESS)
276 config_watcher_.reset(); 300 config_watcher_.reset();
277 #endif // !defined(REMOTING_MULTI_PROCESS) 301 #endif // !defined(REMOTING_MULTI_PROCESS)
278 302
279 daemon_channel_.reset(); 303 daemon_channel_.reset();
280 304
305 #if defined(OS_POSIX)
306 context_->file_task_runner()->PostTask(
alexeypa (please no reviews) 2012/09/05 21:41:25 Why are we doing it in ShutdownHostProcess()? cont
Jamie 2012/09/06 00:18:50 Arguably, it isn't needed on either platform since
307 FROM_HERE,
308 base::Bind(&HostProcess::ListenForShutdownSignal,
309 base::Unretained(this)));
310 #endif // OS_POSIX
311
281 #if defined(OS_MACOSX) || defined(OS_WIN) 312 #if defined(OS_MACOSX) || defined(OS_WIN)
282 host_user_interface_.reset(); 313 host_user_interface_.reset();
283 #endif 314 #endif
284 315
285 if (policy_watcher_.get()) { 316 if (policy_watcher_.get()) {
286 base::WaitableEvent done_event(true, false); 317 base::WaitableEvent done_event(true, false);
287 policy_watcher_->StopWatching(&done_event); 318 policy_watcher_->StopWatching(&done_event);
288 done_event.Wait(); 319 done_event.Wait();
289 policy_watcher_.reset(); 320 policy_watcher_.reset();
290 } 321 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 user32.GetFunctionPointer("SetProcessDPIAware")); 810 user32.GetFunctionPointer("SetProcessDPIAware"));
780 set_process_dpi_aware(); 811 set_process_dpi_aware();
781 } 812 }
782 813
783 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 814 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
784 // the command line from GetCommandLineW(), so we can safely pass NULL here. 815 // the command line from GetCommandLineW(), so we can safely pass NULL here.
785 return main(0, NULL); 816 return main(0, NULL);
786 } 817 }
787 818
788 #endif // defined(OS_WIN) 819 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698