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 #include "build/build_config.h" | |
6 | |
7 #include "chrome/browser/nacl_host/nacl_process_host.h" | 5 #include "chrome/browser/nacl_host/nacl_process_host.h" |
8 | 6 |
9 #if defined(OS_POSIX) | 7 #include <string> |
10 #include <fcntl.h> | 8 #include <vector> |
11 #endif | |
12 | 9 |
13 #include "base/bind.h" | 10 #include "base/bind.h" |
14 #include "base/command_line.h" | 11 #include "base/command_line.h" |
15 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
16 #include "base/path_service.h" | 13 #include "base/path_service.h" |
17 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
18 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
19 #include "base/win/windows_version.h" | 16 #include "base/win/windows_version.h" |
| 17 #include "build/build_config.h" |
20 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/logging_chrome.h" | 20 #include "chrome/common/logging_chrome.h" |
23 #include "chrome/common/nacl_cmd_line.h" | 21 #include "chrome/common/nacl_cmd_line.h" |
24 #include "chrome/common/nacl_messages.h" | 22 #include "chrome/common/nacl_messages.h" |
25 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
26 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 24 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
27 #include "content/public/browser/browser_child_process_host.h" | 25 #include "content/public/browser/browser_child_process_host.h" |
28 #include "content/public/browser/child_process_data.h" | 26 #include "content/public/browser/child_process_data.h" |
29 #include "content/public/common/child_process_host.h" | 27 #include "content/public/common/child_process_host.h" |
30 #include "ipc/ipc_switches.h" | 28 #include "ipc/ipc_switches.h" |
31 #include "native_client/src/shared/imc/nacl_imc.h" | 29 #include "native_client/src/shared/imc/nacl_imc.h" |
32 | 30 |
33 #if defined(OS_POSIX) | 31 #if defined(OS_POSIX) |
| 32 #include <fcntl.h> |
| 33 |
34 #include "ipc/ipc_channel_posix.h" | 34 #include "ipc/ipc_channel_posix.h" |
35 #elif defined(OS_WIN) | 35 #elif defined(OS_WIN) |
| 36 #include <windows.h> |
| 37 |
36 #include "base/threading/thread.h" | 38 #include "base/threading/thread.h" |
37 #include "base/process_util.h" | 39 #include "base/process_util.h" |
38 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" | 40 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" |
39 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler.
h" | 41 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler.
h" |
40 #include <windows.h> | |
41 #endif | 42 #endif |
42 | 43 |
43 using content::BrowserThread; | 44 using content::BrowserThread; |
44 using content::ChildProcessData; | 45 using content::ChildProcessData; |
45 using content::ChildProcessHost; | 46 using content::ChildProcessHost; |
46 | 47 |
47 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
48 class NaClProcessHost::DebugContext | 49 class NaClProcessHost::DebugContext |
49 : public base::RefCountedThreadSafe<NaClProcessHost::DebugContext> { | 50 : public base::RefCountedThreadSafe<NaClProcessHost::DebugContext> { |
50 public: | 51 public: |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 // On Windows we might need to start the broker process to launch a new loader | 407 // On Windows we might need to start the broker process to launch a new loader |
407 #if defined(OS_WIN) | 408 #if defined(OS_WIN) |
408 if (RunningOnWOW64()) { | 409 if (RunningOnWOW64()) { |
409 return NaClBrokerService::GetInstance()->LaunchLoader( | 410 return NaClBrokerService::GetInstance()->LaunchLoader( |
410 this, ASCIIToWide(channel_id)); | 411 this, ASCIIToWide(channel_id)); |
411 } else { | 412 } else { |
412 process_->Launch(FilePath(), cmd_line); | 413 process_->Launch(FilePath(), cmd_line); |
413 } | 414 } |
414 #elif defined(OS_POSIX) | 415 #elif defined(OS_POSIX) |
415 process_->Launch(nacl_loader_prefix.empty(), // use_zygote | 416 process_->Launch(nacl_loader_prefix.empty(), // use_zygote |
416 base::environment_vector(), | 417 base::EnvironmentVector(), |
417 cmd_line); | 418 cmd_line); |
418 #endif | 419 #endif |
419 | 420 |
420 return true; | 421 return true; |
421 } | 422 } |
422 | 423 |
423 void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) { | 424 void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) { |
424 process_->SetHandle(handle); | 425 process_->SetHandle(handle); |
425 OnProcessLaunched(); | 426 OnProcessLaunched(); |
426 } | 427 } |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 process_->Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); | 727 process_->Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); |
727 #endif | 728 #endif |
728 | 729 |
729 internal_->sockets_for_sel_ldr.clear(); | 730 internal_->sockets_for_sel_ldr.clear(); |
730 } | 731 } |
731 | 732 |
732 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { | 733 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
733 NOTREACHED() << "Invalid message with type = " << msg.type(); | 734 NOTREACHED() << "Invalid message with type = " << msg.type(); |
734 return false; | 735 return false; |
735 } | 736 } |
OLD | NEW |