OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/fileapi/isolated_context.h" | 5 #include "webkit/fileapi/isolated_context.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Make sure GetRegisteredPath returns false for id_ since it is | 108 // Make sure GetRegisteredPath returns false for id_ since it is |
109 // registered for dragged files. | 109 // registered for dragged files. |
110 FilePath path; | 110 FilePath path; |
111 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); | 111 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); |
112 | 112 |
113 // Deref the current one and registering a new one. | 113 // Deref the current one and registering a new one. |
114 isolated_context()->RemoveReference(id_); | 114 isolated_context()->RemoveReference(id_); |
115 | 115 |
116 std::string id2 = isolated_context()->RegisterFileSystemForPath( | 116 std::string id2 = isolated_context()->RegisterFileSystemForPath( |
117 kFileSystemTypeIsolated, FilePath(DRIVE FPL("/foo")), NULL); | 117 kFileSystemTypeNativeLocal, FilePath(DRIVE FPL("/foo")), NULL); |
118 | 118 |
119 // Make sure the GetDraggedFileInfo returns false for both ones. | 119 // Make sure the GetDraggedFileInfo returns false for both ones. |
120 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id2, &toplevels)); | 120 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id2, &toplevels)); |
121 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id_, &toplevels)); | 121 ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id_, &toplevels)); |
122 | 122 |
123 // Make sure the GetRegisteredPath returns true only for the new one. | 123 // Make sure the GetRegisteredPath returns true only for the new one. |
124 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); | 124 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); |
125 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); | 125 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); |
126 | 126 |
127 // Try registering three more file systems for the same path as id2. | 127 // Try registering three more file systems for the same path as id2. |
128 std::string id3 = isolated_context()->RegisterFileSystemForPath( | 128 std::string id3 = isolated_context()->RegisterFileSystemForPath( |
129 kFileSystemTypeIsolated, path, NULL); | 129 kFileSystemTypeNativeLocal, path, NULL); |
130 std::string id4 = isolated_context()->RegisterFileSystemForPath( | 130 std::string id4 = isolated_context()->RegisterFileSystemForPath( |
131 kFileSystemTypeIsolated, path, NULL); | 131 kFileSystemTypeNativeLocal, path, NULL); |
132 std::string id5 = isolated_context()->RegisterFileSystemForPath( | 132 std::string id5 = isolated_context()->RegisterFileSystemForPath( |
133 kFileSystemTypeIsolated, path, NULL); | 133 kFileSystemTypeNativeLocal, path, NULL); |
134 | 134 |
135 // Remove file system for id4. | 135 // Remove file system for id4. |
136 isolated_context()->AddReference(id4); | 136 isolated_context()->AddReference(id4); |
137 isolated_context()->RemoveReference(id4); | 137 isolated_context()->RemoveReference(id4); |
138 | 138 |
139 // Only id4 should become invalid now. | 139 // Only id4 should become invalid now. |
140 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); | 140 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path)); |
141 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path)); | 141 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path)); |
142 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path)); | 142 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path)); |
143 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id5, &path)); | 143 ASSERT_TRUE(isolated_context()->GetRegisteredPath(id5, &path)); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 // Trying to crack "/foo" should fail (because "foo" is not the one | 224 // Trying to crack "/foo" should fail (because "foo" is not the one |
225 // included in the kTestPaths). | 225 // included in the kTestPaths). |
226 virtual_path = isolated_context()->CreateVirtualRootPath( | 226 virtual_path = isolated_context()->CreateVirtualRootPath( |
227 id_).AppendASCII("foo"); | 227 id_).AppendASCII("foo"); |
228 ASSERT_FALSE(isolated_context()->CrackIsolatedPath( | 228 ASSERT_FALSE(isolated_context()->CrackIsolatedPath( |
229 virtual_path, &cracked_id, NULL, &cracked_path)); | 229 virtual_path, &cracked_id, NULL, &cracked_path)); |
230 } | 230 } |
231 | 231 |
232 } // namespace fileapi | 232 } // namespace fileapi |
OLD | NEW |