From 9e51af9018550b6b23802f66469310f5d1790ab9 Mon Sep 17 00:00:00 2001 From: "jrg@chromium.org" Date: Wed, 4 Feb 2009 00:58:39 +0000 Subject: Properly honor base::SharedMemory semantics for name="" to mean new/private shared memory on POSIX. Transition base::SharedMemory implementation to file/mmap() to prevent leaking of wired kernel resources and allow easier cleanup. Enable one more shared_memory unit test for POSIX. Enable stats_table_unittest.cc for Mac, and modify it so it cleans up. Review URL: http://codereview.chromium.org/19724 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9114 0039d316-1c4b-4281-b951-d872f2087c98 --- base/file_util_win.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'base/file_util_win.cc') diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 0947827..22c24cd 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -395,6 +395,10 @@ bool GetTempDir(FilePath* path) { return true; } +bool GetShmemTempDir(FilePath* path) { + return GetTempDir(path); +} + bool CreateTemporaryFileName(FilePath* path) { std::wstring temp_path, temp_file; @@ -409,6 +413,22 @@ bool CreateTemporaryFileName(FilePath* path) { return false; } +// On POSIX we have semantics to create and open a temporary file +// atomically. +// TODO(jrg): is there equivalent call to use on Windows instead of +// going 2-step? +FILE* CreateAndOpenTemporaryFile(FilePath* path) { + + if (!CreateTemporaryFileName(path)) { + return NULL; + } + return OpenFile(*path, "w+"); +} + +FILE* CreateAndOpenTemporaryShmemFile(FilePath* path) { + return CreateAndOpenTemporaryFile(path); +} + bool CreateTemporaryFileNameInDir(const std::wstring& dir, std::wstring* temp_file) { wchar_t temp_name[MAX_PATH + 1]; -- cgit v1.1