Skip to content

Commit

Permalink
Add SHARED_DELETE flag to FileStream.
Browse files Browse the repository at this point in the history
Allow for all tests to do a guaranteed deletion of their temporary files
(it could fail previously on Windows).

TEST=net_unittests

BUG=


Review URL: https://chromiumcodereview.appspot.com/11440008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171257 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
paivanof@gmail.com committed Dec 5, 2012
1 parent 80e2032 commit a42fdcd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions net/base/file_stream_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ void FileStream::Context::BeginOpenEvent(const FilePath& path) {

FileStream::Context::OpenResult FileStream::Context::OpenFileImpl(
const FilePath& path, int open_flags) {
// FileStream::Context actually closes the file asynchronously, independently
// from FileStream's destructor. It can cause problems for users wanting to
// delete the file right after FileStream deletion. Thus we are always
// adding SHARE_DELETE flag to accommodate such use case.
open_flags |= base::PLATFORM_FILE_SHARE_DELETE;
OpenResult result;
result.error_code = OK;
result.file = base::CreatePlatformFile(path, open_flags, NULL, NULL);
Expand Down
2 changes: 1 addition & 1 deletion net/base/file_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FileStreamTest : public PlatformTest {
file_util::WriteFile(temp_file_path_, kTestData, kTestDataSize);
}
virtual void TearDown() {
file_util::Delete(temp_file_path_, false);
EXPECT_TRUE(file_util::Delete(temp_file_path_, false));

PlatformTest::TearDown();
}
Expand Down

0 comments on commit a42fdcd

Please sign in to comment.