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