OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CONTEXT_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "webkit/quota/special_storage_policy.h" | 10 #include "webkit/quota/special_storage_policy.h" |
11 | 11 |
12 class FilePath; | 12 class FilePath; |
13 class GURL; | 13 class GURL; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class MessageLoopProxy; | 16 class MessageLoopProxy; |
17 } | 17 } |
18 | 18 |
| 19 namespace quota { |
| 20 class SpecialStoragePolicy; |
| 21 } |
| 22 |
19 namespace fileapi { | 23 namespace fileapi { |
20 | 24 |
21 class FileSystemPathManager; | 25 class FileSystemPathManager; |
22 class FileSystemQuotaManager; | |
23 class FileSystemUsageTracker; | 26 class FileSystemUsageTracker; |
24 class FileSystemContext; | 27 class FileSystemContext; |
25 | 28 |
26 struct DefaultContextDeleter; | 29 struct DefaultContextDeleter; |
27 | 30 |
28 // This class keeps and provides a file system context for FileSystem API. | 31 // This class keeps and provides a file system context for FileSystem API. |
29 class FileSystemContext | 32 class FileSystemContext |
30 : public base::RefCountedThreadSafe<FileSystemContext, | 33 : public base::RefCountedThreadSafe<FileSystemContext, |
31 DefaultContextDeleter> { | 34 DefaultContextDeleter> { |
32 public: | 35 public: |
33 FileSystemContext( | 36 FileSystemContext( |
34 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 37 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
35 scoped_refptr<base::MessageLoopProxy> io_message_loop, | 38 scoped_refptr<base::MessageLoopProxy> io_message_loop, |
36 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 39 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
37 const FilePath& profile_path, | 40 const FilePath& profile_path, |
38 bool is_incognito, | 41 bool is_incognito, |
39 bool allow_file_access_from_files, | 42 bool allow_file_access_from_files, |
40 bool unlimited_quota); | 43 bool unlimited_quota); |
41 ~FileSystemContext(); | 44 ~FileSystemContext(); |
42 | 45 |
| 46 // This method can be called on any thread. |
| 47 bool IsStorageUnlimited(const GURL& origin); |
| 48 |
43 void DeleteDataForOriginOnFileThread(const GURL& origin_url); | 49 void DeleteDataForOriginOnFileThread(const GURL& origin_url); |
44 | 50 |
45 FileSystemPathManager* path_manager() { return path_manager_.get(); } | 51 FileSystemPathManager* path_manager() { return path_manager_.get(); } |
46 FileSystemQuotaManager* quota_manager() { return quota_manager_.get(); } | |
47 FileSystemUsageTracker* usage_tracker() { return usage_tracker_.get(); } | 52 FileSystemUsageTracker* usage_tracker() { return usage_tracker_.get(); } |
48 | 53 |
49 private: | 54 private: |
50 friend struct DefaultContextDeleter; | 55 friend struct DefaultContextDeleter; |
51 void DeleteOnCorrectThread() const; | 56 void DeleteOnCorrectThread() const; |
52 | 57 |
53 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 58 scoped_refptr<base::MessageLoopProxy> file_message_loop_; |
54 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 59 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 60 |
| 61 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 62 const bool allow_file_access_from_files_; |
| 63 const bool unlimited_quota_; |
| 64 |
55 scoped_ptr<FileSystemPathManager> path_manager_; | 65 scoped_ptr<FileSystemPathManager> path_manager_; |
56 scoped_ptr<FileSystemQuotaManager> quota_manager_; | |
57 scoped_ptr<FileSystemUsageTracker> usage_tracker_; | 66 scoped_ptr<FileSystemUsageTracker> usage_tracker_; |
58 | 67 |
59 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); | 68 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); |
60 }; | 69 }; |
61 | 70 |
62 struct DefaultContextDeleter { | 71 struct DefaultContextDeleter { |
63 static void Destruct(const FileSystemContext* context) { | 72 static void Destruct(const FileSystemContext* context) { |
64 context->DeleteOnCorrectThread(); | 73 context->DeleteOnCorrectThread(); |
65 } | 74 } |
66 }; | 75 }; |
67 | 76 |
68 } // namespace fileapi | 77 } // namespace fileapi |
69 | 78 |
70 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 79 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
OLD | NEW |