From 7bfab8f349b63ff45d74928bf417e2e5c378e64b Mon Sep 17 00:00:00 2001 From: "kinuko@chromium.org" Date: Thu, 2 Aug 2012 23:13:10 +0000 Subject: Adding RevokeFileSystemByPath so that we can make sure we invalidate all file systems associated to a given path (e.g. for a detached device) BUG=none TEST=IsolatedContextTest.* Review URL: https://chromiumcodereview.appspot.com/10829136 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149732 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/fileapi/isolated_context_unittest.cc | 33 ++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'webkit/fileapi/isolated_context_unittest.cc') diff --git a/webkit/fileapi/isolated_context_unittest.cc b/webkit/fileapi/isolated_context_unittest.cc index c1319919..ac71aec 100644 --- a/webkit/fileapi/isolated_context_unittest.cc +++ b/webkit/fileapi/isolated_context_unittest.cc @@ -58,11 +58,12 @@ class IsolatedContextTest : public testing::Test { names_.push_back(name); } id_ = IsolatedContext::GetInstance()->RegisterDraggedFileSystem(files); + IsolatedContext::GetInstance()->AddReference(id_); ASSERT_FALSE(id_.empty()); } void TearDown() { - IsolatedContext::GetInstance()->RevokeFileSystem(id_); + IsolatedContext::GetInstance()->RemoveReference(id_); } IsolatedContext* isolated_context() const { @@ -109,8 +110,9 @@ TEST_F(IsolatedContextTest, RegisterAndRevokeTest) { FilePath path; ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); - // Revoking the current one and registering a new one. - isolated_context()->RevokeFileSystem(id_); + // Deref the current one and registering a new one. + isolated_context()->RemoveReference(id_); + std::string id2 = isolated_context()->RegisterFileSystemForPath( kFileSystemTypeIsolated, FilePath(DRIVE FPL("/foo")), NULL); @@ -119,10 +121,31 @@ TEST_F(IsolatedContextTest, RegisterAndRevokeTest) { ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id_, &toplevels)); // Make sure the GetRegisteredPath returns true only for the new one. - ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); + ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); + + // Try registering two more file systems for the same path as id2. + std::string id3 = isolated_context()->RegisterFileSystemForPath( + kFileSystemTypeIsolated, path, NULL); + std::string id4 = isolated_context()->RegisterFileSystemForPath( + kFileSystemTypeIsolated, path, NULL); + + // Remove file system for id4. + isolated_context()->AddReference(id4); + isolated_context()->RemoveReference(id4); + + // Only id4 should become invalid now. + ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); + ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path)); + ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path)); + + // Revoke the file systems by path. + isolated_context()->RevokeFileSystemByPath(path); - isolated_context()->RevokeFileSystem(id2); + // Now all the file systems associated to the path must be invalid. + ASSERT_FALSE(isolated_context()->GetRegisteredPath(id2, &path)); + ASSERT_FALSE(isolated_context()->GetRegisteredPath(id3, &path)); + ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path)); } TEST_F(IsolatedContextTest, CrackWithRelativePaths) { -- cgit v1.1