diff options
author | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-30 17:13:01 +0000 |
---|---|---|
committer | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-30 17:13:01 +0000 |
commit | 9a80715bd54cf030c89a9b0941551fe8bc028df9 (patch) | |
tree | 87289c9f90fcce68a8b6210255c4f3c6a927d727 /chrome/renderer | |
parent | b1186477901883f22ae9e3d0c0266557735a062e (diff) | |
download | chromium_src-9a80715bd54cf030c89a9b0941551fe8bc028df9.zip chromium_src-9a80715bd54cf030c89a9b0941551fe8bc028df9.tar.gz chromium_src-9a80715bd54cf030c89a9b0941551fe8bc028df9.tar.bz2 |
Add an interface for nacl to create delete-on-close temp files,
to be used by pnacl for scratch files during compilation and linking.
This is in-lieu of the current use of pepper temp files, which are not
allowed in incognito mode, and are more cumbersome to clean up on surfaway.
Use this interface for the .o file in pnacl coordinator. The .nexe still uses
pepper temp files, since we haven't moved that over for caching yet.
We will clean that up later.
Also do some crude quota enforcement for these files, using the
existing reverse service interface.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2683
TEST= none -- pnacl compilation still works
Review URL: https://chromiumcodereview.appspot.com/10815080
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/pepper/ppb_nacl_private_impl.cc | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/chrome/renderer/pepper/ppb_nacl_private_impl.cc b/chrome/renderer/pepper/ppb_nacl_private_impl.cc index f094f65..2aa930a 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 |