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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "webkit/browser/fileapi/sandbox_directory_database.h" | 27 #include "webkit/browser/fileapi/sandbox_directory_database.h" |
28 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" | 28 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" |
29 #include "webkit/browser/fileapi/sandbox_isolated_origin_database.h" | 29 #include "webkit/browser/fileapi/sandbox_isolated_origin_database.h" |
30 #include "webkit/browser/fileapi/sandbox_origin_database.h" | 30 #include "webkit/browser/fileapi/sandbox_origin_database.h" |
31 #include "webkit/browser/fileapi/test_file_set.h" | 31 #include "webkit/browser/fileapi/test_file_set.h" |
32 #include "webkit/browser/quota/mock_special_storage_policy.h" | 32 #include "webkit/browser/quota/mock_special_storage_policy.h" |
33 #include "webkit/browser/quota/quota_manager.h" | 33 #include "webkit/browser/quota/quota_manager.h" |
34 #include "webkit/common/database/database_identifier.h" | 34 #include "webkit/common/database/database_identifier.h" |
35 #include "webkit/common/quota/quota_types.h" | 35 #include "webkit/common/quota/quota_types.h" |
36 | 36 |
37 namespace fileapi { | 37 using fileapi::AsyncFileTestHelper; |
| 38 using fileapi::FileSystemContext; |
| 39 using fileapi::FileSystemOperation; |
| 40 using fileapi::FileSystemOperationContext; |
| 41 using fileapi::FileSystemType; |
| 42 using fileapi::FileSystemURL; |
| 43 using fileapi::ObfuscatedFileUtil; |
| 44 using fileapi::SandboxDirectoryDatabase; |
| 45 using fileapi::SandboxIsolatedOriginDatabase; |
| 46 using fileapi::kFileSystemTypeTemporary; |
| 47 using fileapi::kFileSystemTypePersistent; |
| 48 |
| 49 namespace content { |
38 | 50 |
39 namespace { | 51 namespace { |
40 | 52 |
41 bool FileExists(const base::FilePath& path) { | 53 bool FileExists(const base::FilePath& path) { |
42 return base::PathExists(path) && !base::DirectoryExists(path); | 54 return base::PathExists(path) && !base::DirectoryExists(path); |
43 } | 55 } |
44 | 56 |
45 int64 GetSize(const base::FilePath& path) { | 57 int64 GetSize(const base::FilePath& path) { |
46 int64 size; | 58 int64 size; |
47 EXPECT_TRUE(base::GetFileSize(path, &size)); | 59 EXPECT_TRUE(base::GetFileSize(path, &size)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 FileSystemURL FileSystemURLAppendUTF8( | 115 FileSystemURL FileSystemURLAppendUTF8( |
104 const FileSystemURL& url, const std::string& child) { | 116 const FileSystemURL& url, const std::string& child) { |
105 return FileSystemURL::CreateForTest( | 117 return FileSystemURL::CreateForTest( |
106 url.origin(), | 118 url.origin(), |
107 url.mount_type(), | 119 url.mount_type(), |
108 url.virtual_path().Append(base::FilePath::FromUTF8Unsafe(child))); | 120 url.virtual_path().Append(base::FilePath::FromUTF8Unsafe(child))); |
109 } | 121 } |
110 | 122 |
111 FileSystemURL FileSystemURLDirName(const FileSystemURL& url) { | 123 FileSystemURL FileSystemURLDirName(const FileSystemURL& url) { |
112 return FileSystemURL::CreateForTest( | 124 return FileSystemURL::CreateForTest( |
113 url.origin(), url.mount_type(), VirtualPath::DirName(url.virtual_path())); | 125 url.origin(), url.mount_type(), |
| 126 fileapi::VirtualPath::DirName(url.virtual_path())); |
114 } | 127 } |
115 | 128 |
116 std::string GetTypeString(FileSystemType type) { | 129 std::string GetTypeString(FileSystemType type) { |
117 return SandboxFileSystemBackendDelegate::GetTypeString(type); | 130 return fileapi::SandboxFileSystemBackendDelegate::GetTypeString(type); |
118 } | 131 } |
119 | 132 |
120 bool HasFileSystemType( | 133 bool HasFileSystemType( |
121 ObfuscatedFileUtil::AbstractOriginEnumerator* enumerator, | 134 ObfuscatedFileUtil::AbstractOriginEnumerator* enumerator, |
122 FileSystemType type) { | 135 FileSystemType type) { |
123 return enumerator->HasTypeDirectory(GetTypeString(type)); | 136 return enumerator->HasTypeDirectory(GetTypeString(type)); |
124 } | 137 } |
125 | 138 |
126 } // namespace | 139 } // namespace |
127 | 140 |
128 // TODO(ericu): The vast majority of this and the other FSFU subclass tests | 141 // TODO(ericu): The vast majority of this and the other FSFU subclass tests |
129 // could theoretically be shared. It would basically be a FSFU interface | 142 // could theoretically be shared. It would basically be a FSFU interface |
130 // compliance test, and only the subclass-specific bits that look into the | 143 // compliance test, and only the subclass-specific bits that look into the |
131 // implementation would need to be written per-subclass. | 144 // implementation would need to be written per-subclass. |
132 class ObfuscatedFileUtilTest : public testing::Test { | 145 class ObfuscatedFileUtilTest : public testing::Test { |
133 public: | 146 public: |
134 ObfuscatedFileUtilTest() | 147 ObfuscatedFileUtilTest() |
135 : origin_(GURL("http://www.example.com")), | 148 : origin_(GURL("http://www.example.com")), |
136 type_(kFileSystemTypeTemporary), | 149 type_(fileapi::kFileSystemTypeTemporary), |
137 weak_factory_(this), | 150 weak_factory_(this), |
138 sandbox_file_system_(origin_, type_), | 151 sandbox_file_system_(origin_, type_), |
139 quota_status_(quota::kQuotaStatusUnknown), | 152 quota_status_(quota::kQuotaStatusUnknown), |
140 usage_(-1) { | 153 usage_(-1) { |
141 } | 154 } |
142 | 155 |
143 virtual void SetUp() { | 156 virtual void SetUp() { |
144 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 157 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
145 | 158 |
146 storage_policy_ = new quota::MockSpecialStoragePolicy(); | 159 storage_policy_ = new quota::MockSpecialStoragePolicy(); |
147 | 160 |
148 quota_manager_ = | 161 quota_manager_ = |
149 new quota::QuotaManager(false /* is_incognito */, | 162 new quota::QuotaManager(false /* is_incognito */, |
150 data_dir_.path(), | 163 data_dir_.path(), |
151 base::MessageLoopProxy::current().get(), | 164 base::MessageLoopProxy::current().get(), |
152 base::MessageLoopProxy::current().get(), | 165 base::MessageLoopProxy::current().get(), |
153 storage_policy_.get()); | 166 storage_policy_.get()); |
154 | 167 |
155 // Every time we create a new sandbox_file_system helper, | 168 // Every time we create a new sandbox_file_system helper, |
156 // it creates another context, which creates another path manager, | 169 // it creates another context, which creates another path manager, |
157 // another sandbox_backend, and another OFU. | 170 // another sandbox_backend, and another OFU. |
158 // We need to pass in the context to skip all that. | 171 // We need to pass in the context to skip all that. |
159 file_system_context_ = CreateFileSystemContextForTesting( | 172 file_system_context_ = CreateFileSystemContextForTesting( |
160 quota_manager_->proxy(), | 173 quota_manager_->proxy(), |
161 data_dir_.path()); | 174 data_dir_.path()); |
162 | 175 |
163 sandbox_file_system_.SetUp(file_system_context_.get()); | 176 sandbox_file_system_.SetUp(file_system_context_.get()); |
164 | 177 |
165 change_observers_ = MockFileChangeObserver::CreateList(&change_observer_); | 178 change_observers_ = fileapi::MockFileChangeObserver::CreateList( |
| 179 &change_observer_); |
166 } | 180 } |
167 | 181 |
168 virtual void TearDown() { | 182 virtual void TearDown() { |
169 quota_manager_ = NULL; | 183 quota_manager_ = NULL; |
170 sandbox_file_system_.TearDown(); | 184 sandbox_file_system_.TearDown(); |
171 } | 185 } |
172 | 186 |
173 scoped_ptr<FileSystemOperationContext> LimitedContext( | 187 scoped_ptr<FileSystemOperationContext> LimitedContext( |
174 int64 allowed_bytes_growth) { | 188 int64 allowed_bytes_growth) { |
175 scoped_ptr<FileSystemOperationContext> context( | 189 scoped_ptr<FileSystemOperationContext> context( |
(...skipping 13 matching lines...) Expand all Loading... |
189 if (file_system) | 203 if (file_system) |
190 context = file_system->NewOperationContext(); | 204 context = file_system->NewOperationContext(); |
191 else | 205 else |
192 context = sandbox_file_system_.NewOperationContext(); | 206 context = sandbox_file_system_.NewOperationContext(); |
193 // Setting allowed_bytes_growth big enough for all tests. | 207 // Setting allowed_bytes_growth big enough for all tests. |
194 context->set_allowed_bytes_growth(1024 * 1024); | 208 context->set_allowed_bytes_growth(1024 * 1024); |
195 context->set_change_observers(change_observers()); | 209 context->set_change_observers(change_observers()); |
196 return context; | 210 return context; |
197 } | 211 } |
198 | 212 |
199 const ChangeObserverList& change_observers() const { | 213 const fileapi::ChangeObserverList& change_observers() const { |
200 return change_observers_; | 214 return change_observers_; |
201 } | 215 } |
202 | 216 |
203 MockFileChangeObserver* change_observer() { | 217 fileapi::MockFileChangeObserver* change_observer() { |
204 return &change_observer_; | 218 return &change_observer_; |
205 } | 219 } |
206 | 220 |
207 // This can only be used after SetUp has run and created file_system_context_ | 221 // This can only be used after SetUp has run and created file_system_context_ |
208 // and obfuscated_file_util_. | 222 // and obfuscated_file_util_. |
209 // Use this for tests which need to run in multiple origins; we need a test | 223 // Use this for tests which need to run in multiple origins; we need a test |
210 // helper per origin. | 224 // helper per origin. |
211 SandboxFileSystemTestHelper* NewFileSystem( | 225 SandboxFileSystemTestHelper* NewFileSystem( |
212 const GURL& origin, fileapi::FileSystemType type) { | 226 const GURL& origin, fileapi::FileSystemType type) { |
213 SandboxFileSystemTestHelper* file_system = | 227 SandboxFileSystemTestHelper* file_system = |
214 new SandboxFileSystemTestHelper(origin, type); | 228 new SandboxFileSystemTestHelper(origin, type); |
215 | 229 |
216 file_system->SetUp(file_system_context_.get()); | 230 file_system->SetUp(file_system_context_.get()); |
217 return file_system; | 231 return file_system; |
218 } | 232 } |
219 | 233 |
| 234 scoped_ptr<ObfuscatedFileUtil> CreateObfuscatedFileUtil( |
| 235 quota::SpecialStoragePolicy* storage_policy) { |
| 236 return scoped_ptr<ObfuscatedFileUtil>( |
| 237 ObfuscatedFileUtil::CreateForTesting( |
| 238 storage_policy, data_dir_path(), |
| 239 base::MessageLoopProxy::current().get())); |
| 240 } |
| 241 |
220 ObfuscatedFileUtil* ofu() { | 242 ObfuscatedFileUtil* ofu() { |
221 return static_cast<ObfuscatedFileUtil*>(sandbox_file_system_.file_util()); | 243 return static_cast<ObfuscatedFileUtil*>(sandbox_file_system_.file_util()); |
222 } | 244 } |
223 | 245 |
224 const base::FilePath& test_directory() const { | 246 const base::FilePath& test_directory() const { |
225 return data_dir_.path(); | 247 return data_dir_.path(); |
226 } | 248 } |
227 | 249 |
228 const GURL& origin() const { | 250 const GURL& origin() const { |
229 return origin_; | 251 return origin_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 base::PlatformFileError error = ofu()->GetFileInfo( | 298 base::PlatformFileError error = ofu()->GetFileInfo( |
277 context.get(), url, &file_info, &platform_path); | 299 context.get(), url, &file_info, &platform_path); |
278 return error == base::PLATFORM_FILE_OK; | 300 return error == base::PLATFORM_FILE_OK; |
279 } | 301 } |
280 | 302 |
281 bool DirectoryExists(const FileSystemURL& url) { | 303 bool DirectoryExists(const FileSystemURL& url) { |
282 return AsyncFileTestHelper::DirectoryExists(file_system_context(), url); | 304 return AsyncFileTestHelper::DirectoryExists(file_system_context(), url); |
283 } | 305 } |
284 | 306 |
285 int64 usage() const { return usage_; } | 307 int64 usage() const { return usage_; } |
286 FileSystemUsageCache* usage_cache() { | 308 fileapi::FileSystemUsageCache* usage_cache() { |
287 return sandbox_file_system_.usage_cache(); | 309 return sandbox_file_system_.usage_cache(); |
288 } | 310 } |
289 | 311 |
290 FileSystemURL CreateURLFromUTF8(const std::string& path) { | 312 FileSystemURL CreateURLFromUTF8(const std::string& path) { |
291 return sandbox_file_system_.CreateURLFromUTF8(path); | 313 return sandbox_file_system_.CreateURLFromUTF8(path); |
292 } | 314 } |
293 | 315 |
294 int64 PathCost(const FileSystemURL& url) { | 316 int64 PathCost(const FileSystemURL& url) { |
295 return ObfuscatedFileUtil::ComputeFilePathCost(url.path()); | 317 return ObfuscatedFileUtil::ComputeFilePathCost(url.path()); |
296 } | 318 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 int64 usage = sandbox_file_system_.GetCachedOriginUsage(); | 442 int64 usage = sandbox_file_system_.GetCachedOriginUsage(); |
421 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper( | 443 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper( |
422 LimitedContext(requested_growth - 1), &sandbox_file_system_, usage)); | 444 LimitedContext(requested_growth - 1), &sandbox_file_system_, usage)); |
423 } | 445 } |
424 | 446 |
425 void FillTestDirectory( | 447 void FillTestDirectory( |
426 const FileSystemURL& root_url, | 448 const FileSystemURL& root_url, |
427 std::set<base::FilePath::StringType>* files, | 449 std::set<base::FilePath::StringType>* files, |
428 std::set<base::FilePath::StringType>* directories) { | 450 std::set<base::FilePath::StringType>* directories) { |
429 scoped_ptr<FileSystemOperationContext> context; | 451 scoped_ptr<FileSystemOperationContext> context; |
430 std::vector<DirectoryEntry> entries; | 452 std::vector<fileapi::DirectoryEntry> entries; |
431 EXPECT_EQ(base::PLATFORM_FILE_OK, | 453 EXPECT_EQ(base::PLATFORM_FILE_OK, |
432 AsyncFileTestHelper::ReadDirectory( | 454 AsyncFileTestHelper::ReadDirectory( |
433 file_system_context(), root_url, &entries)); | 455 file_system_context(), root_url, &entries)); |
434 EXPECT_EQ(0UL, entries.size()); | 456 EXPECT_EQ(0UL, entries.size()); |
435 | 457 |
436 files->clear(); | 458 files->clear(); |
437 files->insert(FILE_PATH_LITERAL("first")); | 459 files->insert(FILE_PATH_LITERAL("first")); |
438 files->insert(FILE_PATH_LITERAL("second")); | 460 files->insert(FILE_PATH_LITERAL("second")); |
439 files->insert(FILE_PATH_LITERAL("third")); | 461 files->insert(FILE_PATH_LITERAL("third")); |
440 directories->clear(); | 462 directories->clear(); |
(...skipping 23 matching lines...) Expand all Loading... |
464 } | 486 } |
465 ValidateTestDirectory(root_url, *files, *directories); | 487 ValidateTestDirectory(root_url, *files, *directories); |
466 } | 488 } |
467 | 489 |
468 void TestReadDirectoryHelper(const FileSystemURL& root_url) { | 490 void TestReadDirectoryHelper(const FileSystemURL& root_url) { |
469 std::set<base::FilePath::StringType> files; | 491 std::set<base::FilePath::StringType> files; |
470 std::set<base::FilePath::StringType> directories; | 492 std::set<base::FilePath::StringType> directories; |
471 FillTestDirectory(root_url, &files, &directories); | 493 FillTestDirectory(root_url, &files, &directories); |
472 | 494 |
473 scoped_ptr<FileSystemOperationContext> context; | 495 scoped_ptr<FileSystemOperationContext> context; |
474 std::vector<DirectoryEntry> entries; | 496 std::vector<fileapi::DirectoryEntry> entries; |
475 context.reset(NewContext(NULL)); | 497 context.reset(NewContext(NULL)); |
476 EXPECT_EQ(base::PLATFORM_FILE_OK, | 498 EXPECT_EQ(base::PLATFORM_FILE_OK, |
477 AsyncFileTestHelper::ReadDirectory( | 499 AsyncFileTestHelper::ReadDirectory( |
478 file_system_context(), root_url, &entries)); | 500 file_system_context(), root_url, &entries)); |
479 std::vector<DirectoryEntry>::iterator entry_iter; | 501 std::vector<fileapi::DirectoryEntry>::iterator entry_iter; |
480 EXPECT_EQ(files.size() + directories.size(), entries.size()); | 502 EXPECT_EQ(files.size() + directories.size(), entries.size()); |
481 EXPECT_TRUE(change_observer()->HasNoChange()); | 503 EXPECT_TRUE(change_observer()->HasNoChange()); |
482 for (entry_iter = entries.begin(); entry_iter != entries.end(); | 504 for (entry_iter = entries.begin(); entry_iter != entries.end(); |
483 ++entry_iter) { | 505 ++entry_iter) { |
484 const DirectoryEntry& entry = *entry_iter; | 506 const fileapi::DirectoryEntry& entry = *entry_iter; |
485 std::set<base::FilePath::StringType>::iterator iter = | 507 std::set<base::FilePath::StringType>::iterator iter = |
486 files.find(entry.name); | 508 files.find(entry.name); |
487 if (iter != files.end()) { | 509 if (iter != files.end()) { |
488 EXPECT_FALSE(entry.is_directory); | 510 EXPECT_FALSE(entry.is_directory); |
489 files.erase(iter); | 511 files.erase(iter); |
490 continue; | 512 continue; |
491 } | 513 } |
492 iter = directories.find(entry.name); | 514 iter = directories.find(entry.name); |
493 EXPECT_FALSE(directories.end() == iter); | 515 EXPECT_FALSE(directories.end() == iter); |
494 EXPECT_TRUE(entry.is_directory); | 516 EXPECT_TRUE(entry.is_directory); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 src_file_url, dest_file_url, | 677 src_file_url, dest_file_url, |
656 FileSystemOperation::OPTION_NONE, | 678 FileSystemOperation::OPTION_NONE, |
657 copy)); | 679 copy)); |
658 if (copy) | 680 if (copy) |
659 EXPECT_EQ(base::Time(), GetModifiedTime(src_dir_url)); | 681 EXPECT_EQ(base::Time(), GetModifiedTime(src_dir_url)); |
660 else | 682 else |
661 EXPECT_NE(base::Time(), GetModifiedTime(src_dir_url)); | 683 EXPECT_NE(base::Time(), GetModifiedTime(src_dir_url)); |
662 EXPECT_NE(base::Time(), GetModifiedTime(dest_dir_url)); | 684 EXPECT_NE(base::Time(), GetModifiedTime(dest_dir_url)); |
663 } | 685 } |
664 | 686 |
| 687 void MaybeDropDatabasesAliveCaseTestBody() { |
| 688 scoped_ptr<ObfuscatedFileUtil> file_util = CreateObfuscatedFileUtil(NULL); |
| 689 file_util->InitOriginDatabase(GURL(), true /*create*/); |
| 690 ASSERT_TRUE(file_util->origin_database_ != NULL); |
| 691 |
| 692 // Callback to Drop DB is called while ObfuscatedFileUtilTest is |
| 693 // still alive. |
| 694 file_util->db_flush_delay_seconds_ = 0; |
| 695 file_util->MarkUsed(); |
| 696 base::RunLoop().RunUntilIdle(); |
| 697 |
| 698 ASSERT_TRUE(file_util->origin_database_ == NULL); |
| 699 } |
| 700 |
| 701 void MaybeDropDatabasesAlreadyDeletedCaseTestBody() { |
| 702 // Run message loop after OFU is already deleted to make sure callback |
| 703 // doesn't cause a crash for use after free. |
| 704 { |
| 705 scoped_ptr<ObfuscatedFileUtil> file_util = CreateObfuscatedFileUtil(NULL); |
| 706 file_util->InitOriginDatabase(GURL(), true /*create*/); |
| 707 file_util->db_flush_delay_seconds_ = 0; |
| 708 file_util->MarkUsed(); |
| 709 } |
| 710 |
| 711 // At this point the callback is still in the message queue but OFU is gone. |
| 712 base::RunLoop().RunUntilIdle(); |
| 713 } |
| 714 |
| 715 void DestroyDirectoryDatabase_IsolatedTestBody() { |
| 716 storage_policy_->AddIsolated(origin_); |
| 717 scoped_ptr<ObfuscatedFileUtil> file_util = CreateObfuscatedFileUtil( |
| 718 storage_policy_.get()); |
| 719 const FileSystemURL url = FileSystemURL::CreateForTest( |
| 720 origin_, kFileSystemTypePersistent, base::FilePath()); |
| 721 |
| 722 // Create DirectoryDatabase for isolated origin. |
| 723 SandboxDirectoryDatabase* db = |
| 724 file_util->GetDirectoryDatabase(url, true /* create */); |
| 725 ASSERT_TRUE(db != NULL); |
| 726 |
| 727 // Destory it. |
| 728 ASSERT_TRUE(file_util->DestroyDirectoryDatabase( |
| 729 url.origin(), GetTypeString(url.type()))); |
| 730 ASSERT_TRUE(file_util->directories_.empty()); |
| 731 } |
| 732 |
| 733 void GetDirectoryDatabase_IsolatedTestBody() { |
| 734 storage_policy_->AddIsolated(origin_); |
| 735 scoped_ptr<ObfuscatedFileUtil> file_util = CreateObfuscatedFileUtil( |
| 736 storage_policy_.get()); |
| 737 const FileSystemURL url = FileSystemURL::CreateForTest( |
| 738 origin_, kFileSystemTypePersistent, base::FilePath()); |
| 739 |
| 740 // Create DirectoryDatabase for isolated origin. |
| 741 SandboxDirectoryDatabase* db = |
| 742 file_util->GetDirectoryDatabase(url, true /* create */); |
| 743 ASSERT_TRUE(db != NULL); |
| 744 ASSERT_EQ(1U, file_util->directories_.size()); |
| 745 |
| 746 // Remove isolated. |
| 747 storage_policy_->RemoveIsolated(url.origin()); |
| 748 |
| 749 // This should still get the same database. |
| 750 SandboxDirectoryDatabase* db2 = |
| 751 file_util->GetDirectoryDatabase(url, false /* create */); |
| 752 ASSERT_EQ(db, db2); |
| 753 } |
| 754 |
| 755 void MigrationBackFromIsolatedTestBody() { |
| 756 std::string kFakeDirectoryData("0123456789"); |
| 757 base::FilePath old_directory_db_path; |
| 758 |
| 759 // Initialize the directory with one origin using |
| 760 // SandboxIsolatedOriginDatabase. |
| 761 { |
| 762 std::string origin_string = |
| 763 webkit_database::GetIdentifierFromOrigin(origin_); |
| 764 SandboxIsolatedOriginDatabase database_old( |
| 765 origin_string, data_dir_path(), |
| 766 base::FilePath( |
| 767 SandboxIsolatedOriginDatabase::kObsoleteOriginDirectory)); |
| 768 base::FilePath path; |
| 769 EXPECT_TRUE(database_old.GetPathForOrigin(origin_string, &path)); |
| 770 EXPECT_FALSE(path.empty()); |
| 771 |
| 772 // Populate the origin directory with some fake data. |
| 773 old_directory_db_path = data_dir_path().Append(path); |
| 774 ASSERT_TRUE(base::CreateDirectory(old_directory_db_path)); |
| 775 EXPECT_EQ(static_cast<int>(kFakeDirectoryData.size()), |
| 776 file_util::WriteFile(old_directory_db_path.AppendASCII("dummy"), |
| 777 kFakeDirectoryData.data(), |
| 778 kFakeDirectoryData.size())); |
| 779 } |
| 780 |
| 781 storage_policy_->AddIsolated(origin_); |
| 782 scoped_ptr<ObfuscatedFileUtil> file_util = CreateObfuscatedFileUtil( |
| 783 storage_policy_.get()); |
| 784 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
| 785 base::FilePath origin_directory = file_util->GetDirectoryForOrigin( |
| 786 origin_, true /* create */, &error); |
| 787 EXPECT_EQ(base::PLATFORM_FILE_OK, error); |
| 788 |
| 789 // The database is migrated from the old one. |
| 790 EXPECT_TRUE(base::DirectoryExists(origin_directory)); |
| 791 EXPECT_FALSE(base::DirectoryExists(old_directory_db_path)); |
| 792 |
| 793 // Check we see the same contents in the new origin directory. |
| 794 std::string origin_db_data; |
| 795 EXPECT_TRUE(base::PathExists(origin_directory.AppendASCII("dummy"))); |
| 796 EXPECT_TRUE(base::ReadFileToString( |
| 797 origin_directory.AppendASCII("dummy"), &origin_db_data)); |
| 798 EXPECT_EQ(kFakeDirectoryData, origin_db_data); |
| 799 } |
| 800 |
665 int64 ComputeCurrentUsage() { | 801 int64 ComputeCurrentUsage() { |
666 return sandbox_file_system_.ComputeCurrentOriginUsage() - | 802 return sandbox_file_system_.ComputeCurrentOriginUsage() - |
667 sandbox_file_system_.ComputeCurrentDirectoryDatabaseUsage(); | 803 sandbox_file_system_.ComputeCurrentDirectoryDatabaseUsage(); |
668 } | 804 } |
669 | 805 |
670 FileSystemContext* file_system_context() { | 806 FileSystemContext* file_system_context() { |
671 return sandbox_file_system_.file_system_context(); | 807 return sandbox_file_system_.file_system_context(); |
672 } | 808 } |
673 | 809 |
674 const base::FilePath& data_dir_path() const { | 810 const base::FilePath& data_dir_path() const { |
675 return data_dir_.path(); | 811 return data_dir_.path(); |
676 } | 812 } |
677 | 813 |
678 protected: | 814 protected: |
679 base::ScopedTempDir data_dir_; | 815 base::ScopedTempDir data_dir_; |
680 base::MessageLoop message_loop_; | 816 base::MessageLoop message_loop_; |
681 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_; | 817 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_; |
682 scoped_refptr<quota::QuotaManager> quota_manager_; | 818 scoped_refptr<quota::QuotaManager> quota_manager_; |
683 scoped_refptr<FileSystemContext> file_system_context_; | 819 scoped_refptr<FileSystemContext> file_system_context_; |
684 GURL origin_; | 820 GURL origin_; |
685 fileapi::FileSystemType type_; | 821 fileapi::FileSystemType type_; |
686 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_; | 822 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_; |
687 SandboxFileSystemTestHelper sandbox_file_system_; | 823 SandboxFileSystemTestHelper sandbox_file_system_; |
688 quota::QuotaStatusCode quota_status_; | 824 quota::QuotaStatusCode quota_status_; |
689 int64 usage_; | 825 int64 usage_; |
690 MockFileChangeObserver change_observer_; | 826 fileapi::MockFileChangeObserver change_observer_; |
691 ChangeObserverList change_observers_; | 827 fileapi::ChangeObserverList change_observers_; |
692 | 828 |
693 private: | 829 private: |
694 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtilTest); | 830 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtilTest); |
695 }; | 831 }; |
696 | 832 |
697 TEST_F(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) { | 833 TEST_F(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) { |
698 base::PlatformFile file_handle = base::kInvalidPlatformFileValue; | 834 base::PlatformFile file_handle = base::kInvalidPlatformFileValue; |
699 bool created; | 835 bool created; |
700 FileSystemURL url = CreateURLFromUTF8("fake/file"); | 836 FileSystemURL url = CreateURLFromUTF8("fake/file"); |
701 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 837 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 | 1249 |
1114 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) { | 1250 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) { |
1115 FileSystemURL url = CreateURLFromUTF8("file"); | 1251 FileSystemURL url = CreateURLFromUTF8("file"); |
1116 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 1252 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
1117 | 1253 |
1118 bool created = false; | 1254 bool created = false; |
1119 ASSERT_EQ(base::PLATFORM_FILE_OK, | 1255 ASSERT_EQ(base::PLATFORM_FILE_OK, |
1120 ofu()->EnsureFileExists(context.get(), url, &created)); | 1256 ofu()->EnsureFileExists(context.get(), url, &created)); |
1121 ASSERT_TRUE(created); | 1257 ASSERT_TRUE(created); |
1122 | 1258 |
1123 std::vector<DirectoryEntry> entries; | 1259 std::vector<fileapi::DirectoryEntry> entries; |
1124 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, | 1260 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, |
1125 AsyncFileTestHelper::ReadDirectory( | 1261 AsyncFileTestHelper::ReadDirectory( |
1126 file_system_context(), url, &entries)); | 1262 file_system_context(), url, &entries)); |
1127 | 1263 |
1128 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url)); | 1264 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url)); |
1129 } | 1265 } |
1130 | 1266 |
1131 TEST_F(ObfuscatedFileUtilTest, TestTouch) { | 1267 TEST_F(ObfuscatedFileUtilTest, TestTouch) { |
1132 FileSystemURL url = CreateURLFromUTF8("file"); | 1268 FileSystemURL url = CreateURLFromUTF8("file"); |
1133 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 1269 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 origins_expected.end(), origins_found.begin(), origins_found.end(), | 1696 origins_expected.end(), origins_found.begin(), origins_found.end(), |
1561 inserter(diff, diff.begin())); | 1697 inserter(diff, diff.begin())); |
1562 EXPECT_TRUE(diff.empty()); | 1698 EXPECT_TRUE(diff.empty()); |
1563 } | 1699 } |
1564 | 1700 |
1565 TEST_F(ObfuscatedFileUtilTest, TestRevokeUsageCache) { | 1701 TEST_F(ObfuscatedFileUtilTest, TestRevokeUsageCache) { |
1566 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 1702 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
1567 | 1703 |
1568 int64 expected_quota = 0; | 1704 int64 expected_quota = 0; |
1569 | 1705 |
1570 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { | 1706 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { |
1571 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCase " << i); | 1707 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCase " << i); |
1572 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; | 1708 const fileapi::test::TestCaseRecord& test_case = |
| 1709 fileapi::test::kRegularTestCases[i]; |
1573 base::FilePath file_path(test_case.path); | 1710 base::FilePath file_path(test_case.path); |
1574 expected_quota += ObfuscatedFileUtil::ComputeFilePathCost(file_path); | 1711 expected_quota += ObfuscatedFileUtil::ComputeFilePathCost(file_path); |
1575 if (test_case.is_directory) { | 1712 if (test_case.is_directory) { |
1576 bool exclusive = true; | 1713 bool exclusive = true; |
1577 bool recursive = false; | 1714 bool recursive = false; |
1578 ASSERT_EQ(base::PLATFORM_FILE_OK, | 1715 ASSERT_EQ(base::PLATFORM_FILE_OK, |
1579 ofu()->CreateDirectory(context.get(), CreateURL(file_path), | 1716 ofu()->CreateDirectory(context.get(), CreateURL(file_path), |
1580 exclusive, recursive)); | 1717 exclusive, recursive)); |
1581 } else { | 1718 } else { |
1582 bool created = false; | 1719 bool created = false; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 scoped_ptr<FileSystemOperationContext> context; | 1832 scoped_ptr<FileSystemOperationContext> context; |
1696 | 1833 |
1697 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) { | 1834 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) { |
1698 bool created = false; | 1835 bool created = false; |
1699 context.reset(NewContext(NULL)); | 1836 context.reset(NewContext(NULL)); |
1700 EXPECT_EQ(base::PLATFORM_FILE_OK, | 1837 EXPECT_EQ(base::PLATFORM_FILE_OK, |
1701 ofu()->EnsureFileExists(context.get(), kPath[i], &created)); | 1838 ofu()->EnsureFileExists(context.get(), kPath[i], &created)); |
1702 EXPECT_TRUE(created); | 1839 EXPECT_TRUE(created); |
1703 } | 1840 } |
1704 | 1841 |
1705 std::vector<DirectoryEntry> entries; | 1842 std::vector<fileapi::DirectoryEntry> entries; |
1706 EXPECT_EQ(base::PLATFORM_FILE_OK, | 1843 EXPECT_EQ(base::PLATFORM_FILE_OK, |
1707 AsyncFileTestHelper::ReadDirectory( | 1844 AsyncFileTestHelper::ReadDirectory( |
1708 file_system_context(), empty_path, &entries)); | 1845 file_system_context(), empty_path, &entries)); |
1709 EXPECT_EQ(3u, entries.size()); | 1846 EXPECT_EQ(3u, entries.size()); |
1710 | 1847 |
1711 base::FilePath local_path; | 1848 base::FilePath local_path; |
1712 EXPECT_EQ(base::PLATFORM_FILE_OK, | 1849 EXPECT_EQ(base::PLATFORM_FILE_OK, |
1713 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); | 1850 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); |
1714 EXPECT_TRUE(base::DeleteFile(local_path, false)); | 1851 EXPECT_TRUE(base::DeleteFile(local_path, false)); |
1715 | 1852 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 ofu()->GetLocalFilePath(context.get(), url1, &file_path)); | 2089 ofu()->GetLocalFilePath(context.get(), url1, &file_path)); |
1953 EXPECT_FALSE(file_path.empty()); | 2090 EXPECT_FALSE(file_path.empty()); |
1954 | 2091 |
1955 context.reset(NewContext(NULL)); | 2092 context.reset(NewContext(NULL)); |
1956 EXPECT_EQ(base::PLATFORM_FILE_OK, | 2093 EXPECT_EQ(base::PLATFORM_FILE_OK, |
1957 ofu()->Touch(context.get(), url1, | 2094 ofu()->Touch(context.get(), url1, |
1958 base::Time::Now() + base::TimeDelta::FromHours(1), | 2095 base::Time::Now() + base::TimeDelta::FromHours(1), |
1959 base::Time())); | 2096 base::Time())); |
1960 | 2097 |
1961 context.reset(NewContext(NULL)); | 2098 context.reset(NewContext(NULL)); |
1962 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> file_enum( | 2099 scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> file_enum( |
1963 ofu()->CreateFileEnumerator(context.get(), dir, false)); | 2100 ofu()->CreateFileEnumerator(context.get(), dir, false)); |
1964 | 2101 |
1965 int count = 0; | 2102 int count = 0; |
1966 base::FilePath file_path_each; | 2103 base::FilePath file_path_each; |
1967 while (!(file_path_each = file_enum->Next()).empty()) { | 2104 while (!(file_path_each = file_enum->Next()).empty()) { |
1968 context.reset(NewContext(NULL)); | 2105 context.reset(NewContext(NULL)); |
1969 base::PlatformFileInfo file_info; | 2106 base::PlatformFileInfo file_info; |
1970 base::FilePath file_path; | 2107 base::FilePath file_path; |
1971 EXPECT_EQ(base::PLATFORM_FILE_OK, | 2108 EXPECT_EQ(base::PLATFORM_FILE_OK, |
1972 ofu()->GetFileInfo(context.get(), | 2109 ofu()->GetFileInfo(context.get(), |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 ASSERT_EQ(base::PLATFORM_FILE_OK, | 2442 ASSERT_EQ(base::PLATFORM_FILE_OK, |
2306 ofu()->CreateOrOpen( | 2443 ofu()->CreateOrOpen( |
2307 AllowUsageIncrease(-length)->context(), file, | 2444 AllowUsageIncrease(-length)->context(), file, |
2308 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, | 2445 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, |
2309 &file_handle, &created)); | 2446 &file_handle, &created)); |
2310 ASSERT_EQ(0, ComputeTotalFileSize()); | 2447 ASSERT_EQ(0, ComputeTotalFileSize()); |
2311 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); | 2448 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); |
2312 } | 2449 } |
2313 | 2450 |
2314 TEST_F(ObfuscatedFileUtilTest, MaybeDropDatabasesAliveCase) { | 2451 TEST_F(ObfuscatedFileUtilTest, MaybeDropDatabasesAliveCase) { |
2315 scoped_ptr<ObfuscatedFileUtil> file_util( | 2452 MaybeDropDatabasesAliveCaseTestBody(); |
2316 ObfuscatedFileUtil::CreateForTesting( | |
2317 NULL, data_dir_path(), | |
2318 base::MessageLoopProxy::current().get())); | |
2319 file_util->InitOriginDatabase(GURL(), true /*create*/); | |
2320 ASSERT_TRUE(file_util->origin_database_ != NULL); | |
2321 | |
2322 // Callback to Drop DB is called while ObfuscatedFileUtilTest is still alive. | |
2323 file_util->db_flush_delay_seconds_ = 0; | |
2324 file_util->MarkUsed(); | |
2325 base::RunLoop().RunUntilIdle(); | |
2326 | |
2327 ASSERT_TRUE(file_util->origin_database_ == NULL); | |
2328 } | 2453 } |
2329 | 2454 |
2330 TEST_F(ObfuscatedFileUtilTest, MaybeDropDatabasesAlreadyDeletedCase) { | 2455 TEST_F(ObfuscatedFileUtilTest, MaybeDropDatabasesAlreadyDeletedCase) { |
2331 // Run message loop after OFU is already deleted to make sure callback doesn't | 2456 MaybeDropDatabasesAlreadyDeletedCaseTestBody(); |
2332 // cause a crash for use after free. | |
2333 { | |
2334 scoped_ptr<ObfuscatedFileUtil> file_util( | |
2335 ObfuscatedFileUtil::CreateForTesting( | |
2336 NULL, data_dir_path(), | |
2337 base::MessageLoopProxy::current().get())); | |
2338 file_util->InitOriginDatabase(GURL(), true /*create*/); | |
2339 file_util->db_flush_delay_seconds_ = 0; | |
2340 file_util->MarkUsed(); | |
2341 } | |
2342 | |
2343 // At this point the callback is still in the message queue but OFU is gone. | |
2344 base::RunLoop().RunUntilIdle(); | |
2345 } | 2457 } |
2346 | 2458 |
2347 TEST_F(ObfuscatedFileUtilTest, DestroyDirectoryDatabase_Isolated) { | 2459 TEST_F(ObfuscatedFileUtilTest, DestroyDirectoryDatabase_Isolated) { |
2348 storage_policy_->AddIsolated(origin_); | 2460 DestroyDirectoryDatabase_IsolatedTestBody(); |
2349 scoped_ptr<ObfuscatedFileUtil> file_util( | |
2350 ObfuscatedFileUtil::CreateForTesting( | |
2351 storage_policy_.get(), data_dir_path(), | |
2352 base::MessageLoopProxy::current().get())); | |
2353 const FileSystemURL url = FileSystemURL::CreateForTest( | |
2354 origin_, kFileSystemTypePersistent, base::FilePath()); | |
2355 | |
2356 // Create DirectoryDatabase for isolated origin. | |
2357 SandboxDirectoryDatabase* db = | |
2358 file_util->GetDirectoryDatabase(url, true /* create */); | |
2359 ASSERT_TRUE(db != NULL); | |
2360 | |
2361 // Destory it. | |
2362 ASSERT_TRUE(file_util->DestroyDirectoryDatabase( | |
2363 url.origin(), GetTypeString(url.type()))); | |
2364 ASSERT_TRUE(file_util->directories_.empty()); | |
2365 } | 2461 } |
2366 | 2462 |
2367 TEST_F(ObfuscatedFileUtilTest, GetDirectoryDatabase_Isolated) { | 2463 TEST_F(ObfuscatedFileUtilTest, GetDirectoryDatabase_Isolated) { |
2368 storage_policy_->AddIsolated(origin_); | 2464 GetDirectoryDatabase_IsolatedTestBody(); |
2369 scoped_ptr<ObfuscatedFileUtil> file_util( | |
2370 ObfuscatedFileUtil::CreateForTesting( | |
2371 storage_policy_.get(), data_dir_path(), | |
2372 base::MessageLoopProxy::current().get())); | |
2373 const FileSystemURL url = FileSystemURL::CreateForTest( | |
2374 origin_, kFileSystemTypePersistent, base::FilePath()); | |
2375 | |
2376 // Create DirectoryDatabase for isolated origin. | |
2377 SandboxDirectoryDatabase* db = | |
2378 file_util->GetDirectoryDatabase(url, true /* create */); | |
2379 ASSERT_TRUE(db != NULL); | |
2380 ASSERT_EQ(1U, file_util->directories_.size()); | |
2381 | |
2382 // Remove isolated. | |
2383 storage_policy_->RemoveIsolated(url.origin()); | |
2384 | |
2385 // This should still get the same database. | |
2386 SandboxDirectoryDatabase* db2 = | |
2387 file_util->GetDirectoryDatabase(url, false /* create */); | |
2388 ASSERT_EQ(db, db2); | |
2389 } | 2465 } |
2390 | 2466 |
2391 TEST_F(ObfuscatedFileUtilTest, MigrationBackFromIsolated) { | 2467 TEST_F(ObfuscatedFileUtilTest, MigrationBackFromIsolated) { |
2392 std::string kFakeDirectoryData("0123456789"); | 2468 MigrationBackFromIsolatedTestBody(); |
2393 base::FilePath old_directory_db_path; | |
2394 | |
2395 // Initialize the directory with one origin using | |
2396 // SandboxIsolatedOriginDatabase. | |
2397 { | |
2398 std::string origin_string = | |
2399 webkit_database::GetIdentifierFromOrigin(origin_); | |
2400 SandboxIsolatedOriginDatabase database_old( | |
2401 origin_string, data_dir_path(), | |
2402 base::FilePath( | |
2403 SandboxIsolatedOriginDatabase::kObsoleteOriginDirectory)); | |
2404 base::FilePath path; | |
2405 EXPECT_TRUE(database_old.GetPathForOrigin(origin_string, &path)); | |
2406 EXPECT_FALSE(path.empty()); | |
2407 | |
2408 // Populate the origin directory with some fake data. | |
2409 old_directory_db_path = data_dir_path().Append(path); | |
2410 ASSERT_TRUE(base::CreateDirectory(old_directory_db_path)); | |
2411 EXPECT_EQ(static_cast<int>(kFakeDirectoryData.size()), | |
2412 file_util::WriteFile(old_directory_db_path.AppendASCII("dummy"), | |
2413 kFakeDirectoryData.data(), | |
2414 kFakeDirectoryData.size())); | |
2415 } | |
2416 | |
2417 storage_policy_->AddIsolated(origin_); | |
2418 scoped_ptr<ObfuscatedFileUtil> file_util( | |
2419 ObfuscatedFileUtil::CreateForTesting( | |
2420 storage_policy_.get(), data_dir_path(), | |
2421 base::MessageLoopProxy::current().get())); | |
2422 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; | |
2423 base::FilePath origin_directory = file_util->GetDirectoryForOrigin( | |
2424 origin_, true /* create */, &error); | |
2425 EXPECT_EQ(base::PLATFORM_FILE_OK, error); | |
2426 | |
2427 // The database is migrated from the old one. | |
2428 EXPECT_TRUE(base::DirectoryExists(origin_directory)); | |
2429 EXPECT_FALSE(base::DirectoryExists(old_directory_db_path)); | |
2430 | |
2431 // Check we see the same contents in the new origin directory. | |
2432 std::string origin_db_data; | |
2433 EXPECT_TRUE(base::PathExists(origin_directory.AppendASCII("dummy"))); | |
2434 EXPECT_TRUE(base::ReadFileToString( | |
2435 origin_directory.AppendASCII("dummy"), &origin_db_data)); | |
2436 EXPECT_EQ(kFakeDirectoryData, origin_db_data); | |
2437 } | 2469 } |
2438 | 2470 |
2439 TEST_F(ObfuscatedFileUtilTest, OpenPathInNonDirectory) { | 2471 TEST_F(ObfuscatedFileUtilTest, OpenPathInNonDirectory) { |
2440 FileSystemURL file(CreateURLFromUTF8("file")); | 2472 FileSystemURL file(CreateURLFromUTF8("file")); |
2441 FileSystemURL path_in_file(CreateURLFromUTF8("file/file")); | 2473 FileSystemURL path_in_file(CreateURLFromUTF8("file/file")); |
2442 bool created; | 2474 bool created; |
2443 | 2475 |
2444 ASSERT_EQ(base::PLATFORM_FILE_OK, | 2476 ASSERT_EQ(base::PLATFORM_FILE_OK, |
2445 ofu()->EnsureFileExists(UnlimitedContext().get(), file, &created)); | 2477 ofu()->EnsureFileExists(UnlimitedContext().get(), file, &created)); |
2446 ASSERT_TRUE(created); | 2478 ASSERT_TRUE(created); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 path_in_file, | 2512 path_in_file, |
2481 false /* exclusive */, | 2513 false /* exclusive */, |
2482 true /* recursive */)); | 2514 true /* recursive */)); |
2483 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, | 2515 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, |
2484 ofu()->CreateDirectory(UnlimitedContext().get(), | 2516 ofu()->CreateDirectory(UnlimitedContext().get(), |
2485 path_in_file_in_file, | 2517 path_in_file_in_file, |
2486 false /* exclusive */, | 2518 false /* exclusive */, |
2487 true /* recursive */)); | 2519 true /* recursive */)); |
2488 } | 2520 } |
2489 | 2521 |
2490 } // namespace fileapi | 2522 } // namespace content |
OLD | NEW |