| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/fileapi/file_system_context.h" | 5 #include "webkit/browser/fileapi/file_system_context.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "content/browser/quota/mock_quota_manager.h" | 10 #include "content/browser/quota/mock_quota_manager.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 #if !defined(OS_CHROMEOS) | 107 #if !defined(OS_CHROMEOS) |
| 108 TEST_F(FileSystemContextTest, NullExternalMountPoints) { | 108 TEST_F(FileSystemContextTest, NullExternalMountPoints) { |
| 109 scoped_refptr<FileSystemContext> file_system_context( | 109 scoped_refptr<FileSystemContext> file_system_context( |
| 110 CreateFileSystemContextForTest(NULL)); | 110 CreateFileSystemContextForTest(NULL)); |
| 111 | 111 |
| 112 // Cracking system external mount and isolated mount points should work. | 112 // Cracking system external mount and isolated mount points should work. |
| 113 std::string isolated_name = "root"; | 113 std::string isolated_name = "root"; |
| 114 std::string isolated_id = | 114 std::string isolated_id = |
| 115 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 115 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 116 fileapi::kFileSystemTypeNativeLocal, | 116 fileapi::kFileSystemTypeNativeLocal, |
| 117 std::string(), |
| 117 base::FilePath(DRIVE FPL("/test/isolated/root")), | 118 base::FilePath(DRIVE FPL("/test/isolated/root")), |
| 118 &isolated_name); | 119 &isolated_name); |
| 119 // Register system external mount point. | 120 // Register system external mount point. |
| 120 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 121 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
| 121 "system", | 122 "system", |
| 122 fileapi::kFileSystemTypeNativeLocal, | 123 fileapi::kFileSystemTypeNativeLocal, |
| 123 FileSystemMountOption(), | 124 FileSystemMountOption(), |
| 124 base::FilePath(DRIVE FPL("/test/sys/")))); | 125 base::FilePath(DRIVE FPL("/test/sys/")))); |
| 125 | 126 |
| 126 FileSystemURL cracked_isolated = file_system_context->CrackURL( | 127 FileSystemURL cracked_isolated = file_system_context->CrackURL( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 scoped_refptr<ExternalMountPoints> external_mount_points( | 197 scoped_refptr<ExternalMountPoints> external_mount_points( |
| 197 ExternalMountPoints::CreateRefCounted()); | 198 ExternalMountPoints::CreateRefCounted()); |
| 198 scoped_refptr<FileSystemContext> file_system_context( | 199 scoped_refptr<FileSystemContext> file_system_context( |
| 199 CreateFileSystemContextForTest(external_mount_points.get())); | 200 CreateFileSystemContextForTest(external_mount_points.get())); |
| 200 | 201 |
| 201 // Register an isolated mount point. | 202 // Register an isolated mount point. |
| 202 std::string isolated_file_system_name = "root"; | 203 std::string isolated_file_system_name = "root"; |
| 203 const std::string kIsolatedFileSystemID = | 204 const std::string kIsolatedFileSystemID = |
| 204 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 205 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 205 fileapi::kFileSystemTypeNativeLocal, | 206 fileapi::kFileSystemTypeNativeLocal, |
| 207 std::string(), |
| 206 base::FilePath(DRIVE FPL("/test/isolated/root")), | 208 base::FilePath(DRIVE FPL("/test/isolated/root")), |
| 207 &isolated_file_system_name); | 209 &isolated_file_system_name); |
| 208 // Register system external mount point. | 210 // Register system external mount point. |
| 209 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 211 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
| 210 "system", | 212 "system", |
| 211 fileapi::kFileSystemTypeDrive, | 213 fileapi::kFileSystemTypeDrive, |
| 212 FileSystemMountOption(), | 214 FileSystemMountOption(), |
| 213 base::FilePath(DRIVE FPL("/test/sys/")))); | 215 base::FilePath(DRIVE FPL("/test/sys/")))); |
| 214 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 216 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
| 215 "ext", | 217 "ext", |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 FileSystemURL cracked_url = | 352 FileSystemURL cracked_url = |
| 351 context->CrackURL(CreateRawFileSystemURL("persistent", "pers_mount")); | 353 context->CrackURL(CreateRawFileSystemURL("persistent", "pers_mount")); |
| 352 EXPECT_EQ(fileapi::kFileSystemTypePersistent, cracked_url.mount_type()); | 354 EXPECT_EQ(fileapi::kFileSystemTypePersistent, cracked_url.mount_type()); |
| 353 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); | 355 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); |
| 354 | 356 |
| 355 // A request for an isolated mount point should NOT be served. | 357 // A request for an isolated mount point should NOT be served. |
| 356 std::string isolated_fs_name = "root"; | 358 std::string isolated_fs_name = "root"; |
| 357 std::string isolated_fs_id = | 359 std::string isolated_fs_id = |
| 358 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 360 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 359 fileapi::kFileSystemTypeNativeLocal, | 361 fileapi::kFileSystemTypeNativeLocal, |
| 362 std::string(), |
| 360 base::FilePath(DRIVE FPL("/test/isolated/root")), | 363 base::FilePath(DRIVE FPL("/test/isolated/root")), |
| 361 &isolated_fs_name); | 364 &isolated_fs_name); |
| 362 cracked_url = context->CrackURL( | 365 cracked_url = context->CrackURL( |
| 363 CreateRawFileSystemURL("isolated", isolated_fs_id)); | 366 CreateRawFileSystemURL("isolated", isolated_fs_id)); |
| 364 EXPECT_EQ(fileapi::kFileSystemTypeIsolated, cracked_url.mount_type()); | 367 EXPECT_EQ(fileapi::kFileSystemTypeIsolated, cracked_url.mount_type()); |
| 365 EXPECT_FALSE(context->CanServeURLRequest(cracked_url)); | 368 EXPECT_FALSE(context->CanServeURLRequest(cracked_url)); |
| 366 | 369 |
| 367 // A request for an external mount point should be served. | 370 // A request for an external mount point should be served. |
| 368 const std::string kExternalMountName = "ext_mount"; | 371 const std::string kExternalMountName = "ext_mount"; |
| 369 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 372 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
| 370 kExternalMountName, fileapi::kFileSystemTypeDrive, | 373 kExternalMountName, fileapi::kFileSystemTypeDrive, |
| 371 FileSystemMountOption(), | 374 FileSystemMountOption(), |
| 372 base::FilePath())); | 375 base::FilePath())); |
| 373 cracked_url = context->CrackURL( | 376 cracked_url = context->CrackURL( |
| 374 CreateRawFileSystemURL("external", kExternalMountName)); | 377 CreateRawFileSystemURL("external", kExternalMountName)); |
| 375 EXPECT_EQ(fileapi::kFileSystemTypeExternal, cracked_url.mount_type()); | 378 EXPECT_EQ(fileapi::kFileSystemTypeExternal, cracked_url.mount_type()); |
| 376 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); | 379 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); |
| 377 | 380 |
| 378 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 381 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
| 379 kExternalMountName); | 382 kExternalMountName); |
| 380 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_fs_id); | 383 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_fs_id); |
| 381 } | 384 } |
| 382 | 385 |
| 383 } // namespace | 386 } // namespace |
| 384 | 387 |
| 385 } // namespace content | 388 } // namespace content |
| OLD | NEW |