OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_FILE_SYSTEM_TEST_HELPER_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_TEST_HELPER_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_TEST_HELPER_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_TEST_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "webkit/fileapi/file_system_types.h" | 15 #include "webkit/fileapi/file_system_types.h" |
16 #include "webkit/fileapi/file_system_util.h" | 16 #include "webkit/fileapi/file_system_util.h" |
17 #include "webkit/quota/quota_types.h" | 17 #include "webkit/quota/quota_types.h" |
18 | 18 |
19 namespace quota { | 19 namespace quota { |
20 class QuotaManagerProxy; | 20 class QuotaManagerProxy; |
21 } | 21 } |
22 | 22 |
23 class FilePath; | 23 class FilePath; |
24 | 24 |
25 namespace fileapi { | 25 namespace fileapi { |
26 | 26 |
27 class FileSystemCallbackDispatcher; | 27 class FileSystemCallbackDispatcher; |
28 class FileSystemContext; | 28 class FileSystemContext; |
29 class FileSystemFileUtil; | |
30 class FileSystemOperation; | 29 class FileSystemOperation; |
31 class FileSystemOperationContext; | 30 class FileSystemOperationContext; |
32 class FileSystemPathManager; | 31 class FileSystemPathManager; |
| 32 class FileUtil; |
33 | 33 |
34 // Filesystem test helper class that encapsulates test environment for | 34 // Filesystem test helper class that encapsulates test environment for |
35 // a given {origin, type} pair. | 35 // a given {origin, type} pair. |
36 class FileSystemTestOriginHelper { | 36 class FileSystemTestOriginHelper { |
37 public: | 37 public: |
38 FileSystemTestOriginHelper(const GURL& origin, FileSystemType type); | 38 FileSystemTestOriginHelper(const GURL& origin, FileSystemType type); |
39 FileSystemTestOriginHelper(); | 39 FileSystemTestOriginHelper(); |
40 ~FileSystemTestOriginHelper(); | 40 ~FileSystemTestOriginHelper(); |
41 | 41 |
42 void SetUp(const FilePath& base_dir, FileSystemFileUtil* file_util); | 42 void SetUp(const FilePath& base_dir, FileUtil* file_util); |
43 // If you want to use more than one FileSystemTestOriginHelper in a single | 43 // If you want to use more than one FileSystemTestOriginHelper in a single |
44 // base directory, they have to share a context, so that they don't have | 44 // base directory, they have to share a context, so that they don't have |
45 // multiple databases fighting over the lock to the origin directory [deep | 45 // multiple databases fighting over the lock to the origin directory [deep |
46 // down inside ObfuscatedFileSystemFileUtil]. | 46 // down inside ObfuscatedFileUtil]. |
47 void SetUp(FileSystemContext* file_system_context, | 47 void SetUp(FileSystemContext* file_system_context, FileUtil* file_util); |
48 FileSystemFileUtil* file_util); | |
49 void SetUp(const FilePath& base_dir, | 48 void SetUp(const FilePath& base_dir, |
50 bool incognito_mode, | 49 bool incognito_mode, |
51 bool unlimited_quota, | 50 bool unlimited_quota, |
52 quota::QuotaManagerProxy* quota_manager_proxy, | 51 quota::QuotaManagerProxy* quota_manager_proxy, |
53 FileSystemFileUtil* file_util); | 52 FileUtil* file_util); |
54 void TearDown(); | 53 void TearDown(); |
55 | 54 |
56 FilePath GetOriginRootPath() const; | 55 FilePath GetOriginRootPath() const; |
57 FilePath GetLocalPath(const FilePath& path); | 56 FilePath GetLocalPath(const FilePath& path); |
58 FilePath GetLocalPathFromASCII(const std::string& path); | 57 FilePath GetLocalPathFromASCII(const std::string& path); |
59 GURL GetURLForPath(const FilePath& path) const; | 58 GURL GetURLForPath(const FilePath& path) const; |
60 FilePath GetUsageCachePath() const; | 59 FilePath GetUsageCachePath() const; |
61 | 60 |
62 int64 GetCachedOriginUsage() const; | 61 int64 GetCachedOriginUsage() const; |
63 bool RevokeUsageCache() const; | 62 bool RevokeUsageCache() const; |
64 int64 ComputeCurrentOriginUsage() const; | 63 int64 ComputeCurrentOriginUsage() const; |
65 | 64 |
66 FileSystemOperation* NewOperation( | 65 FileSystemOperation* NewOperation( |
67 FileSystemCallbackDispatcher* callback_dispatcher); | 66 FileSystemCallbackDispatcher* callback_dispatcher); |
68 FileSystemOperationContext* NewOperationContext(); | 67 FileSystemOperationContext* NewOperationContext(); |
69 | 68 |
70 FileSystemContext* file_system_context() const { | 69 FileSystemContext* file_system_context() const { |
71 return file_system_context_.get(); | 70 return file_system_context_.get(); |
72 } | 71 } |
73 | 72 |
74 const GURL& origin() const { return origin_; } | 73 const GURL& origin() const { return origin_; } |
75 FileSystemType type() const { return type_; } | 74 FileSystemType type() const { return type_; } |
76 quota::StorageType storage_type() const { | 75 quota::StorageType storage_type() const { |
77 return FileSystemTypeToQuotaStorageType(type_); | 76 return FileSystemTypeToQuotaStorageType(type_); |
78 } | 77 } |
79 FileSystemFileUtil* file_util() { return file_util_; } | 78 FileUtil* file_util() { return file_util_; } |
80 | 79 |
81 private: | 80 private: |
82 void InitializeOperationContext(FileSystemOperationContext* context); | 81 void InitializeOperationContext(FileSystemOperationContext* context); |
83 | 82 |
84 scoped_refptr<FileSystemContext> file_system_context_; | 83 scoped_refptr<FileSystemContext> file_system_context_; |
85 const GURL origin_; | 84 const GURL origin_; |
86 const FileSystemType type_; | 85 const FileSystemType type_; |
87 FileSystemFileUtil* file_util_; | 86 FileUtil* file_util_; |
88 int64 initial_usage_size_; | 87 int64 initial_usage_size_; |
89 }; | 88 }; |
90 | 89 |
91 } // namespace fileapi | 90 } // namespace fileapi |
92 | 91 |
93 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_TEST_HELPER_H_ | 92 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_TEST_HELPER_H_ |
OLD | NEW |