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-05-06 00:55:35 +0000
committerrvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-06 00:55:35 +0000
commit2741d240bc6e677fd319b5145125a5e5942bbda7 (patch)
treed32c2bd051eb51e42db02b2ea5f49b92c0ecf339 /base/files/file_proxy_unittest.cc
parent8d656092df5d02cb07a357e50ef2748774fa3ac0 (diff)
downloadchromium_src-2741d240bc6e677fd319b5145125a5e5942bbda7.zip
chromium_src-2741d240bc6e677fd319b5145125a5e5942bbda7.tar.gz
chromium_src-2741d240bc6e677fd319b5145125a5e5942bbda7.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 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=263675 Review URL: https://codereview.chromium.org/231703002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268348 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());