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

Unified Diff: chrome/browser/nacl_host/pnacl_file_host.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
Index: chrome/browser/nacl_host/pnacl_file_host.cc
diff --git a/chrome/browser/nacl_host/pnacl_file_host.cc b/chrome/browser/nacl_host/pnacl_file_host.cc
index a5186680453b4ab8a55a8fc249cfe0547f82ea48..fa0e5f0fe4ed086224bc4cfcf48cf69fb8b931f3 100644
--- a/chrome/browser/nacl_host/pnacl_file_host.cc
+++ b/chrome/browser/nacl_host/pnacl_file_host.cc
@@ -76,6 +76,46 @@ void DoOpenPnaclFile(
chrome_render_message_filter->Send(reply_msg);
}
+void DoCreateTemporaryFile(
+ ChromeRenderMessageFilter* chrome_render_message_filter,
+ IPC::Message* reply_msg) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+
+ FilePath file_path;
+ if (!file_util::CreateTemporaryFile(&file_path)) {
+ NotifyRendererOfError(chrome_render_message_filter, reply_msg);
+ return;
+ }
+
+ base::PlatformFileError error;
+ base::PlatformFile file_handle = base::CreatePlatformFile(
+ file_path,
+ base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_READ |
+ base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_TEMPORARY |
+ base::PLATFORM_FILE_DELETE_ON_CLOSE,
+ NULL, &error);
+
+ if (error != base::PLATFORM_FILE_OK) {
+ NotifyRendererOfError(chrome_render_message_filter, reply_msg);
+ return;
+ }
+
+ // Send the reply!
+ // Do any DuplicateHandle magic that is necessary first.
+ IPC::PlatformFileForTransit target_desc =
+ IPC::GetFileHandleForProcess(file_handle,
+ chrome_render_message_filter->peer_handle(),
+ true);
+ if (target_desc == IPC::InvalidPlatformFileForTransit()) {
+ NotifyRendererOfError(chrome_render_message_filter, reply_msg);
+ return;
+ }
+
+ ChromeViewHostMsg_NaClCreateTemporaryFile::WriteReplyParams(
+ reply_msg, target_desc);
+ chrome_render_message_filter->Send(reply_msg);
+}
+
} // namespace
namespace pnacl_file_host {
@@ -135,4 +175,16 @@ bool PnaclCanOpenFile(const std::string& filename,
return true;
}
+void CreateTemporaryFile(
+ ChromeRenderMessageFilter* chrome_render_message_filter,
+ IPC::Message* reply_msg) {
+ if (!BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DoCreateTemporaryFile,
+ make_scoped_refptr(chrome_render_message_filter),
+ reply_msg))) {
+ NotifyRendererOfError(chrome_render_message_filter, reply_msg);
+ }
+}
+
} // namespace pnacl_file_host
« no previous file with comments | « chrome/browser/nacl_host/pnacl_file_host.h ('k') | chrome/browser/renderer_host/chrome_render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698