Index: components/nacl/renderer/nexe_load_manager.cc |
diff --git a/components/nacl/renderer/nexe_load_manager.cc b/components/nacl/renderer/nexe_load_manager.cc |
index ebfc0cde0bbe455def5106978f04a1b269c10ad9..c994d02399b0ce72cf6f8973c288e3d09d60516f 100644 |
--- a/components/nacl/renderer/nexe_load_manager.cc |
+++ b/components/nacl/renderer/nexe_load_manager.cc |
@@ -12,7 +12,6 @@ |
#include "base/metrics/histogram.h" |
#include "base/strings/string_tokenizer.h" |
#include "base/strings/string_util.h" |
-#include "components/nacl/common/nacl_host_messages.h" |
#include "components/nacl/common/nacl_types.h" |
#include "components/nacl/renderer/histogram.h" |
#include "components/nacl/renderer/manifest_service_channel.h" |
@@ -82,8 +81,7 @@ std::string LookupAttribute(const std::map<std::string, std::string>& args, |
} // namespace |
-NexeLoadManager::NexeLoadManager( |
- PP_Instance pp_instance) |
+NexeLoadManager::NexeLoadManager(PP_Instance pp_instance, mojom::NaClHost* host) |
: pp_instance_(pp_instance), |
nacl_ready_state_(PP_NACL_READY_STATE_UNSENT), |
nexe_error_reported_(false), |
@@ -92,7 +90,7 @@ NexeLoadManager::NexeLoadManager( |
nexe_size_(0), |
plugin_instance_(content::PepperPluginInstance::Get(pp_instance)), |
nonsfi_(false), |
- crash_info_shmem_handle_(base::SharedMemory::NULLHandle()), |
+ host_(host), |
weak_factory_(this) { |
set_exit_status(-1); |
SetLastError(""); |
@@ -108,8 +106,6 @@ NexeLoadManager::~NexeLoadManager() { |
base::TimeDelta uptime = base::Time::Now() - ready_time_; |
HistogramTimeLarge("NaCl.ModuleUptime.Normal", uptime.InMilliseconds()); |
} |
- if (base::SharedMemory::IsHandleValid(crash_info_shmem_handle_)) |
- base::SharedMemory::CloseHandle(crash_info_shmem_handle_); |
} |
void NexeLoadManager::NexeFileDidOpen(int32_t pp_error, |
@@ -197,9 +193,7 @@ void NexeLoadManager::ReportLoadError(PP_NaClError error, |
if (error == PP_NACL_ERROR_MANIFEST_PROGRAM_MISSING_ARCH) { |
// A special case: the manifest may otherwise be valid but is missing |
// a program/file compatible with the user's sandbox. |
- IPC::Sender* sender = content::RenderThread::Get(); |
- sender->Send( |
- new NaClHostMsg_MissingArchError(GetRoutingID(pp_instance_))); |
+ host_->MissingArchError(GetRoutingID(pp_instance_)); |
} |
set_nacl_ready_state(PP_NACL_READY_STATE_DONE); |
nexe_error_reported_ = true; |
@@ -267,18 +261,19 @@ void NexeLoadManager::NexeDidCrash() { |
// invocation will just be a no-op, since the entire crash log will |
// have been received and we'll just get an EOF indication. |
- base::SharedMemory shmem(crash_info_shmem_handle_, true); |
- if (shmem.Map(kNaClCrashInfoShmemSize)) { |
+ mojo::ScopedSharedBufferMapping mapping = |
+ crash_info_shmem_handle_->Map(kNaClCrashInfoShmemSize); |
+ if (mapping) { |
uint32_t crash_log_length; |
// We cast the length value to volatile here to prevent the compiler from |
// reordering instructions in a way that could introduce a TOCTTOU race. |
- crash_log_length = *(static_cast<volatile uint32_t*>(shmem.memory())); |
+ crash_log_length = *(static_cast<volatile uint32_t*>(mapping.get())); |
crash_log_length = std::min<uint32_t>(crash_log_length, |
kNaClCrashInfoMaxLogSize); |
std::unique_ptr<char[]> crash_log_data(new char[kNaClCrashInfoShmemSize]); |
memcpy(crash_log_data.get(), |
- static_cast<char*>(shmem.memory()) + sizeof(uint32_t), |
+ static_cast<char*>(mapping.get()) + sizeof(uint32_t), |
crash_log_length); |
std::string crash_log(crash_log_data.get(), crash_log_length); |
CopyCrashLogToJsConsole(crash_log); |