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

Unified Diff: chrome/renderer/pepper/ppb_nacl_private_impl.cc

Issue 10662006: Add a NaCl-Private interface for opening files in DIR_PNACL_COMPONENT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: do not run test when disable_nacl=1 Created 8 years, 5 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 | « chrome/common/render_messages.h ('k') | ppapi/api/private/finish_writing_these/ppb_nacl_private.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/pepper/ppb_nacl_private_impl.cc
diff --git a/chrome/renderer/pepper/ppb_nacl_private_impl.cc b/chrome/renderer/pepper/ppb_nacl_private_impl.cc
index 2e9b494ef03c6edbbc61bfeec26ac330a9079b57..f094f6590b35116d436f5cd93b1933ebca428136 100644
--- a/chrome/renderer/pepper/ppb_nacl_private_impl.cc
+++ b/chrome/renderer/pepper/ppb_nacl_private_impl.cc
@@ -6,6 +6,11 @@
#ifndef DISABLE_NACL
+#if defined(OS_WIN)
+#include <fcntl.h>
+#include <io.h>
+#endif
+
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
@@ -42,6 +47,9 @@ using WebKit::WebView;
namespace {
+// This allows us to send requests from background threads.
+// E.g., to do LaunchSelLdr for helper nexes (which is done synchronously),
+// in a background thread, to avoid jank.
base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> >
g_background_thread_sender = LAZY_INSTANCE_INITIALIZER;
@@ -257,6 +265,40 @@ int BrokerDuplicateHandle(void* source_handle,
#endif
}
+int GetReadonlyPnaclFD(const char* filename) {
+ IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit();
+ IPC::Sender* sender = content::RenderThread::Get();
+ if (sender == NULL)
+ sender = g_background_thread_sender.Pointer()->get();
+
+ if (!sender->Send(new ChromeViewHostMsg_GetReadonlyPnaclFD(
+ std::string(filename),
+ &out_fd))) {
+ return -1;
+ }
+
+ if (out_fd == IPC::InvalidPlatformFileForTransit()) {
+ return -1;
+ }
+
+ base::PlatformFile handle =
+ IPC::PlatformFileForTransitToPlatformFile(out_fd);
+#if defined(OS_WIN)
+ int posix_desc = _open_osfhandle(reinterpret_cast<intptr_t>(handle),
+ _O_RDONLY | _O_BINARY);
+ if (posix_desc == -1) {
+ // Close the Windows HANDLE if it can't be converted.
+ CloseHandle(handle);
+ return -1;
+ }
+ return posix_desc;
+#elif defined(OS_POSIX)
+ return handle;
+#else
+#error "GetReadonlyPnaclFD: Don't know how to convert FileDescriptor to native."
+#endif
+}
+
const PPB_NaCl_Private nacl_interface = {
&LaunchSelLdr,
&StartPpapiProxy,
@@ -264,6 +306,7 @@ const PPB_NaCl_Private nacl_interface = {
&Are3DInterfacesDisabled,
&EnableBackgroundSelLdrLaunch,
&BrokerDuplicateHandle,
+ &GetReadonlyPnaclFD
};
} // namespace
« no previous file with comments | « chrome/common/render_messages.h ('k') | ppapi/api/private/finish_writing_these/ppb_nacl_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698