summaryrefslogtreecommitdiffstats
path: root/base/files/file_proxy_unittest.cc
diff options
context:
space:
mode:
authorrvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 18:32:46 +0000
committerrvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 18:32:46 +0000
commit2b609d7d55a824522fac1f227c60e5acb8bbbfc1 (patch)
tree57d09951a13f0d820ec530d76b231893fb9ee7b7 /base/files/file_proxy_unittest.cc
parent0d66b19518bc93e338165a01dc1c3cd023a42940 (diff)
downloadchromium_src-2b609d7d55a824522fac1f227c60e5acb8bbbfc1.zip
chromium_src-2b609d7d55a824522fac1f227c60e5acb8bbbfc1.tar.gz
chromium_src-2b609d7d55a824522fac1f227c60e5acb8bbbfc1.tar.bz2
Base: Make FileProxy automaticaly close the file on a worker thread.
This CL removes the restriction that callers should call Close before deleting the object if they want to make sure the file is not closed on the current thread. BUG=322664 TEST=base_unittests Review URL: https://codereview.chromium.org/231703002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/files/file_proxy_unittest.cc')
-rw-r--r--base/files/file_proxy_unittest.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/base/files/file_proxy_unittest.cc b/base/files/file_proxy_unittest.cc
index bb7e6c3..7748923 100644
--- a/base/files/file_proxy_unittest.cc
+++ b/base/files/file_proxy_unittest.cc
@@ -14,6 +14,7 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_restrictions.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -143,6 +144,21 @@ TEST_F(FileProxyTest, CreateOrOpen_OpenNonExistent) {
EXPECT_FALSE(PathExists(test_path()));
}
+TEST_F(FileProxyTest, CreateOrOpen_AbandonedCreate) {
+ bool prev = ThreadRestrictions::SetIOAllowed(false);
+ {
+ FileProxy proxy(file_task_runner());
+ proxy.CreateOrOpen(
+ test_path(),
+ File::FLAG_CREATE | File::FLAG_READ,
+ Bind(&FileProxyTest::DidCreateOrOpen, weak_factory_.GetWeakPtr()));
+ }
+ MessageLoop::current()->Run();
+ ThreadRestrictions::SetIOAllowed(prev);
+
+ EXPECT_TRUE(PathExists(test_path()));
+}
+
TEST_F(FileProxyTest, Close) {
// Creates a file.
FileProxy proxy(file_task_runner());