Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: components/nacl/loader/nonsfi/nonsfi_listener.cc

Issue 1125043002: NaCl: Stop sending resource FDs with NaClProcessMsg_Start (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_listener.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/loader/nonsfi/nonsfi_listener.cc
diff --git a/components/nacl/loader/nonsfi/nonsfi_listener.cc b/components/nacl/loader/nonsfi/nonsfi_listener.cc
index 00dde7a197a19987e58762550d1c6f05a45b7a5e..4d13d4ec231fc8df8d53a6832995776f103dfb7a 100644
--- a/components/nacl/loader/nonsfi/nonsfi_listener.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_listener.cc
@@ -35,7 +35,8 @@ namespace nacl {
namespace nonsfi {
NonSfiListener::NonSfiListener() : io_thread_("NaCl_IOThread"),
- shutdown_event_(true, false) {
+ shutdown_event_(true, false),
+ key_fd_map_(new std::map<std::string, int>) {
io_thread_.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
}
@@ -63,12 +64,27 @@ bool NonSfiListener::Send(IPC::Message* msg) {
bool NonSfiListener::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NonSfiListener, msg)
+ IPC_MESSAGE_HANDLER(NaClProcessMsg_AddPrefetchedResource,
+ OnAddPrefetchedResource)
IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
+void NonSfiListener::OnAddPrefetchedResource(
+ const nacl::NaClResourcePrefetchResult& prefetched_resource_file) {
+ CHECK(prefetched_resource_file.file_path_metadata.empty());
+ bool result = key_fd_map_->insert(std::make_pair(
+ prefetched_resource_file.file_key,
+ IPC::PlatformFileForTransitToPlatformFile(
+ prefetched_resource_file.file))).second;
+ if (!result) {
+ LOG(FATAL) << "Duplicated open_resource key: "
+ << prefetched_resource_file.file_key;
+ }
+}
+
void NonSfiListener::OnStart(const nacl::NaClStartParams& params) {
// Random number source initialization.
#if defined(OS_NACL_NONSFI)
@@ -161,15 +177,7 @@ void NonSfiListener::OnStart(const nacl::NaClStartParams& params) {
CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit());
CHECK(params.nexe_file_path_metadata.empty());
- std::map<std::string, int>* key_fd_map = new std::map<std::string, int>;
- for (size_t i = 0; i < params.prefetched_resource_files.size(); ++i) {
- CHECK(params.prefetched_resource_files[i].file_path_metadata.empty());
- key_fd_map->insert(std::make_pair(
- params.prefetched_resource_files[i].file_key,
- IPC::PlatformFileForTransitToPlatformFile(
- params.prefetched_resource_files[i].file)));
- }
- ppapi::RegisterPreopenedDescriptorsNonSfi(key_fd_map);
+ ppapi::RegisterPreopenedDescriptorsNonSfi(key_fd_map_.release());
MainStart(IPC::PlatformFileForTransitToPlatformFile(params.nexe_file));
}
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_listener.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698