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