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

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: Delete debugging and clean up comments. 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "remoting/host/network_settings.h" 46 #include "remoting/host/network_settings.h"
47 #include "remoting/host/policy_hack/policy_watcher.h" 47 #include "remoting/host/policy_hack/policy_watcher.h"
48 #include "remoting/host/session_manager_factory.h" 48 #include "remoting/host/session_manager_factory.h"
49 #include "remoting/host/signaling_connector.h" 49 #include "remoting/host/signaling_connector.h"
50 #include "remoting/host/usage_stats_consent.h" 50 #include "remoting/host/usage_stats_consent.h"
51 #include "remoting/host/video_frame_capturer.h" 51 #include "remoting/host/video_frame_capturer.h"
52 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 52 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
53 #include "remoting/protocol/me2me_host_authenticator_factory.h" 53 #include "remoting/protocol/me2me_host_authenticator_factory.h"
54 54
55 #if defined(OS_POSIX) 55 #if defined(OS_POSIX)
56 #include "remoting/host/posix/sighup_listener.h" 56 #include "remoting/host/posix/signal_handler.h"
57 #include <signal.h>
Lambros 2012/09/05 16:35:54 nit: move system include above project include
Jamie 2012/09/05 21:15:38 Done.
57 #endif // defined(OS_POSIX) 58 #endif // defined(OS_POSIX)
58 59
59 #if defined(OS_MACOSX) 60 #if defined(OS_MACOSX)
60 #include "base/mac/scoped_cftyperef.h" 61 #include "base/mac/scoped_cftyperef.h"
61 #include "base/mac/scoped_nsautorelease_pool.h" 62 #include "base/mac/scoped_nsautorelease_pool.h"
62 #include "remoting/host/curtain_mode_mac.h" 63 #include "remoting/host/curtain_mode_mac.h"
63 #endif // defined(OS_MACOSX) 64 #endif // defined(OS_MACOSX)
64 65
65 // N.B. OS_WIN is defined by including src/base headers. 66 // N.B. OS_WIN is defined by including src/base headers.
66 #if defined(OS_WIN) 67 #if defined(OS_WIN)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 155
155 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); 156 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile);
156 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 157 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
157 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 158 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
158 } 159 }
159 config_.AddConfigPath(host_config_path_); 160 config_.AddConfigPath(host_config_path_);
160 161
161 return true; 162 return true;
162 } 163 }
163 164
165 #if defined(OS_POSIX)
166 void SignalHandler(int signum) {
Sergey Ulanov 2012/09/04 22:01:48 Why not separate SighupHandler() and SigtermHandle
Jamie 2012/09/05 21:15:38 Done.
167 switch (signum) {
168 case SIGHUP:
169 LOG(INFO) << "Caught SIGHUP: Reloading config...";
170 ConfigUpdatedDelayed();
171 break;
172 case SIGTERM:
173 LOG(INFO) << "Caught SIGTERM: Shutting down...";
174 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
175 &HostProcess::Shutdown, base::Unretained(this), kSuccessExitCode));
Lambros 2012/09/05 16:35:54 Could you comment why base::Unretained is safe her
Jamie 2012/09/05 21:15:38 Done.
176 break;
177 default:
178 LOG(ERROR) << "Ignoring unexpected signal " << signum;
179 }
180 }
181 #endif
182
164 void ConfigUpdated() { 183 void ConfigUpdated() {
165 DCHECK(message_loop_.message_loop_proxy()->BelongsToCurrentThread()); 184 DCHECK(message_loop_.message_loop_proxy()->BelongsToCurrentThread());
166 185
167 // Call ConfigUpdatedDelayed after a short delay, so that this object won't 186 // Call ConfigUpdatedDelayed after a short delay, so that this object won't
168 // try to read the updated configuration file before it has been 187 // try to read the updated configuration file before it has been
169 // completely written. 188 // completely written.
170 // If the writer moves the new configuration file into place atomically, 189 // If the writer moves the new configuration file into place atomically,
171 // this delay may not be necessary. 190 // this delay may not be necessary.
172 config_updated_timer_->Reset(); 191 config_updated_timer_->Reset();
173 } 192 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 private: 225 private:
207 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 226 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
208 base::Closure callback_; 227 base::Closure callback_;
209 228
210 DISALLOW_COPY_AND_ASSIGN(ConfigChangedDelegate); 229 DISALLOW_COPY_AND_ASSIGN(ConfigChangedDelegate);
211 }; 230 };
212 #endif // defined(OS_WIN) 231 #endif // defined(OS_WIN)
213 232
214 void ListenForConfigChanges() { 233 void ListenForConfigChanges() {
215 #if defined(OS_POSIX) 234 #if defined(OS_POSIX)
216 remoting::RegisterHupSignalHandler( 235 remoting::RegisterSignalHandler(
217 base::Bind(&HostProcess::ConfigUpdatedDelayed, base::Unretained(this))); 236 SIGHUP,
237 base::Bind(&HostProcess::SignalHandler, base::Unretained(this)));
218 #elif defined(OS_WIN) 238 #elif defined(OS_WIN)
219 scoped_refptr<base::files::FilePathWatcher::Delegate> delegate( 239 scoped_refptr<base::files::FilePathWatcher::Delegate> delegate(
220 new ConfigChangedDelegate( 240 new ConfigChangedDelegate(
221 message_loop_.message_loop_proxy(), 241 message_loop_.message_loop_proxy(),
222 base::Bind(&HostProcess::ConfigUpdated, base::Unretained(this)))); 242 base::Bind(&HostProcess::ConfigUpdated, base::Unretained(this))));
223 config_watcher_.reset(new base::files::FilePathWatcher()); 243 config_watcher_.reset(new base::files::FilePathWatcher());
224 if (!config_watcher_->Watch(host_config_path_, delegate)) { 244 if (!config_watcher_->Watch(host_config_path_, delegate)) {
225 LOG(ERROR) << "Couldn't watch file " << host_config_path_.value(); 245 LOG(ERROR) << "Couldn't watch file " << host_config_path_.value();
226 } 246 }
227 #endif // defined (OS_WIN) 247 #endif // defined (OS_WIN)
228 } 248 }
229 249
250 #if defined(OS_POSIX)
251 void ListenForShutdownSignal() {
252 remoting::RegisterSignalHandler(
253 SIGTERM,
254 base::Bind(&HostProcess::SignalHandler, base::Unretained(this)));
255 }
256 #endif // OS_POSIX
257
230 void CreateAuthenticatorFactory() { 258 void CreateAuthenticatorFactory() {
231 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 259 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
232 scoped_ptr<protocol::AuthenticatorFactory> factory( 260 scoped_ptr<protocol::AuthenticatorFactory> factory(
233 new protocol::Me2MeHostAuthenticatorFactory( 261 new protocol::Me2MeHostAuthenticatorFactory(
234 key_pair_.GenerateCertificate(), 262 key_pair_.GenerateCertificate(),
235 *key_pair_.private_key(), host_secret_hash_)); 263 *key_pair_.private_key(), host_secret_hash_));
236 host_->SetAuthenticatorFactory(factory.Pass()); 264 host_->SetAuthenticatorFactory(factory.Pass());
237 } 265 }
238 266
239 // IPC::Listener implementation. 267 // IPC::Listener implementation.
(...skipping 22 matching lines...) Expand all
262 } 290 }
263 #endif // OS_MACOSX 291 #endif // OS_MACOSX
264 292
265 if (want_user_interface) { 293 if (want_user_interface) {
266 host_user_interface_.reset(new HostUserInterface(context_.get())); 294 host_user_interface_.reset(new HostUserInterface(context_.get()));
267 } 295 }
268 #endif // OS_MACOSX || OS_WIN 296 #endif // OS_MACOSX || OS_WIN
269 297
270 StartWatchingPolicy(); 298 StartWatchingPolicy();
271 299
272 #if defined(OS_MACOSX) || defined(OS_WIN)
273 context_->file_task_runner()->PostTask( 300 context_->file_task_runner()->PostTask(
274 FROM_HERE, 301 FROM_HERE,
275 base::Bind(&HostProcess::ListenForConfigChanges, 302 base::Bind(&HostProcess::ListenForConfigChanges,
276 base::Unretained(this))); 303 base::Unretained(this)));
277 #endif 304
305 #if defined(OS_POSIX)
306 remoting::SignalHandler handler = base::Bind(&HostProcess::SignalHandler,
307 base::Unretained(this));
308 context_->file_task_runner()->PostTask(
309 FROM_HERE,
310 base::Bind(&HostProcess::ListenForShutdownSignal,
311 base::Unretained(this)));
312 #endif // OS_POSIX
313
278 message_loop_.Run(); 314 message_loop_.Run();
279 315
280 #if defined(OS_MACOSX) || defined(OS_WIN) 316 #if defined(OS_MACOSX) || defined(OS_WIN)
281 host_user_interface_.reset(); 317 host_user_interface_.reset();
282 #endif 318 #endif
283 319
284 daemon_channel_.reset(); 320 daemon_channel_.reset();
285 base::WaitableEvent done_event(true, false); 321 base::WaitableEvent done_event(true, false);
286 policy_watcher_->StopWatching(&done_event); 322 policy_watcher_->StopWatching(&done_event);
287 done_event.Wait(); 323 done_event.Wait();
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 user32.GetFunctionPointer("SetProcessDPIAware")); 811 user32.GetFunctionPointer("SetProcessDPIAware"));
776 set_process_dpi_aware(); 812 set_process_dpi_aware();
777 } 813 }
778 814
779 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 815 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
780 // the command line from GetCommandLineW(), so we can safely pass NULL here. 816 // the command line from GetCommandLineW(), so we can safely pass NULL here.
781 return main(0, NULL); 817 return main(0, NULL);
782 } 818 }
783 819
784 #endif // defined(OS_WIN) 820 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698