diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-02 23:13:10 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-02 23:13:10 +0000 |
commit | 7bfab8f349b63ff45d74928bf417e2e5c378e64b (patch) | |
tree | 86f9b9b4fdaeba9c73856f9ef3c5e2aa966a5ca8 /webkit/fileapi/isolated_context_unittest.cc | |
parent | 0ab5f76e05a56c59ad3c3049f2fc3323379706be (diff) | |
download | chromium_src-7bfab8f349b63ff45d74928bf417e2e5c378e64b.zip chromium_src-7bfab8f349b63ff45d74928bf417e2e5c378e64b.tar.gz chromium_src-7bfab8f349b63ff45d74928bf417e2e5c378e64b.tar.bz2 |
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
Diffstat (limited to 'webkit/fileapi/isolated_context_unittest.cc')
-rw-r--r-- | webkit/fileapi/isolated_context_unittest.cc | 33 |
1 files changed, 28 insertions, 5 deletions
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) { |