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

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

Issue 10815080: Add an interface for nacl to create delete-on-close temp files, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert buildbot hack 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 f094f6590b35116d436f5cd93b1933ebca428136..2aa930a154a30db45a352c5a9d3a79c617ad9e08 100644
--- a/chrome/renderer/pepper/ppb_nacl_private_impl.cc
+++ b/chrome/renderer/pepper/ppb_nacl_private_impl.cc
@@ -6,11 +6,6 @@
#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"
@@ -24,6 +19,7 @@
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "ipc/ipc_sync_message_filter.h"
+#include "ppapi/c/private/pp_file_handle.h"
#include "ppapi/c/private/ppb_nacl_private.h"
#include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h"
#include "ppapi/proxy/host_dispatcher.h"
@@ -265,7 +261,7 @@ int BrokerDuplicateHandle(void* source_handle,
#endif
}
-int GetReadonlyPnaclFD(const char* filename) {
+PP_FileHandle GetReadonlyPnaclFD(const char* filename) {
IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit();
IPC::Sender* sender = content::RenderThread::Get();
if (sender == NULL)
@@ -274,29 +270,36 @@ int GetReadonlyPnaclFD(const char* filename) {
if (!sender->Send(new ChromeViewHostMsg_GetReadonlyPnaclFD(
std::string(filename),
&out_fd))) {
- return -1;
+ return base::kInvalidPlatformFileValue;
}
if (out_fd == IPC::InvalidPlatformFileForTransit()) {
- return -1;
+ return base::kInvalidPlatformFileValue;
}
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 handle;
+}
+
+PP_FileHandle CreateTemporaryFile(PP_Instance instance) {
+ IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit();
+ IPC::Sender* sender = content::RenderThread::Get();
+ if (sender == NULL)
+ sender = g_background_thread_sender.Pointer()->get();
+
+ if (!sender->Send(new ChromeViewHostMsg_NaClCreateTemporaryFile(
+ &transit_fd))) {
+ return base::kInvalidPlatformFileValue;
+ }
+
+ if (transit_fd == IPC::InvalidPlatformFileForTransit()) {
+ return base::kInvalidPlatformFileValue;
}
- return posix_desc;
-#elif defined(OS_POSIX)
+
+ base::PlatformFile handle = IPC::PlatformFileForTransitToPlatformFile(
+ transit_fd);
return handle;
-#else
-#error "GetReadonlyPnaclFD: Don't know how to convert FileDescriptor to native."
-#endif
}
const PPB_NaCl_Private nacl_interface = {
@@ -306,7 +309,8 @@ const PPB_NaCl_Private nacl_interface = {
&Are3DInterfacesDisabled,
&EnableBackgroundSelLdrLaunch,
&BrokerDuplicateHandle,
- &GetReadonlyPnaclFD
+ &GetReadonlyPnaclFD,
+ &CreateTemporaryFile
};
} // 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