OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/nexe_load_manager.h" | 5 #include "components/nacl/renderer/nexe_load_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 SetLastError(error_string); | 224 SetLastError(error_string); |
225 | 225 |
226 // Inform JavaScript that loading was aborted and is complete. | 226 // Inform JavaScript that loading was aborted and is complete. |
227 DispatchProgressEvent(pp_instance_, ProgressEvent(PP_NACL_EVENT_ABORT)); | 227 DispatchProgressEvent(pp_instance_, ProgressEvent(PP_NACL_EVENT_ABORT)); |
228 DispatchProgressEvent(pp_instance_, ProgressEvent(PP_NACL_EVENT_LOADEND)); | 228 DispatchProgressEvent(pp_instance_, ProgressEvent(PP_NACL_EVENT_LOADEND)); |
229 | 229 |
230 HistogramEnumerateLoadStatus(PP_NACL_ERROR_LOAD_ABORTED, is_installed_); | 230 HistogramEnumerateLoadStatus(PP_NACL_ERROR_LOAD_ABORTED, is_installed_); |
231 LogToConsole(error_string); | 231 LogToConsole(error_string); |
232 } | 232 } |
233 | 233 |
234 void NexeLoadManager::NexeDidCrash(const char* crash_log) { | 234 void NexeLoadManager::NexeDidCrash() { |
235 VLOG(1) << "Plugin::NexeDidCrash: crash event!"; | 235 VLOG(1) << "Plugin::NexeDidCrash: crash event!"; |
236 // The NaCl module voluntarily exited. However, this is still a | 236 // The NaCl module voluntarily exited. However, this is still a |
237 // crash from the point of view of Pepper, since PPAPI plugins are | 237 // crash from the point of view of Pepper, since PPAPI plugins are |
238 // event handlers and should never exit. | 238 // event handlers and should never exit. |
239 VLOG_IF(1, exit_status_ != -1) | 239 VLOG_IF(1, exit_status_ != -1) |
240 << "Plugin::NexeDidCrash: nexe exited with status " << exit_status_ | 240 << "Plugin::NexeDidCrash: nexe exited with status " << exit_status_ |
241 << " so this is a \"controlled crash\"."; | 241 << " so this is a \"controlled crash\"."; |
242 // If the crash occurs during load, we just want to report an error | 242 // If the crash occurs during load, we just want to report an error |
243 // that fits into our load progress event grammar. If the crash | 243 // that fits into our load progress event grammar. If the crash |
244 // occurs after loaded/loadend, then we use ReportDeadNexe to send a | 244 // occurs after loaded/loadend, then we use ReportDeadNexe to send a |
245 // "crash" event. | 245 // "crash" event. |
246 if (nexe_error_reported_) { | 246 if (nexe_error_reported_) { |
247 VLOG(1) << "Plugin::NexeDidCrash: error already reported; suppressing"; | 247 VLOG(1) << "Plugin::NexeDidCrash: error already reported; suppressing"; |
248 } else { | 248 } else { |
249 if (nacl_ready_state_ == PP_NACL_READY_STATE_DONE) { | 249 if (nacl_ready_state_ == PP_NACL_READY_STATE_DONE) { |
250 ReportDeadNexe(); | 250 ReportDeadNexe(); |
251 } else { | 251 } else { |
252 ReportLoadError(PP_NACL_ERROR_START_PROXY_CRASH, | 252 ReportLoadError(PP_NACL_ERROR_START_PROXY_CRASH, |
253 "Nexe crashed during startup"); | 253 "Nexe crashed during startup"); |
254 } | 254 } |
255 } | 255 } |
256 // In all cases, try to grab the crash log. The first error | |
257 // reported may have come from the start_module RPC reply indicating | |
258 // a validation error or something similar, which wouldn't grab the | |
259 // crash log. In the event that this is called twice, the second | |
260 // invocation will just be a no-op, since the entire crash log will | |
261 // have been received and we'll just get an EOF indication. | |
262 CopyCrashLogToJsConsole(crash_log); | |
263 } | 256 } |
264 | 257 |
265 void NexeLoadManager::set_trusted_plugin_channel( | 258 void NexeLoadManager::set_trusted_plugin_channel( |
266 scoped_ptr<TrustedPluginChannel> channel) { | 259 scoped_ptr<TrustedPluginChannel> channel) { |
267 trusted_plugin_channel_ = channel.Pass(); | 260 trusted_plugin_channel_ = channel.Pass(); |
268 } | 261 } |
269 | 262 |
270 void NexeLoadManager::set_manifest_service_channel( | 263 void NexeLoadManager::set_manifest_service_channel( |
271 scoped_ptr<ManifestServiceChannel> channel) { | 264 scoped_ptr<ManifestServiceChannel> channel) { |
272 manifest_service_channel_ = channel.Pass(); | 265 manifest_service_channel_ = channel.Pass(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 SetLastError(message); | 403 SetLastError(message); |
411 LogToConsole(message); | 404 LogToConsole(message); |
412 | 405 |
413 DispatchProgressEvent(pp_instance_, ProgressEvent(PP_NACL_EVENT_CRASH)); | 406 DispatchProgressEvent(pp_instance_, ProgressEvent(PP_NACL_EVENT_CRASH)); |
414 nexe_error_reported_ = true; | 407 nexe_error_reported_ = true; |
415 } | 408 } |
416 // else ReportLoadError() and ReportLoadAbort() will be used by loading code | 409 // else ReportLoadError() and ReportLoadAbort() will be used by loading code |
417 // to provide error handling. | 410 // to provide error handling. |
418 } | 411 } |
419 | 412 |
420 void NexeLoadManager::CopyCrashLogToJsConsole(const std::string& crash_log) { | |
421 base::StringTokenizer t(crash_log, "\n"); | |
422 while (t.GetNext()) | |
423 LogToConsole(t.token()); | |
424 } | |
425 | |
426 } // namespace nacl | 413 } // namespace nacl |
OLD | NEW |