| 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 <string.h> | 7 #include <string.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 190 } |
| 191 #endif // OS_WIN | 191 #endif // OS_WIN |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 void CloseFile(base::File file) { | 194 void CloseFile(base::File file) { |
| 195 // The base::File destructor will close the file for us. | 195 // The base::File destructor will close the file for us. |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace | 198 } // namespace |
| 199 | 199 |
| 200 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = | |
| 201 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; | |
| 202 | |
| 203 NaClProcessHost::NaClProcessHost( | 200 NaClProcessHost::NaClProcessHost( |
| 204 const GURL& manifest_url, | 201 const GURL& manifest_url, |
| 205 base::File nexe_file, | 202 base::File nexe_file, |
| 206 const NaClFileToken& nexe_token, | 203 const NaClFileToken& nexe_token, |
| 207 const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files, | 204 const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files, |
| 208 ppapi::PpapiPermissions permissions, | 205 ppapi::PpapiPermissions permissions, |
| 209 int render_view_id, | 206 int render_view_id, |
| 210 uint32_t permission_bits, | 207 uint32_t permission_bits, |
| 211 bool uses_nonsfi_mode, | 208 bool uses_nonsfi_mode, |
| 212 bool off_the_record, | 209 bool off_the_record, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 334 } |
| 338 | 335 |
| 339 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 336 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 340 // static | 337 // static |
| 341 void NaClProcessHost::EarlyZygoteLaunch() { | 338 void NaClProcessHost::EarlyZygoteLaunch() { |
| 342 DCHECK(!g_nacl_zygote); | 339 DCHECK(!g_nacl_zygote); |
| 343 g_nacl_zygote = content::CreateZygote(); | 340 g_nacl_zygote = content::CreateZygote(); |
| 344 } | 341 } |
| 345 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 342 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 346 | 343 |
| 347 // static | |
| 348 void NaClProcessHost::SetPpapiKeepAliveThrottleForTesting( | |
| 349 unsigned milliseconds) { | |
| 350 keepalive_throttle_interval_milliseconds_ = milliseconds; | |
| 351 } | |
| 352 | |
| 353 void NaClProcessHost::Launch( | 344 void NaClProcessHost::Launch( |
| 354 NaClHostMessageFilter* nacl_host_message_filter, | 345 NaClHostMessageFilter* nacl_host_message_filter, |
| 355 IPC::Message* reply_msg, | 346 IPC::Message* reply_msg, |
| 356 const base::FilePath& manifest_path) { | 347 const base::FilePath& manifest_path) { |
| 357 nacl_host_message_filter_ = nacl_host_message_filter; | 348 nacl_host_message_filter_ = nacl_host_message_filter; |
| 358 reply_msg_ = reply_msg; | 349 reply_msg_ = reply_msg; |
| 359 manifest_path_ = manifest_path; | 350 manifest_path_ = manifest_path; |
| 360 | 351 |
| 361 // Do not launch the requested NaCl module if NaCl is marked "unstable" due | 352 // Do not launch the requested NaCl module if NaCl is marked "unstable" due |
| 362 // to too many crashes within a given time period. | 353 // to too many crashes within a given time period. |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 // Create the browser ppapi host and enable PPAPI message dispatching to the | 914 // Create the browser ppapi host and enable PPAPI message dispatching to the |
| 924 // browser process. | 915 // browser process. |
| 925 ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess( | 916 ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess( |
| 926 ipc_proxy_channel_.get(), // sender | 917 ipc_proxy_channel_.get(), // sender |
| 927 permissions_, | 918 permissions_, |
| 928 process_->GetData().handle, | 919 process_->GetData().handle, |
| 929 ipc_proxy_channel_.get(), | 920 ipc_proxy_channel_.get(), |
| 930 nacl_host_message_filter_->render_process_id(), | 921 nacl_host_message_filter_->render_process_id(), |
| 931 render_view_id_, | 922 render_view_id_, |
| 932 profile_directory_)); | 923 profile_directory_)); |
| 933 ppapi_host_->SetOnKeepaliveCallback( | |
| 934 NaClBrowser::GetDelegate()->GetOnKeepaliveCallback()); | |
| 935 | 924 |
| 936 ppapi::PpapiNaClPluginArgs args; | 925 ppapi::PpapiNaClPluginArgs args; |
| 937 args.off_the_record = nacl_host_message_filter_->off_the_record(); | 926 args.off_the_record = nacl_host_message_filter_->off_the_record(); |
| 938 args.permissions = permissions_; | 927 args.permissions = permissions_; |
| 939 args.keepalive_throttle_interval_milliseconds = | |
| 940 keepalive_throttle_interval_milliseconds_; | |
| 941 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 928 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 942 DCHECK(cmdline); | 929 DCHECK(cmdline); |
| 943 std::string flag_whitelist[] = { | 930 std::string flag_whitelist[] = { |
| 944 switches::kV, | 931 switches::kV, |
| 945 switches::kVModule, | 932 switches::kVModule, |
| 946 }; | 933 }; |
| 947 for (size_t i = 0; i < arraysize(flag_whitelist); ++i) { | 934 for (size_t i = 0; i < arraysize(flag_whitelist); ++i) { |
| 948 std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]); | 935 std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]); |
| 949 if (!value.empty()) { | 936 if (!value.empty()) { |
| 950 args.switch_names.push_back(flag_whitelist[i]); | 937 args.switch_names.push_back(flag_whitelist[i]); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 NaClStartDebugExceptionHandlerThread( | 1141 NaClStartDebugExceptionHandlerThread( |
| 1155 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), | 1142 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), |
| 1156 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1143 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1157 weak_factory_.GetWeakPtr())); | 1144 weak_factory_.GetWeakPtr())); |
| 1158 return true; | 1145 return true; |
| 1159 } | 1146 } |
| 1160 } | 1147 } |
| 1161 #endif | 1148 #endif |
| 1162 | 1149 |
| 1163 } // namespace nacl | 1150 } // namespace nacl |
| OLD | NEW |