OLD | NEW |
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 #if defined(OS_POSIX) | 248 #if defined(OS_POSIX) |
249 void ListenForShutdownSignal() { | 249 void ListenForShutdownSignal() { |
250 remoting::RegisterSignalHandler( | 250 remoting::RegisterSignalHandler( |
251 SIGTERM, | 251 SIGTERM, |
252 base::Bind(&HostProcess::SigTermHandler, base::Unretained(this))); | 252 base::Bind(&HostProcess::SigTermHandler, base::Unretained(this))); |
253 } | 253 } |
254 #endif // OS_POSIX | 254 #endif // OS_POSIX |
255 | 255 |
256 void CreateAuthenticatorFactory() { | 256 void CreateAuthenticatorFactory() { |
257 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 257 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 258 |
| 259 std::string local_certificate = key_pair_.GenerateCertificate(); |
| 260 if (local_certificate.empty()) { |
| 261 LOG(ERROR) << "Failed to generate host certificate."; |
| 262 Shutdown(kHostInitializationFailed); |
| 263 return; |
| 264 } |
| 265 |
258 scoped_ptr<protocol::AuthenticatorFactory> factory( | 266 scoped_ptr<protocol::AuthenticatorFactory> factory( |
259 new protocol::Me2MeHostAuthenticatorFactory( | 267 new protocol::Me2MeHostAuthenticatorFactory( |
260 key_pair_.GenerateCertificate(), | 268 local_certificate, *key_pair_.private_key(), host_secret_hash_)); |
261 *key_pair_.private_key(), host_secret_hash_)); | |
262 host_->SetAuthenticatorFactory(factory.Pass()); | 269 host_->SetAuthenticatorFactory(factory.Pass()); |
263 } | 270 } |
264 | 271 |
265 // IPC::Listener implementation. | 272 // IPC::Listener implementation. |
266 virtual bool OnMessageReceived(const IPC::Message& message) { | 273 virtual bool OnMessageReceived(const IPC::Message& message) { |
267 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 274 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
268 | 275 |
269 #if defined(REMOTING_MULTI_PROCESS) | 276 #if defined(REMOTING_MULTI_PROCESS) |
270 bool handled = true; | 277 bool handled = true; |
271 IPC_BEGIN_MESSAGE_MAP(HostProcess, message) | 278 IPC_BEGIN_MESSAGE_MAP(HostProcess, message) |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 user32.GetFunctionPointer("SetProcessDPIAware")); | 813 user32.GetFunctionPointer("SetProcessDPIAware")); |
807 set_process_dpi_aware(); | 814 set_process_dpi_aware(); |
808 } | 815 } |
809 | 816 |
810 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 817 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
811 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 818 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
812 return main(0, NULL); | 819 return main(0, NULL); |
813 } | 820 } |
814 | 821 |
815 #endif // defined(OS_WIN) | 822 #endif // defined(OS_WIN) |
OLD | NEW |