| 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 #ifdef _MSC_VER | 5 #ifdef _MSC_VER |
| 6 // Do not warn about use of std::copy with raw pointers. | 6 // Do not warn about use of std::copy with raw pointers. |
| 7 #pragma warning(disable : 4996) | 7 #pragma warning(disable : 4996) |
| 8 #endif | 8 #endif |
| 9 | 9 |
| 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "native_client/src/shared/platform/nacl_check.h" | 27 #include "native_client/src/shared/platform/nacl_check.h" |
| 28 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 28 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| 29 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" | 29 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" |
| 30 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 30 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
| 31 | 31 |
| 32 #include "ppapi/c/pp_errors.h" | 32 #include "ppapi/c/pp_errors.h" |
| 33 #include "ppapi/c/ppb_console.h" | 33 #include "ppapi/c/ppb_console.h" |
| 34 #include "ppapi/c/ppb_var.h" | 34 #include "ppapi/c/ppb_var.h" |
| 35 #include "ppapi/c/ppp_instance.h" | 35 #include "ppapi/c/ppp_instance.h" |
| 36 #include "ppapi/c/private/ppb_nacl_private.h" | 36 #include "ppapi/c/private/ppb_nacl_private.h" |
| 37 #include "ppapi/c/private/ppb_uma_private.h" | |
| 38 #include "ppapi/cpp/dev/url_util_dev.h" | 37 #include "ppapi/cpp/dev/url_util_dev.h" |
| 39 #include "ppapi/cpp/module.h" | 38 #include "ppapi/cpp/module.h" |
| 40 #include "ppapi/cpp/text_input_controller.h" | 39 #include "ppapi/cpp/text_input_controller.h" |
| 41 | 40 |
| 42 #include "ppapi/native_client/src/trusted/plugin/file_utils.h" | 41 #include "ppapi/native_client/src/trusted/plugin/file_utils.h" |
| 43 #include "ppapi/native_client/src/trusted/plugin/json_manifest.h" | 42 #include "ppapi/native_client/src/trusted/plugin/json_manifest.h" |
| 44 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" | 43 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" |
| 45 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" | 44 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" |
| 46 #include "ppapi/native_client/src/trusted/plugin/nexe_arch.h" | 45 #include "ppapi/native_client/src/trusted/plugin/nexe_arch.h" |
| 47 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" | 46 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const int64_t kSizeKBMax = 512*1024; // very large .nexe | 96 const int64_t kSizeKBMax = 512*1024; // very large .nexe |
| 98 const uint32_t kSizeKBBuckets = 100; | 97 const uint32_t kSizeKBBuckets = 100; |
| 99 | 98 |
| 100 const PPB_NaCl_Private* GetNaClInterface() { | 99 const PPB_NaCl_Private* GetNaClInterface() { |
| 101 pp::Module *module = pp::Module::Get(); | 100 pp::Module *module = pp::Module::Get(); |
| 102 CHECK(module); | 101 CHECK(module); |
| 103 return static_cast<const PPB_NaCl_Private*>( | 102 return static_cast<const PPB_NaCl_Private*>( |
| 104 module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE)); | 103 module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE)); |
| 105 } | 104 } |
| 106 | 105 |
| 107 const PPB_UMA_Private* GetUMAInterface() { | 106 } // namespace |
| 108 pp::Module *module = pp::Module::Get(); | 107 |
| 109 CHECK(module); | 108 bool Plugin::EarlyInit(int argc, const char* argn[], const char* argv[]) { |
| 110 return static_cast<const PPB_UMA_Private*>( | 109 PLUGIN_PRINTF(("Plugin::EarlyInit (instance=%p)\n", |
| 111 module->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE)); | 110 static_cast<void*>(this))); |
| 111 |
| 112 #ifdef NACL_OSX |
| 113 // TODO(kochi): For crbug.com/102808, this is a stopgap solution for Lion |
| 114 // until we expose IME API to .nexe. This disables any IME interference |
| 115 // against key inputs, so you cannot use off-the-spot IME input for NaCl apps. |
| 116 // This makes discrepancy among platforms and therefore we should remove |
| 117 // this hack when IME API is made available. |
| 118 // The default for non-Mac platforms is still off-the-spot IME mode. |
| 119 pp::TextInputController(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE); |
| 120 #endif |
| 121 |
| 122 // Remember the embed/object argn/argv pairs. |
| 123 argn_ = new char*[argc]; |
| 124 argv_ = new char*[argc]; |
| 125 argc_ = 0; |
| 126 for (int i = 0; i < argc; ++i) { |
| 127 if (NULL != argn_ && NULL != argv_) { |
| 128 argn_[argc_] = strdup(argn[i]); |
| 129 argv_[argc_] = strdup(argv[i]); |
| 130 if (NULL == argn_[argc_] || NULL == argv_[argc_]) { |
| 131 // Give up on passing arguments. |
| 132 free(argn_[argc_]); |
| 133 free(argv_[argc_]); |
| 134 continue; |
| 135 } |
| 136 ++argc_; |
| 137 } |
| 138 } |
| 139 // TODO(sehr): this leaks strings if there is a subsequent failure. |
| 140 |
| 141 // Set up the factory used to produce DescWrappers. |
| 142 wrapper_factory_ = new nacl::DescWrapperFactory(); |
| 143 if (NULL == wrapper_factory_) { |
| 144 return false; |
| 145 } |
| 146 PLUGIN_PRINTF(("Plugin::Init (wrapper_factory=%p)\n", |
| 147 static_cast<void*>(wrapper_factory_))); |
| 148 |
| 149 PLUGIN_PRINTF(("Plugin::Init (return 1)\n")); |
| 150 // Return success. |
| 151 return true; |
| 112 } | 152 } |
| 113 | 153 |
| 114 void HistogramTimeSmall(const std::string& name, int64_t ms) { | 154 void Plugin::ShutDownSubprocesses() { |
| 115 if (ms < 0) return; | 155 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n", |
| 156 static_cast<void*>(this))); |
| 157 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n", |
| 158 main_subprocess_.detailed_description().c_str())); |
| 116 | 159 |
| 117 const PPB_UMA_Private* ptr = GetUMAInterface(); | 160 // Shut down service runtime. This must be done before all other calls so |
| 118 if (ptr == NULL) return; | 161 // they don't block forever when waiting for the upcall thread to exit. |
| 162 main_subprocess_.Shutdown(); |
| 119 | 163 |
| 120 ptr->HistogramCustomTimes(pp::Var(name).pp_var(), | 164 PLUGIN_PRINTF(("Plugin::ShutDownSubprocess (this=%p, return)\n", |
| 121 ms, | 165 static_cast<void*>(this))); |
| 122 kTimeSmallMin, kTimeSmallMax, | |
| 123 kTimeSmallBuckets); | |
| 124 } | 166 } |
| 125 | 167 |
| 126 void HistogramTimeMedium(const std::string& name, int64_t ms) { | 168 void Plugin::HistogramTimeSmall(const std::string& name, |
| 169 int64_t ms) { |
| 127 if (ms < 0) return; | 170 if (ms < 0) return; |
| 128 | 171 uma_interface_.HistogramCustomTimes(name, |
| 129 const PPB_UMA_Private* ptr = GetUMAInterface(); | 172 ms, |
| 130 if (ptr == NULL) return; | 173 kTimeSmallMin, kTimeSmallMax, |
| 131 | 174 kTimeSmallBuckets); |
| 132 ptr->HistogramCustomTimes(pp::Var(name).pp_var(), | |
| 133 ms, | |
| 134 kTimeMediumMin, kTimeMediumMax, | |
| 135 kTimeMediumBuckets); | |
| 136 } | 175 } |
| 137 | 176 |
| 138 void HistogramTimeLarge(const std::string& name, int64_t ms) { | 177 void Plugin::HistogramTimeMedium(const std::string& name, |
| 178 int64_t ms) { |
| 139 if (ms < 0) return; | 179 if (ms < 0) return; |
| 140 | 180 uma_interface_.HistogramCustomTimes(name, |
| 141 const PPB_UMA_Private* ptr = GetUMAInterface(); | 181 ms, |
| 142 if (ptr == NULL) return; | 182 kTimeMediumMin, kTimeMediumMax, |
| 143 | 183 kTimeMediumBuckets); |
| 144 ptr->HistogramCustomTimes(pp::Var(name).pp_var(), | |
| 145 ms, | |
| 146 kTimeLargeMin, kTimeLargeMax, | |
| 147 kTimeLargeBuckets); | |
| 148 } | 184 } |
| 149 | 185 |
| 150 void HistogramSizeKB(const std::string& name, int32_t sample) { | 186 void Plugin::HistogramTimeLarge(const std::string& name, |
| 151 if (sample < 0) return; | 187 int64_t ms) { |
| 152 | 188 if (ms < 0) return; |
| 153 const PPB_UMA_Private* ptr = GetUMAInterface(); | 189 uma_interface_.HistogramCustomTimes(name, |
| 154 if (ptr == NULL) return; | 190 ms, |
| 155 | 191 kTimeLargeMin, kTimeLargeMax, |
| 156 ptr->HistogramCustomCounts(pp::Var(name).pp_var(), | 192 kTimeLargeBuckets); |
| 157 sample, | |
| 158 kSizeKBMin, kSizeKBMax, | |
| 159 kSizeKBBuckets); | |
| 160 } | 193 } |
| 161 | 194 |
| 162 void HistogramEnumerate(const std::string& name, int sample, int maximum, | 195 void Plugin::HistogramSizeKB(const std::string& name, |
| 163 int out_of_range_replacement) { | 196 int32_t sample) { |
| 197 if (sample < 0) return; |
| 198 uma_interface_.HistogramCustomCounts(name, |
| 199 sample, |
| 200 kSizeKBMin, kSizeKBMax, |
| 201 kSizeKBBuckets); |
| 202 } |
| 203 |
| 204 void Plugin::HistogramEnumerate(const std::string& name, |
| 205 int sample, |
| 206 int maximum, |
| 207 int out_of_range_replacement) { |
| 164 if (sample < 0 || sample >= maximum) { | 208 if (sample < 0 || sample >= maximum) { |
| 165 if (out_of_range_replacement < 0) | 209 if (out_of_range_replacement < 0) |
| 166 // No replacement for bad input, abort. | 210 // No replacement for bad input, abort. |
| 167 return; | 211 return; |
| 168 else | 212 else |
| 169 // Use a specific value to signal a bad input. | 213 // Use a specific value to signal a bad input. |
| 170 sample = out_of_range_replacement; | 214 sample = out_of_range_replacement; |
| 171 } | 215 } |
| 172 const PPB_UMA_Private* ptr = GetUMAInterface(); | 216 uma_interface_.HistogramEnumeration(name, sample, maximum); |
| 173 if (ptr == NULL) return; | |
| 174 ptr->HistogramEnumeration(pp::Var(name).pp_var(), sample, maximum); | |
| 175 } | 217 } |
| 176 | 218 |
| 177 void HistogramEnumerateOsArch(const std::string& sandbox_isa) { | 219 void Plugin::HistogramEnumerateOsArch(const std::string& sandbox_isa) { |
| 178 enum NaClOSArch { | 220 enum NaClOSArch { |
| 179 kNaClLinux32 = 0, | 221 kNaClLinux32 = 0, |
| 180 kNaClLinux64, | 222 kNaClLinux64, |
| 181 kNaClLinuxArm, | 223 kNaClLinuxArm, |
| 182 kNaClMac32, | 224 kNaClMac32, |
| 183 kNaClMac64, | 225 kNaClMac64, |
| 184 kNaClMacArm, | 226 kNaClMacArm, |
| 185 kNaClWin32, | 227 kNaClWin32, |
| 186 kNaClWin64, | 228 kNaClWin64, |
| 187 kNaClWinArm, | 229 kNaClWinArm, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 198 #endif | 240 #endif |
| 199 | 241 |
| 200 if (sandbox_isa == "x86-64") | 242 if (sandbox_isa == "x86-64") |
| 201 os_arch = static_cast<NaClOSArch>(os_arch + 1); | 243 os_arch = static_cast<NaClOSArch>(os_arch + 1); |
| 202 if (sandbox_isa == "arm") | 244 if (sandbox_isa == "arm") |
| 203 os_arch = static_cast<NaClOSArch>(os_arch + 2); | 245 os_arch = static_cast<NaClOSArch>(os_arch + 2); |
| 204 | 246 |
| 205 HistogramEnumerate("NaCl.Client.OSArch", os_arch, kNaClOSArchMax, -1); | 247 HistogramEnumerate("NaCl.Client.OSArch", os_arch, kNaClOSArchMax, -1); |
| 206 } | 248 } |
| 207 | 249 |
| 208 void HistogramEnumerateLoadStatus(PluginErrorCode error_code, | 250 void Plugin::HistogramEnumerateLoadStatus(PluginErrorCode error_code, |
| 209 bool is_installed) { | 251 bool is_installed) { |
| 210 HistogramEnumerate("NaCl.LoadStatus.Plugin", error_code, ERROR_MAX, | 252 HistogramEnumerate("NaCl.LoadStatus.Plugin", error_code, ERROR_MAX, |
| 211 ERROR_UNKNOWN); | 253 ERROR_UNKNOWN); |
| 212 | 254 |
| 213 // Gather data to see if being installed changes load outcomes. | 255 // Gather data to see if being installed changes load outcomes. |
| 214 const char* name = is_installed ? "NaCl.LoadStatus.Plugin.InstalledApp" : | 256 const char* name = is_installed ? "NaCl.LoadStatus.Plugin.InstalledApp" : |
| 215 "NaCl.LoadStatus.Plugin.NotInstalledApp"; | 257 "NaCl.LoadStatus.Plugin.NotInstalledApp"; |
| 216 HistogramEnumerate(name, error_code, ERROR_MAX, | 258 HistogramEnumerate(name, error_code, ERROR_MAX, ERROR_UNKNOWN); |
| 217 ERROR_UNKNOWN); | |
| 218 } | 259 } |
| 219 | 260 |
| 220 void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code, | 261 void Plugin::HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code, |
| 221 bool is_installed) { | 262 bool is_installed) { |
| 222 HistogramEnumerate("NaCl.LoadStatus.SelLdr", error_code, NACL_ERROR_CODE_MAX, | 263 HistogramEnumerate("NaCl.LoadStatus.SelLdr", error_code, |
| 223 LOAD_STATUS_UNKNOWN); | 264 NACL_ERROR_CODE_MAX, LOAD_STATUS_UNKNOWN); |
| 224 | 265 |
| 225 // Gather data to see if being installed changes load outcomes. | 266 // Gather data to see if being installed changes load outcomes. |
| 226 const char* name = is_installed ? "NaCl.LoadStatus.SelLdr.InstalledApp" : | 267 const char* name = is_installed ? "NaCl.LoadStatus.SelLdr.InstalledApp" : |
| 227 "NaCl.LoadStatus.SelLdr.NotInstalledApp"; | 268 "NaCl.LoadStatus.SelLdr.NotInstalledApp"; |
| 228 HistogramEnumerate(name, error_code, NACL_ERROR_CODE_MAX, | 269 HistogramEnumerate(name, error_code, NACL_ERROR_CODE_MAX, |
| 229 LOAD_STATUS_UNKNOWN); | 270 LOAD_STATUS_UNKNOWN); |
| 230 } | 271 } |
| 231 | 272 |
| 232 void HistogramEnumerateManifestIsDataURI(bool is_data_uri) { | 273 void Plugin::HistogramEnumerateManifestIsDataURI(bool is_data_uri) { |
| 233 HistogramEnumerate("NaCl.Manifest.IsDataURI", is_data_uri, 2, -1); | 274 HistogramEnumerate("NaCl.Manifest.IsDataURI", is_data_uri, 2, -1); |
| 234 } | 275 } |
| 235 | 276 |
| 236 void HistogramHTTPStatusCode(const std::string& name, int status) { | 277 void Plugin::HistogramHTTPStatusCode(const std::string& name, |
| 278 int status) { |
| 237 // Log the status codes in rough buckets - 1XX, 2XX, etc. | 279 // Log the status codes in rough buckets - 1XX, 2XX, etc. |
| 238 int sample = status / 100; | 280 int sample = status / 100; |
| 239 // HTTP status codes only go up to 5XX, using "6" to indicate an internal | 281 // HTTP status codes only go up to 5XX, using "6" to indicate an internal |
| 240 // error. | 282 // error. |
| 241 // Note: installed files may have "0" for a status code. | 283 // Note: installed files may have "0" for a status code. |
| 242 if (status < 0 || status >= 600) | 284 if (status < 0 || status >= 600) |
| 243 sample = 6; | 285 sample = 6; |
| 244 HistogramEnumerate(name, sample, 7, 6); | 286 HistogramEnumerate(name, sample, 7, 6); |
| 245 } | 287 } |
| 246 | 288 |
| 247 } // namespace | |
| 248 | |
| 249 bool Plugin::EarlyInit(int argc, const char* argn[], const char* argv[]) { | |
| 250 PLUGIN_PRINTF(("Plugin::EarlyInit (instance=%p)\n", | |
| 251 static_cast<void*>(this))); | |
| 252 | |
| 253 #ifdef NACL_OSX | |
| 254 // TODO(kochi): For crbug.com/102808, this is a stopgap solution for Lion | |
| 255 // until we expose IME API to .nexe. This disables any IME interference | |
| 256 // against key inputs, so you cannot use off-the-spot IME input for NaCl apps. | |
| 257 // This makes discrepancy among platforms and therefore we should remove | |
| 258 // this hack when IME API is made available. | |
| 259 // The default for non-Mac platforms is still off-the-spot IME mode. | |
| 260 pp::TextInputController(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE); | |
| 261 #endif | |
| 262 | |
| 263 // Remember the embed/object argn/argv pairs. | |
| 264 argn_ = new char*[argc]; | |
| 265 argv_ = new char*[argc]; | |
| 266 argc_ = 0; | |
| 267 for (int i = 0; i < argc; ++i) { | |
| 268 if (NULL != argn_ && NULL != argv_) { | |
| 269 argn_[argc_] = strdup(argn[i]); | |
| 270 argv_[argc_] = strdup(argv[i]); | |
| 271 if (NULL == argn_[argc_] || NULL == argv_[argc_]) { | |
| 272 // Give up on passing arguments. | |
| 273 free(argn_[argc_]); | |
| 274 free(argv_[argc_]); | |
| 275 continue; | |
| 276 } | |
| 277 ++argc_; | |
| 278 } | |
| 279 } | |
| 280 // TODO(sehr): this leaks strings if there is a subsequent failure. | |
| 281 | |
| 282 // Set up the factory used to produce DescWrappers. | |
| 283 wrapper_factory_ = new nacl::DescWrapperFactory(); | |
| 284 if (NULL == wrapper_factory_) { | |
| 285 return false; | |
| 286 } | |
| 287 PLUGIN_PRINTF(("Plugin::Init (wrapper_factory=%p)\n", | |
| 288 static_cast<void*>(wrapper_factory_))); | |
| 289 | |
| 290 PLUGIN_PRINTF(("Plugin::Init (return 1)\n")); | |
| 291 // Return success. | |
| 292 return true; | |
| 293 } | |
| 294 | |
| 295 void Plugin::ShutDownSubprocesses() { | |
| 296 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n", | |
| 297 static_cast<void*>(this))); | |
| 298 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n", | |
| 299 main_subprocess_.detailed_description().c_str())); | |
| 300 | |
| 301 // Shut down service runtime. This must be done before all other calls so | |
| 302 // they don't block forever when waiting for the upcall thread to exit. | |
| 303 main_subprocess_.Shutdown(); | |
| 304 | |
| 305 PLUGIN_PRINTF(("Plugin::ShutDownSubprocess (this=%p, return)\n", | |
| 306 static_cast<void*>(this))); | |
| 307 } | |
| 308 | |
| 309 void Plugin::StartSelLdrOnMainThread(int32_t pp_error, | |
| 310 ServiceRuntime* service_runtime, | |
| 311 const SelLdrStartParams& params, | |
| 312 bool* success) { | |
| 313 if (pp_error != PP_OK) { | |
| 314 PLUGIN_PRINTF(("Plugin::StartSelLdrOnMainThread: non-PP_OK arg " | |
| 315 "-- SHOULD NOT HAPPEN\n")); | |
| 316 *success = false; | |
| 317 return; | |
| 318 } | |
| 319 *success = service_runtime->StartSelLdr(params); | |
| 320 // Signal outside of StartSelLdr here, so that the write to *success | |
| 321 // is done before signaling. | |
| 322 service_runtime->SignalStartSelLdrDone(); | |
| 323 } | |
| 324 | |
| 325 bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper, | 289 bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper, |
| 326 NaClSubprocess* subprocess, | 290 NaClSubprocess* subprocess, |
| 327 const Manifest* manifest, | 291 const Manifest* manifest, |
| 328 bool should_report_uma, | 292 bool should_report_uma, |
| 329 const SelLdrStartParams& params, | 293 const SelLdrStartParams& params, |
| 330 const pp::CompletionCallback& init_done_cb, | 294 const pp::CompletionCallback& init_done_cb, |
| 331 const pp::CompletionCallback& crash_cb) { | 295 const pp::CompletionCallback& crash_cb) { |
| 332 ServiceRuntime* new_service_runtime = | 296 ServiceRuntime* new_service_runtime = |
| 333 new ServiceRuntime(this, manifest, should_report_uma, init_done_cb, | 297 new ServiceRuntime(this, manifest, should_report_uma, init_done_cb, |
| 334 crash_cb); | 298 crash_cb); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 params.error_info, | 331 params.error_info, |
| 368 crash_cb); | 332 crash_cb); |
| 369 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (nexe_loaded=%d)\n", | 333 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (nexe_loaded=%d)\n", |
| 370 nexe_loaded)); | 334 nexe_loaded)); |
| 371 if (!nexe_loaded) { | 335 if (!nexe_loaded) { |
| 372 return false; | 336 return false; |
| 373 } | 337 } |
| 374 return true; | 338 return true; |
| 375 } | 339 } |
| 376 | 340 |
| 341 void Plugin::StartSelLdrOnMainThread(int32_t pp_error, |
| 342 ServiceRuntime* service_runtime, |
| 343 const SelLdrStartParams& params, |
| 344 bool* success) { |
| 345 if (pp_error != PP_OK) { |
| 346 PLUGIN_PRINTF(("Plugin::StartSelLdrOnMainThread: non-PP_OK arg " |
| 347 "-- SHOULD NOT HAPPEN\n")); |
| 348 *success = false; |
| 349 return; |
| 350 } |
| 351 *success = service_runtime->StartSelLdr(params); |
| 352 // Signal outside of StartSelLdr here, so that the write to *success |
| 353 // is done before signaling. |
| 354 service_runtime->SignalStartSelLdrDone(); |
| 355 } |
| 356 |
| 377 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, | 357 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, |
| 378 ErrorInfo* error_info, | 358 ErrorInfo* error_info, |
| 379 bool enable_dyncode_syscalls, | 359 bool enable_dyncode_syscalls, |
| 380 bool enable_exception_handling, | 360 bool enable_exception_handling, |
| 381 bool enable_crash_throttling, | 361 bool enable_crash_throttling, |
| 382 const pp::CompletionCallback& init_done_cb, | 362 const pp::CompletionCallback& init_done_cb, |
| 383 const pp::CompletionCallback& crash_cb) { | 363 const pp::CompletionCallback& crash_cb) { |
| 384 // Before forking a new sel_ldr process, ensure that we do not leak | 364 // Before forking a new sel_ldr process, ensure that we do not leak |
| 385 // the ServiceRuntime object for an existing subprocess, and that any | 365 // the ServiceRuntime object for an existing subprocess, and that any |
| 386 // associated listener threads do not go unjoined because if they | 366 // associated listener threads do not go unjoined because if they |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 main_subprocess_("main subprocess", NULL, NULL), | 624 main_subprocess_("main subprocess", NULL, NULL), |
| 645 nexe_error_reported_(false), | 625 nexe_error_reported_(false), |
| 646 wrapper_factory_(NULL), | 626 wrapper_factory_(NULL), |
| 647 enable_dev_interfaces_(false), | 627 enable_dev_interfaces_(false), |
| 648 is_installed_(false), | 628 is_installed_(false), |
| 649 init_time_(0), | 629 init_time_(0), |
| 650 ready_time_(0), | 630 ready_time_(0), |
| 651 nexe_size_(0), | 631 nexe_size_(0), |
| 652 time_of_last_progress_event_(0), | 632 time_of_last_progress_event_(0), |
| 653 exit_status_(-1), | 633 exit_status_(-1), |
| 654 nacl_interface_(NULL) { | 634 nacl_interface_(NULL), |
| 635 uma_interface_(this) { |
| 655 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 636 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
| 656 NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance)); | 637 NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance)); |
| 657 callback_factory_.Initialize(this); | 638 callback_factory_.Initialize(this); |
| 658 nexe_downloader_.Initialize(this); | 639 nexe_downloader_.Initialize(this); |
| 659 nacl_interface_ = GetNaClInterface(); | 640 nacl_interface_ = GetNaClInterface(); |
| 660 CHECK(nacl_interface_ != NULL); | 641 CHECK(nacl_interface_ != NULL); |
| 661 set_nacl_ready_state(UNSENT); | 642 set_nacl_ready_state(UNSENT); |
| 662 set_last_error_string(""); | 643 set_last_error_string(""); |
| 663 // We call set_exit_status() here to ensure that the 'exitStatus' property is | 644 // We call set_exit_status() here to ensure that the 'exitStatus' property is |
| 664 // set. This can only be called when nacl_interface_ is not NULL. | 645 // set. This can only be called when nacl_interface_ is not NULL. |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 EnqueueProgressEvent( | 1283 EnqueueProgressEvent( |
| 1303 PP_NACL_EVENT_LOAD, url, length_computable, loaded_bytes, total_bytes); | 1284 PP_NACL_EVENT_LOAD, url, length_computable, loaded_bytes, total_bytes); |
| 1304 EnqueueProgressEvent( | 1285 EnqueueProgressEvent( |
| 1305 PP_NACL_EVENT_LOADEND, url, length_computable, loaded_bytes, total_bytes); | 1286 PP_NACL_EVENT_LOADEND, url, length_computable, loaded_bytes, total_bytes); |
| 1306 | 1287 |
| 1307 // UMA | 1288 // UMA |
| 1308 HistogramEnumerateLoadStatus(ERROR_LOAD_SUCCESS, is_installed_); | 1289 HistogramEnumerateLoadStatus(ERROR_LOAD_SUCCESS, is_installed_); |
| 1309 } | 1290 } |
| 1310 | 1291 |
| 1311 | 1292 |
| 1312 // TODO(ncbray): report UMA stats | |
| 1313 void Plugin::ReportLoadError(const ErrorInfo& error_info) { | 1293 void Plugin::ReportLoadError(const ErrorInfo& error_info) { |
| 1314 PLUGIN_PRINTF(("Plugin::ReportLoadError (error='%s')\n", | 1294 PLUGIN_PRINTF(("Plugin::ReportLoadError (error='%s')\n", |
| 1315 error_info.message().c_str())); | 1295 error_info.message().c_str())); |
| 1316 // For errors the user (and not just the developer) should know about, | 1296 // For errors the user (and not just the developer) should know about, |
| 1317 // report them to the renderer so the browser can display a message. | 1297 // report them to the renderer so the browser can display a message. |
| 1318 if (error_info.error_code() == ERROR_MANIFEST_PROGRAM_MISSING_ARCH) { | 1298 if (error_info.error_code() == ERROR_MANIFEST_PROGRAM_MISSING_ARCH) { |
| 1319 // A special case: the manifest may otherwise be valid but is missing | 1299 // A special case: the manifest may otherwise be valid but is missing |
| 1320 // a program/file compatible with the user's sandbox. | 1300 // a program/file compatible with the user's sandbox. |
| 1321 nacl_interface()->ReportNaClError(pp_instance(), | 1301 nacl_interface()->ReportNaClError(pp_instance(), |
| 1322 PP_NACL_MANIFEST_MISSING_ARCH); | 1302 PP_NACL_MANIFEST_MISSING_ARCH); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 DCHECK(pp::Module::Get()->core()->IsMainThread()); | 1571 DCHECK(pp::Module::Get()->core()->IsMainThread()); |
| 1592 DCHECK(nacl_interface_); | 1572 DCHECK(nacl_interface_); |
| 1593 exit_status_ = exit_status; | 1573 exit_status_ = exit_status; |
| 1594 nacl_interface_->SetReadOnlyProperty(pp_instance(), | 1574 nacl_interface_->SetReadOnlyProperty(pp_instance(), |
| 1595 pp::Var("exitStatus").pp_var(), | 1575 pp::Var("exitStatus").pp_var(), |
| 1596 pp::Var(exit_status_).pp_var()); | 1576 pp::Var(exit_status_).pp_var()); |
| 1597 } | 1577 } |
| 1598 | 1578 |
| 1599 | 1579 |
| 1600 } // namespace plugin | 1580 } // namespace plugin |
| OLD | NEW |