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/local_file_system_operation.h" | 5 #include "webkit/fileapi/local_file_system_operation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webkit/blob/shareable_file_reference.h" | 16 #include "webkit/blob/shareable_file_reference.h" |
17 #include "webkit/fileapi/file_system_context.h" | 17 #include "webkit/fileapi/file_system_context.h" |
18 #include "webkit/fileapi/file_system_file_util.h" | 18 #include "webkit/fileapi/file_system_file_util.h" |
19 #include "webkit/fileapi/file_system_mount_point_provider.h" | 19 #include "webkit/fileapi/file_system_mount_point_provider.h" |
20 #include "webkit/fileapi/file_system_quota_util.h" | 20 #include "webkit/fileapi/file_system_quota_util.h" |
21 #include "webkit/fileapi/file_system_util.h" | 21 #include "webkit/fileapi/file_system_util.h" |
| 22 #include "webkit/fileapi/file_util_helper.h" |
22 #include "webkit/fileapi/local_file_system_test_helper.h" | 23 #include "webkit/fileapi/local_file_system_test_helper.h" |
23 #include "webkit/quota/quota_manager.h" | 24 #include "webkit/quota/quota_manager.h" |
24 | 25 |
25 using quota::QuotaClient; | 26 using quota::QuotaClient; |
26 using quota::QuotaManager; | 27 using quota::QuotaManager; |
27 using quota::QuotaManagerProxy; | 28 using quota::QuotaManagerProxy; |
28 using quota::StorageType; | 29 using quota::StorageType; |
29 using webkit_blob::ShareableFileReference; | 30 using webkit_blob::ShareableFileReference; |
30 | 31 |
31 namespace fileapi { | 32 namespace fileapi { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return test_helper_.CreateURL(path); | 209 return test_helper_.CreateURL(path); |
209 } | 210 } |
210 | 211 |
211 FilePath PlatformPath(const FilePath& virtual_path) { | 212 FilePath PlatformPath(const FilePath& virtual_path) { |
212 return test_helper_.GetLocalPath(virtual_path); | 213 return test_helper_.GetLocalPath(virtual_path); |
213 } | 214 } |
214 | 215 |
215 bool FileExists(const FilePath& virtual_path) { | 216 bool FileExists(const FilePath& virtual_path) { |
216 FileSystemURL path = test_helper_.CreateURL(virtual_path); | 217 FileSystemURL path = test_helper_.CreateURL(virtual_path); |
217 scoped_ptr<FileSystemOperationContext> context(NewContext()); | 218 scoped_ptr<FileSystemOperationContext> context(NewContext()); |
218 if (!file_util()->PathExists(context.get(), path)) | 219 if (!FileUtilHelper::PathExists(context.get(), file_util(), path)) |
219 return false; | 220 return false; |
220 | 221 |
221 context.reset(NewContext()); | 222 context.reset(NewContext()); |
222 return !file_util()->DirectoryExists(context.get(), path); | 223 return !FileUtilHelper::DirectoryExists(context.get(), file_util(), path); |
223 } | 224 } |
224 | 225 |
225 bool DirectoryExists(const FilePath& virtual_path) { | 226 bool DirectoryExists(const FilePath& virtual_path) { |
226 FileSystemURL url = test_helper_.CreateURL(virtual_path); | 227 FileSystemURL url = test_helper_.CreateURL(virtual_path); |
227 scoped_ptr<FileSystemOperationContext> context(NewContext()); | 228 scoped_ptr<FileSystemOperationContext> context(NewContext()); |
228 return file_util()->DirectoryExists(context.get(), url); | 229 return FileUtilHelper::DirectoryExists(context.get(), file_util(), url); |
229 } | 230 } |
230 | 231 |
231 FilePath CreateUniqueFileInDir(const FilePath& virtual_dir_path) { | 232 FilePath CreateUniqueFileInDir(const FilePath& virtual_dir_path) { |
232 FilePath file_name = FilePath::FromUTF8Unsafe( | 233 FilePath file_name = FilePath::FromUTF8Unsafe( |
233 "tmpfile-" + base::IntToString(next_unique_path_suffix_++)); | 234 "tmpfile-" + base::IntToString(next_unique_path_suffix_++)); |
234 FileSystemURL url = test_helper_.CreateURL( | 235 FileSystemURL url = test_helper_.CreateURL( |
235 virtual_dir_path.Append(file_name)); | 236 virtual_dir_path.Append(file_name)); |
236 | 237 |
237 scoped_ptr<FileSystemOperationContext> context(NewContext()); | 238 scoped_ptr<FileSystemOperationContext> context(NewContext()); |
238 bool created; | 239 bool created; |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); | 1147 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
1147 EXPECT_FALSE(info().is_directory); | 1148 EXPECT_FALSE(info().is_directory); |
1148 EXPECT_EQ(PlatformPath(file_path), path()); | 1149 EXPECT_EQ(PlatformPath(file_path), path()); |
1149 | 1150 |
1150 // The FileSystemOpration implementation does not create a | 1151 // The FileSystemOpration implementation does not create a |
1151 // shareable file reference. | 1152 // shareable file reference. |
1152 EXPECT_EQ(NULL, shareable_file_ref()); | 1153 EXPECT_EQ(NULL, shareable_file_ref()); |
1153 } | 1154 } |
1154 | 1155 |
1155 } // namespace fileapi | 1156 } // namespace fileapi |
OLD | NEW |