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_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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.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 "base/platform_file.h" | 14 #include "base/platform_file.h" |
15 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.h" |
| 16 #include "webkit/fileapi/fileapi_export.h" |
16 #include "webkit/fileapi/file_system_types.h" | 17 #include "webkit/fileapi/file_system_types.h" |
17 #include "webkit/quota/special_storage_policy.h" | 18 #include "webkit/quota/special_storage_policy.h" |
18 | 19 |
19 class FilePath; | 20 class FilePath; |
20 class GURL; | 21 class GURL; |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
24 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
25 } | 26 } |
(...skipping 15 matching lines...) Expand all Loading... |
41 class FileSystemOptions; | 42 class FileSystemOptions; |
42 class FileSystemPathManager; | 43 class FileSystemPathManager; |
43 class FileSystemQuotaUtil; | 44 class FileSystemQuotaUtil; |
44 class IsolatedMountPointProvider; | 45 class IsolatedMountPointProvider; |
45 class SandboxMountPointProvider; | 46 class SandboxMountPointProvider; |
46 | 47 |
47 struct DefaultContextDeleter; | 48 struct DefaultContextDeleter; |
48 | 49 |
49 // This class keeps and provides a file system context for FileSystem API. | 50 // This class keeps and provides a file system context for FileSystem API. |
50 // An instance of this class is created and owned by profile. | 51 // An instance of this class is created and owned by profile. |
51 class FileSystemContext | 52 class FILEAPI_EXPORT FileSystemContext |
52 : public base::RefCountedThreadSafe<FileSystemContext, | 53 : public base::RefCountedThreadSafe<FileSystemContext, |
53 DefaultContextDeleter> { | 54 DefaultContextDeleter> { |
54 public: | 55 public: |
55 // |file_task_runner| is used for all file operations and file related | 56 // |file_task_runner| is used for all file operations and file related |
56 // meta operations. | 57 // meta operations. |
57 // The code assumes that file_task_runner->RunsTasksOnCurrentThread() returns | 58 // The code assumes that file_task_runner->RunsTasksOnCurrentThread() returns |
58 // false if the current task is not running on the thread that allows | 59 // false if the current task is not running on the thread that allows |
59 // blocking file operations (like SequencedWorkerPool implementation does). | 60 // blocking file operations (like SequencedWorkerPool implementation does). |
60 FileSystemContext( | 61 FileSystemContext( |
61 base::SequencedTaskRunner* file_task_runner, | 62 base::SequencedTaskRunner* file_task_runner, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int64 offset); | 138 int64 offset); |
138 | 139 |
139 // Register a filesystem provider. The ownership of |provider| is | 140 // Register a filesystem provider. The ownership of |provider| is |
140 // transferred to this instance. | 141 // transferred to this instance. |
141 void RegisterMountPointProvider(FileSystemType type, | 142 void RegisterMountPointProvider(FileSystemType type, |
142 FileSystemMountPointProvider* provider); | 143 FileSystemMountPointProvider* provider); |
143 | 144 |
144 private: | 145 private: |
145 friend struct DefaultContextDeleter; | 146 friend struct DefaultContextDeleter; |
146 friend class base::DeleteHelper<FileSystemContext>; | 147 friend class base::DeleteHelper<FileSystemContext>; |
| 148 friend class base::RefCountedThreadSafe<FileSystemContext, |
| 149 DefaultContextDeleter>; |
147 ~FileSystemContext(); | 150 ~FileSystemContext(); |
148 | 151 |
149 void DeleteOnCorrectThread() const; | 152 void DeleteOnCorrectThread() const; |
150 | 153 |
151 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 154 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
152 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 155 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
153 | 156 |
154 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 157 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
155 | 158 |
156 // Regular mount point providers. | 159 // Regular mount point providers. |
157 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; | 160 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; |
158 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; | 161 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; |
159 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; | 162 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; |
160 | 163 |
161 // Registered mount point providers. | 164 // Registered mount point providers. |
162 std::map<FileSystemType, FileSystemMountPointProvider*> provider_map_; | 165 std::map<FileSystemType, FileSystemMountPointProvider*> provider_map_; |
163 | 166 |
164 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); | 167 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); |
165 }; | 168 }; |
166 | 169 |
167 struct DefaultContextDeleter { | 170 struct DefaultContextDeleter { |
168 static void Destruct(const FileSystemContext* context) { | 171 static void Destruct(const FileSystemContext* context) { |
169 context->DeleteOnCorrectThread(); | 172 context->DeleteOnCorrectThread(); |
170 } | 173 } |
171 }; | 174 }; |
172 | 175 |
173 } // namespace fileapi | 176 } // namespace fileapi |
174 | 177 |
175 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 178 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
OLD | NEW |