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 #ifndef WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ | 5 #ifndef WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ |
6 #define WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ | 6 #define WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "webkit/fileapi/file_system_types.h" | 13 #include "webkit/fileapi/file_system_types.h" |
14 #include "webkit/fileapi/file_system_url.h" | 14 #include "webkit/fileapi/file_system_url.h" |
15 #include "webkit/fileapi/file_system_util.h" | 15 #include "webkit/fileapi/file_system_util.h" |
16 #include "webkit/quota/quota_types.h" | 16 #include "webkit/quota/quota_types.h" |
17 | 17 |
| 18 namespace base { |
| 19 class FilePath; |
| 20 } |
| 21 |
18 namespace quota { | 22 namespace quota { |
19 class QuotaManagerProxy; | 23 class QuotaManagerProxy; |
20 } | 24 } |
21 | 25 |
22 class FilePath; | |
23 | |
24 namespace fileapi { | 26 namespace fileapi { |
25 | 27 |
26 class FileSystemContext; | 28 class FileSystemContext; |
27 class FileSystemFileUtil; | 29 class FileSystemFileUtil; |
28 class FileSystemOperationContext; | 30 class FileSystemOperationContext; |
29 class LocalFileSystemOperation; | 31 class LocalFileSystemOperation; |
30 | 32 |
31 // Filesystem test helper class that encapsulates test environment for | 33 // Filesystem test helper class that encapsulates test environment for |
32 // a given {origin, type} pair. This helper only works for sandboxed | 34 // a given {origin, type} pair. This helper only works for sandboxed |
33 // file systems (Temporary, Persistent or Test types). | 35 // file systems (Temporary, Persistent or Test types). |
34 class LocalFileSystemTestOriginHelper { | 36 class LocalFileSystemTestOriginHelper { |
35 public: | 37 public: |
36 LocalFileSystemTestOriginHelper(const GURL& origin, FileSystemType type); | 38 LocalFileSystemTestOriginHelper(const GURL& origin, FileSystemType type); |
37 LocalFileSystemTestOriginHelper(); | 39 LocalFileSystemTestOriginHelper(); |
38 ~LocalFileSystemTestOriginHelper(); | 40 ~LocalFileSystemTestOriginHelper(); |
39 | 41 |
40 void SetUp(const FilePath& base_dir); | 42 void SetUp(const base::FilePath& base_dir); |
41 // If you want to use more than one LocalFileSystemTestOriginHelper in | 43 // If you want to use more than one LocalFileSystemTestOriginHelper in |
42 // a single base directory, they have to share a context, so that they don't | 44 // a single base directory, they have to share a context, so that they don't |
43 // have multiple databases fighting over the lock to the origin directory | 45 // have multiple databases fighting over the lock to the origin directory |
44 // [deep down inside ObfuscatedFileUtil]. | 46 // [deep down inside ObfuscatedFileUtil]. |
45 void SetUp(FileSystemContext* file_system_context); | 47 void SetUp(FileSystemContext* file_system_context); |
46 void SetUp(const FilePath& base_dir, | 48 void SetUp(const base::FilePath& base_dir, |
47 bool unlimited_quota, | 49 bool unlimited_quota, |
48 quota::QuotaManagerProxy* quota_manager_proxy); | 50 quota::QuotaManagerProxy* quota_manager_proxy); |
49 void TearDown(); | 51 void TearDown(); |
50 | 52 |
51 FilePath GetOriginRootPath() const; | 53 base::FilePath GetOriginRootPath() const; |
52 FilePath GetLocalPath(const FilePath& path); | 54 base::FilePath GetLocalPath(const base::FilePath& path); |
53 FilePath GetLocalPathFromASCII(const std::string& path); | 55 base::FilePath GetLocalPathFromASCII(const std::string& path); |
54 | 56 |
55 // Returns empty path if filesystem type is neither temporary nor persistent. | 57 // Returns empty path if filesystem type is neither temporary nor persistent. |
56 FilePath GetUsageCachePath() const; | 58 base::FilePath GetUsageCachePath() const; |
57 | 59 |
58 FileSystemURL CreateURL(const FilePath& path) const; | 60 FileSystemURL CreateURL(const base::FilePath& path) const; |
59 FileSystemURL CreateURLFromUTF8(const std::string& utf8) const { | 61 FileSystemURL CreateURLFromUTF8(const std::string& utf8) const { |
60 return CreateURL(FilePath::FromUTF8Unsafe(utf8)); | 62 return CreateURL(base::FilePath::FromUTF8Unsafe(utf8)); |
61 } | 63 } |
62 | 64 |
63 // Helper methods for same-FileUtil copy/move. | 65 // Helper methods for same-FileUtil copy/move. |
64 base::PlatformFileError SameFileUtilCopy( | 66 base::PlatformFileError SameFileUtilCopy( |
65 FileSystemOperationContext* context, | 67 FileSystemOperationContext* context, |
66 const FileSystemURL& src, | 68 const FileSystemURL& src, |
67 const FileSystemURL& dest) const; | 69 const FileSystemURL& dest) const; |
68 base::PlatformFileError SameFileUtilMove( | 70 base::PlatformFileError SameFileUtilMove( |
69 FileSystemOperationContext* context, | 71 FileSystemOperationContext* context, |
70 const FileSystemURL& src, | 72 const FileSystemURL& src, |
(...skipping 26 matching lines...) Expand all Loading... |
97 | 99 |
98 scoped_refptr<FileSystemContext> file_system_context_; | 100 scoped_refptr<FileSystemContext> file_system_context_; |
99 const GURL origin_; | 101 const GURL origin_; |
100 const FileSystemType type_; | 102 const FileSystemType type_; |
101 FileSystemFileUtil* file_util_; | 103 FileSystemFileUtil* file_util_; |
102 }; | 104 }; |
103 | 105 |
104 } // namespace fileapi | 106 } // namespace fileapi |
105 | 107 |
106 #endif // WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ | 108 #endif // WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ |
OLD | NEW |