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

Unified Diff: ppapi/nacl_irt/manifest_service.cc

Issue 649603004: Non-SFI NaCl: Batch-open resource files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 10 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 | « ppapi/nacl_irt/irt_manifest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/nacl_irt/manifest_service.cc
diff --git a/ppapi/nacl_irt/manifest_service.cc b/ppapi/nacl_irt/manifest_service.cc
index 8e671b90ceac9f24df864d175a373eb38c643968..3c537b3924475ddf6470633ab720ef1387d91d0d 100644
--- a/ppapi/nacl_irt/manifest_service.cc
+++ b/ppapi/nacl_irt/manifest_service.cc
@@ -13,6 +13,12 @@
#include "ppapi/nacl_irt/plugin_startup.h"
#include "ppapi/proxy/ppapi_messages.h"
+#if !defined(OS_NACL_SFI)
+#include <pthread.h>
+#include <map>
+#include <string>
+#endif
+
namespace ppapi {
const char kFilePrefix[] = "files/";
@@ -120,11 +126,43 @@ bool ManifestService::OpenResource(const char* file, int* fd) {
return true;
}
+#if !defined(OS_NACL_SFI)
+namespace {
+
+pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER;
+std::map<std::string, int>* g_prefetched_fds;
+
+} // namespace
+
+void RegisterPreopenedDescriptorsNonSfi(
+ std::map<std::string, int>* key_fd_map) {
+ pthread_mutex_lock(&g_mu);
+ DCHECK(!g_prefetched_fds);
+ g_prefetched_fds = key_fd_map;
+ pthread_mutex_unlock(&g_mu);
+}
+#endif
+
int IrtOpenResource(const char* file, int* fd) {
// Remove leading '/' character.
if (file[0] == '/')
++file;
+#if !defined(OS_NACL_SFI)
+ // Fast path for prefetched FDs.
+ pthread_mutex_lock(&g_mu);
+ if (g_prefetched_fds) {
+ std::map<std::string, int>::iterator it = g_prefetched_fds->find(file);
+ if (it != g_prefetched_fds->end()) {
+ *fd = it->second;
+ g_prefetched_fds->erase(it);
+ pthread_mutex_unlock(&g_mu);
+ return 0;
+ }
+ }
+ pthread_mutex_unlock(&g_mu);
+#endif
+
ManifestService* manifest_service = GetManifestService();
if (manifest_service == NULL ||
!manifest_service->OpenResource(file, fd)) {
« no previous file with comments | « ppapi/nacl_irt/irt_manifest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698