| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ | |
| 6 #define WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "googleurl/src/gurl.h" | |
| 13 #include "webkit/fileapi/file_system_types.h" | |
| 14 #include "webkit/fileapi/file_system_url.h" | |
| 15 #include "webkit/fileapi/file_system_usage_cache.h" | |
| 16 #include "webkit/fileapi/file_system_util.h" | |
| 17 #include "webkit/quota/quota_types.h" | |
| 18 | |
| 19 namespace base { | |
| 20 class FilePath; | |
| 21 } | |
| 22 | |
| 23 namespace quota { | |
| 24 class QuotaManagerProxy; | |
| 25 } | |
| 26 | |
| 27 namespace fileapi { | |
| 28 | |
| 29 class FileSystemContext; | |
| 30 class FileSystemFileUtil; | |
| 31 class FileSystemOperationContext; | |
| 32 class LocalFileSystemOperation; | |
| 33 | |
| 34 // Filesystem test helper class that encapsulates test environment for | |
| 35 // a given {origin, type} pair. This helper only works for sandboxed | |
| 36 // file systems (Temporary, Persistent or Test types). | |
| 37 class LocalFileSystemTestOriginHelper { | |
| 38 public: | |
| 39 LocalFileSystemTestOriginHelper(const GURL& origin, FileSystemType type); | |
| 40 LocalFileSystemTestOriginHelper(); | |
| 41 ~LocalFileSystemTestOriginHelper(); | |
| 42 | |
| 43 void SetUp(const base::FilePath& base_dir); | |
| 44 // If you want to use more than one LocalFileSystemTestOriginHelper in | |
| 45 // a single base directory, they have to share a context, so that they don't | |
| 46 // have multiple databases fighting over the lock to the origin directory | |
| 47 // [deep down inside ObfuscatedFileUtil]. | |
| 48 void SetUp(FileSystemContext* file_system_context); | |
| 49 void SetUp(const base::FilePath& base_dir, | |
| 50 quota::QuotaManagerProxy* quota_manager_proxy); | |
| 51 void TearDown(); | |
| 52 | |
| 53 base::FilePath GetOriginRootPath() const; | |
| 54 base::FilePath GetLocalPath(const base::FilePath& path); | |
| 55 base::FilePath GetLocalPathFromASCII(const std::string& path); | |
| 56 | |
| 57 // Returns empty path if filesystem type is neither temporary nor persistent. | |
| 58 base::FilePath GetUsageCachePath() const; | |
| 59 | |
| 60 FileSystemURL CreateURL(const base::FilePath& path) const; | |
| 61 FileSystemURL CreateURLFromUTF8(const std::string& utf8) const { | |
| 62 return CreateURL(base::FilePath::FromUTF8Unsafe(utf8)); | |
| 63 } | |
| 64 | |
| 65 // This returns cached usage size returned by QuotaUtil. | |
| 66 int64 GetCachedOriginUsage() const; | |
| 67 | |
| 68 // This doesn't work with OFSFU. | |
| 69 int64 ComputeCurrentOriginUsage(); | |
| 70 | |
| 71 int64 ComputeCurrentDirectoryDatabaseUsage() const; | |
| 72 | |
| 73 LocalFileSystemOperation* NewOperation(); | |
| 74 FileSystemOperationContext* NewOperationContext(); | |
| 75 | |
| 76 FileSystemContext* file_system_context() const { | |
| 77 return file_system_context_.get(); | |
| 78 } | |
| 79 | |
| 80 const GURL& origin() const { return origin_; } | |
| 81 FileSystemType type() const { return type_; } | |
| 82 quota::StorageType storage_type() const { | |
| 83 return FileSystemTypeToQuotaStorageType(type_); | |
| 84 } | |
| 85 FileSystemFileUtil* file_util() const { return file_util_; } | |
| 86 FileSystemUsageCache* usage_cache(); | |
| 87 | |
| 88 private: | |
| 89 void SetUpFileUtil(); | |
| 90 | |
| 91 scoped_refptr<FileSystemContext> file_system_context_; | |
| 92 | |
| 93 const GURL origin_; | |
| 94 const FileSystemType type_; | |
| 95 FileSystemFileUtil* file_util_; | |
| 96 }; | |
| 97 | |
| 98 } // namespace fileapi | |
| 99 | |
| 100 #endif // WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_TEST_HELPER_H_ | |
| OLD | NEW |