| 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 "components/nacl/browser/nacl_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
| 42 #include "content/public/common/process_type.h" | 42 #include "content/public/common/process_type.h" |
| 43 #include "ipc/ipc_channel.h" | 43 #include "ipc/ipc_channel.h" |
| 44 #include "ipc/ipc_switches.h" | 44 #include "ipc/ipc_switches.h" |
| 45 #include "native_client/src/shared/imc/nacl_imc_c.h" | 45 #include "native_client/src/shared/imc/nacl_imc_c.h" |
| 46 #include "net/base/net_util.h" | 46 #include "net/base/net_util.h" |
| 47 #include "net/socket/tcp_listen_socket.h" | 47 #include "net/socket/tcp_listen_socket.h" |
| 48 #include "ppapi/host/host_factory.h" | 48 #include "ppapi/host/host_factory.h" |
| 49 #include "ppapi/host/ppapi_host.h" | 49 #include "ppapi/host/ppapi_host.h" |
| 50 #include "ppapi/proxy/ppapi_messages.h" | 50 #include "ppapi/proxy/ppapi_messages.h" |
| 51 #include "ppapi/shared_impl/ppapi_constants.h" |
| 51 #include "ppapi/shared_impl/ppapi_nacl_plugin_args.h" | 52 #include "ppapi/shared_impl/ppapi_nacl_plugin_args.h" |
| 52 #include "ppapi/shared_impl/ppapi_switches.h" | |
| 53 | 53 |
| 54 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
| 55 |
| 55 #include <fcntl.h> | 56 #include <fcntl.h> |
| 56 | 57 |
| 57 #include "ipc/ipc_channel_posix.h" | 58 #include "ipc/ipc_channel_posix.h" |
| 58 #elif defined(OS_WIN) | 59 #elif defined(OS_WIN) |
| 59 #include <windows.h> | 60 #include <windows.h> |
| 60 | 61 |
| 61 #include "base/threading/thread.h" | 62 #include "base/threading/thread.h" |
| 62 #include "base/win/scoped_handle.h" | 63 #include "base/win/scoped_handle.h" |
| 63 #include "components/nacl/browser/nacl_broker_service_win.h" | 64 #include "components/nacl/browser/nacl_broker_service_win.h" |
| 64 #include "components/nacl/common/nacl_debug_exception_handler_win.h" | 65 #include "components/nacl/common/nacl_debug_exception_handler_win.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 NaClHandle socket_for_renderer; | 227 NaClHandle socket_for_renderer; |
| 227 NaClHandle socket_for_sel_ldr; | 228 NaClHandle socket_for_sel_ldr; |
| 228 | 229 |
| 229 NaClInternal() | 230 NaClInternal() |
| 230 : socket_for_renderer(NACL_INVALID_HANDLE), | 231 : socket_for_renderer(NACL_INVALID_HANDLE), |
| 231 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } | 232 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } |
| 232 }; | 233 }; |
| 233 | 234 |
| 234 // ----------------------------------------------------------------------------- | 235 // ----------------------------------------------------------------------------- |
| 235 | 236 |
| 237 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = |
| 238 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; |
| 239 |
| 236 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, | 240 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, |
| 237 int render_view_id, | 241 int render_view_id, |
| 238 uint32 permission_bits, | 242 uint32 permission_bits, |
| 239 bool uses_irt, | 243 bool uses_irt, |
| 240 bool uses_nonsfi_mode, | 244 bool uses_nonsfi_mode, |
| 241 bool enable_dyncode_syscalls, | 245 bool enable_dyncode_syscalls, |
| 242 bool enable_exception_handling, | 246 bool enable_exception_handling, |
| 243 bool enable_crash_throttling, | 247 bool enable_crash_throttling, |
| 244 bool off_the_record, | 248 bool off_the_record, |
| 245 const base::FilePath& profile_directory) | 249 const base::FilePath& profile_directory) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 cmd->GetSwitchValueASCII(switches::kNaClDebugMask); | 351 cmd->GetSwitchValueASCII(switches::kNaClDebugMask); |
| 348 // By default, exclude debugging SSH and the PNaCl translator. | 352 // By default, exclude debugging SSH and the PNaCl translator. |
| 349 // about::flags only allows empty flags as the default, so replace | 353 // about::flags only allows empty flags as the default, so replace |
| 350 // the empty setting with the default. To debug all apps, use a wild-card. | 354 // the empty setting with the default. To debug all apps, use a wild-card. |
| 351 if (nacl_debug_mask.empty()) { | 355 if (nacl_debug_mask.empty()) { |
| 352 nacl_debug_mask = "!*://*/*ssh_client.nmf,chrome://pnacl-translator/*"; | 356 nacl_debug_mask = "!*://*/*ssh_client.nmf,chrome://pnacl-translator/*"; |
| 353 } | 357 } |
| 354 NaClBrowser::GetDelegate()->SetDebugPatterns(nacl_debug_mask); | 358 NaClBrowser::GetDelegate()->SetDebugPatterns(nacl_debug_mask); |
| 355 } | 359 } |
| 356 | 360 |
| 361 // static |
| 362 void NaClProcessHost::SetPpapiKeepAliveThrottleForTesting( |
| 363 unsigned milliseconds) { |
| 364 keepalive_throttle_interval_milliseconds_ = milliseconds; |
| 365 } |
| 366 |
| 357 void NaClProcessHost::Launch( | 367 void NaClProcessHost::Launch( |
| 358 NaClHostMessageFilter* nacl_host_message_filter, | 368 NaClHostMessageFilter* nacl_host_message_filter, |
| 359 IPC::Message* reply_msg, | 369 IPC::Message* reply_msg, |
| 360 const base::FilePath& manifest_path) { | 370 const base::FilePath& manifest_path) { |
| 361 nacl_host_message_filter_ = nacl_host_message_filter; | 371 nacl_host_message_filter_ = nacl_host_message_filter; |
| 362 reply_msg_ = reply_msg; | 372 reply_msg_ = reply_msg; |
| 363 manifest_path_ = manifest_path; | 373 manifest_path_ = manifest_path; |
| 364 | 374 |
| 365 // Do not launch the requested NaCl module if NaCl is marked "unstable" due | 375 // Do not launch the requested NaCl module if NaCl is marked "unstable" due |
| 366 // to too many crashes within a given time period. | 376 // to too many crashes within a given time period. |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 ipc_proxy_channel_.get(), | 861 ipc_proxy_channel_.get(), |
| 852 nacl_host_message_filter_->render_process_id(), | 862 nacl_host_message_filter_->render_process_id(), |
| 853 render_view_id_, | 863 render_view_id_, |
| 854 profile_directory_)); | 864 profile_directory_)); |
| 855 ppapi_host_->SetOnKeepaliveCallback( | 865 ppapi_host_->SetOnKeepaliveCallback( |
| 856 NaClBrowser::GetDelegate()->GetOnKeepaliveCallback()); | 866 NaClBrowser::GetDelegate()->GetOnKeepaliveCallback()); |
| 857 | 867 |
| 858 ppapi::PpapiNaClPluginArgs args; | 868 ppapi::PpapiNaClPluginArgs args; |
| 859 args.off_the_record = nacl_host_message_filter_->off_the_record(); | 869 args.off_the_record = nacl_host_message_filter_->off_the_record(); |
| 860 args.permissions = permissions_; | 870 args.permissions = permissions_; |
| 871 args.keepalive_throttle_interval_milliseconds = |
| 872 keepalive_throttle_interval_milliseconds_; |
| 861 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 873 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 862 DCHECK(cmdline); | 874 DCHECK(cmdline); |
| 863 std::string flag_whitelist[] = { | 875 std::string flag_whitelist[] = { |
| 864 switches::kPpapiKeepAliveThrottle, | |
| 865 switches::kV, | 876 switches::kV, |
| 866 switches::kVModule, | 877 switches::kVModule, |
| 867 }; | 878 }; |
| 868 for (size_t i = 0; i < arraysize(flag_whitelist); ++i) { | 879 for (size_t i = 0; i < arraysize(flag_whitelist); ++i) { |
| 869 std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]); | 880 std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]); |
| 870 if (!value.empty()) { | 881 if (!value.empty()) { |
| 871 args.switch_names.push_back(flag_whitelist[i]); | 882 args.switch_names.push_back(flag_whitelist[i]); |
| 872 args.switch_values.push_back(value); | 883 args.switch_values.push_back(value); |
| 873 } | 884 } |
| 874 } | 885 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 process_handle.Take(), info, | 1068 process_handle.Take(), info, |
| 1058 base::MessageLoopProxy::current(), | 1069 base::MessageLoopProxy::current(), |
| 1059 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1070 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1060 weak_factory_.GetWeakPtr())); | 1071 weak_factory_.GetWeakPtr())); |
| 1061 return true; | 1072 return true; |
| 1062 } | 1073 } |
| 1063 } | 1074 } |
| 1064 #endif | 1075 #endif |
| 1065 | 1076 |
| 1066 } // namespace nacl | 1077 } // namespace nacl |
| OLD | NEW |