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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 bool IsDirectoryEmpty(FileSystemContext* context, const FileSystemURL& url) { | 57 bool IsDirectoryEmpty(FileSystemContext* context, const FileSystemURL& url) { |
58 FileEntryList entries; | 58 FileEntryList entries; |
59 EXPECT_EQ(base::PLATFORM_FILE_OK, | 59 EXPECT_EQ(base::PLATFORM_FILE_OK, |
60 AsyncFileTestHelper::ReadDirectory(context, url, &entries)); | 60 AsyncFileTestHelper::ReadDirectory(context, url, &entries)); |
61 return entries.empty(); | 61 return entries.empty(); |
62 } | 62 } |
63 | 63 |
64 FileSystemURL GetEntryURL(FileSystemContext* file_system_context, | 64 FileSystemURL GetEntryURL(FileSystemContext* file_system_context, |
65 const FileSystemURL& dir, | 65 const FileSystemURL& dir, |
66 const FilePath::StringType& name) { | 66 const base::FilePath::StringType& name) { |
67 return file_system_context->CreateCrackedFileSystemURL( | 67 return file_system_context->CreateCrackedFileSystemURL( |
68 dir.origin(), | 68 dir.origin(), |
69 dir.mount_type(), | 69 dir.mount_type(), |
70 dir.virtual_path().Append(name)); | 70 dir.virtual_path().Append(name)); |
71 } | 71 } |
72 | 72 |
73 FilePath GetRelativeVirtualPath(const FileSystemURL& root, | 73 base::FilePath GetRelativeVirtualPath(const FileSystemURL& root, |
74 const FileSystemURL& url) { | 74 const FileSystemURL& url) { |
75 if (root.virtual_path().empty()) | 75 if (root.virtual_path().empty()) |
76 return url.virtual_path(); | 76 return url.virtual_path(); |
77 FilePath relative; | 77 base::FilePath relative; |
78 const bool success = root.virtual_path().AppendRelativePath( | 78 const bool success = root.virtual_path().AppendRelativePath( |
79 url.virtual_path(), &relative); | 79 url.virtual_path(), &relative); |
80 DCHECK(success); | 80 DCHECK(success); |
81 return relative; | 81 return relative; |
82 } | 82 } |
83 | 83 |
84 FileSystemURL GetOtherURL(FileSystemContext* file_system_context, | 84 FileSystemURL GetOtherURL(FileSystemContext* file_system_context, |
85 const FileSystemURL& root, | 85 const FileSystemURL& root, |
86 const FileSystemURL& other_root, | 86 const FileSystemURL& other_root, |
87 const FileSystemURL& url) { | 87 const FileSystemURL& url) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return file_system_context_->CreateCrackedFileSystemURL( | 155 return file_system_context_->CreateCrackedFileSystemURL( |
156 GURL("http://example.com"), | 156 GURL("http://example.com"), |
157 kFileSystemTypeIsolated, | 157 kFileSystemTypeIsolated, |
158 virtual_path); | 158 virtual_path); |
159 } | 159 } |
160 | 160 |
161 FileSystemURL GetOtherFileSystemURL(const base::FilePath& path) const { | 161 FileSystemURL GetOtherFileSystemURL(const base::FilePath& path) const { |
162 return file_system_context()->CreateCrackedFileSystemURL( | 162 return file_system_context()->CreateCrackedFileSystemURL( |
163 GURL("http://example.com"), | 163 GURL("http://example.com"), |
164 kFileSystemTypeTemporary, | 164 kFileSystemTypeTemporary, |
165 FilePath().AppendASCII("dest").Append(path)); | 165 base::FilePath().AppendASCII("dest").Append(path)); |
166 } | 166 } |
167 | 167 |
168 void VerifyFilesHaveSameContent(const FileSystemURL& url1, | 168 void VerifyFilesHaveSameContent(const FileSystemURL& url1, |
169 const FileSystemURL& url2) { | 169 const FileSystemURL& url2) { |
170 // Get the file info for url1. | 170 // Get the file info for url1. |
171 base::PlatformFileInfo info1; | 171 base::PlatformFileInfo info1; |
172 FilePath platform_path1; | 172 base::FilePath platform_path1; |
173 ASSERT_EQ(base::PLATFORM_FILE_OK, | 173 ASSERT_EQ(base::PLATFORM_FILE_OK, |
174 AsyncFileTestHelper::GetMetadata( | 174 AsyncFileTestHelper::GetMetadata( |
175 file_system_context(), url1, &info1, &platform_path1)); | 175 file_system_context(), url1, &info1, &platform_path1)); |
176 | 176 |
177 // Get the file info for url2. | 177 // Get the file info for url2. |
178 base::PlatformFileInfo info2; | 178 base::PlatformFileInfo info2; |
179 base::FilePath platform_path2; | 179 base::FilePath platform_path2; |
180 ASSERT_EQ(base::PLATFORM_FILE_OK, | 180 ASSERT_EQ(base::PLATFORM_FILE_OK, |
181 AsyncFileTestHelper::GetMetadata( | 181 AsyncFileTestHelper::GetMetadata( |
182 file_system_context(), url2, &info2, &platform_path2)); | 182 file_system_context(), url2, &info2, &platform_path2)); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 EXPECT_EQ(base::PLATFORM_FILE_OK, | 540 EXPECT_EQ(base::PLATFORM_FILE_OK, |
541 file_util()->Truncate(GetOperationContext().get(), url, 999)); | 541 file_util()->Truncate(GetOperationContext().get(), url, 999)); |
542 ASSERT_EQ(base::PLATFORM_FILE_OK, | 542 ASSERT_EQ(base::PLATFORM_FILE_OK, |
543 file_util()->GetFileInfo(GetOperationContext().get(), url, | 543 file_util()->GetFileInfo(GetOperationContext().get(), url, |
544 &info, &platform_path)); | 544 &info, &platform_path)); |
545 EXPECT_EQ(999, info.size); | 545 EXPECT_EQ(999, info.size); |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 } // namespace fileapi | 549 } // namespace fileapi |
OLD | NEW |