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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
14 #include "webkit/fileapi/file_system_types.h" | 14 #include "webkit/fileapi/file_system_types.h" |
15 #include "webkit/quota/special_storage_policy.h" | 15 #include "webkit/quota/special_storage_policy.h" |
16 | 16 |
17 class FilePath; | 17 class FilePath; |
18 class GURL; | 18 class GURL; |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class MessageLoopProxy; | 21 class SingleThreadTaskRunner; |
22 class TaskRunner; | |
22 } | 23 } |
23 | 24 |
24 namespace quota { | 25 namespace quota { |
25 class QuotaManagerProxy; | 26 class QuotaManagerProxy; |
26 } | 27 } |
27 | 28 |
28 namespace webkit_blob { | 29 namespace webkit_blob { |
29 class FileReader; | 30 class FileReader; |
30 } | 31 } |
31 | 32 |
(...skipping 10 matching lines...) Expand all Loading... | |
42 class SandboxMountPointProvider; | 43 class SandboxMountPointProvider; |
43 | 44 |
44 struct DefaultContextDeleter; | 45 struct DefaultContextDeleter; |
45 | 46 |
46 // This class keeps and provides a file system context for FileSystem API. | 47 // This class keeps and provides a file system context for FileSystem API. |
47 // An instance of this class is created and owned by profile. | 48 // An instance of this class is created and owned by profile. |
48 class FileSystemContext | 49 class FileSystemContext |
49 : public base::RefCountedThreadSafe<FileSystemContext, | 50 : public base::RefCountedThreadSafe<FileSystemContext, |
50 DefaultContextDeleter> { | 51 DefaultContextDeleter> { |
51 public: | 52 public: |
53 // Given |file_task_runner| may be used for internal initialization and | |
54 // finalization by mount point providers. | |
55 // |io_task_runner| is used only for the final destruction. | |
52 FileSystemContext( | 56 FileSystemContext( |
53 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 57 base::SingleThreadTaskRunner* file_task_runner, |
michaeln
2012/04/27 01:04:03
If the intent is to eventually put these tasks on
kinuko
2012/04/27 10:10:29
I wanted to do so but couldn't find the nice RunsT
| |
54 scoped_refptr<base::MessageLoopProxy> io_message_loop, | 58 base::SingleThreadTaskRunner* io_task_runner, |
55 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 59 quota::SpecialStoragePolicy* special_storage_policy, |
56 quota::QuotaManagerProxy* quota_manager_proxy, | 60 quota::QuotaManagerProxy* quota_manager_proxy, |
57 const FilePath& profile_path, | 61 const FilePath& profile_path, |
58 const FileSystemOptions& options); | 62 const FileSystemOptions& options); |
59 ~FileSystemContext(); | 63 ~FileSystemContext(); |
60 | 64 |
61 // This method can be called on any thread. | 65 // This method can be called on any thread. |
62 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); | 66 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); |
63 bool DeleteDataForOriginAndTypeOnFileThread(const GURL& origin_url, | 67 bool DeleteDataForOriginAndTypeOnFileThread(const GURL& origin_url, |
64 FileSystemType type); | 68 FileSystemType type); |
65 | 69 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 bool create, | 113 bool create, |
110 OpenFileSystemCallback callback); | 114 OpenFileSystemCallback callback); |
111 | 115 |
112 // Creates a new FileSystemOperation instance by cracking | 116 // Creates a new FileSystemOperation instance by cracking |
113 // the given filesystem URL |url| to get an appropriate MountPointProvider | 117 // the given filesystem URL |url| to get an appropriate MountPointProvider |
114 // and calling the provider's corresponding CreateFileSystemOperation method. | 118 // and calling the provider's corresponding CreateFileSystemOperation method. |
115 // The resolved MountPointProvider could perform further specialization | 119 // The resolved MountPointProvider could perform further specialization |
116 // depending on the filesystem type pointed by the |url|. | 120 // depending on the filesystem type pointed by the |url|. |
117 FileSystemOperationInterface* CreateFileSystemOperation( | 121 FileSystemOperationInterface* CreateFileSystemOperation( |
118 const GURL& url, | 122 const GURL& url, |
119 base::MessageLoopProxy* file_proxy); | 123 base::TaskRunner* file_task_runner); |
michaeln
2012/04/27 01:04:03
Since an operation may involve multiple steps, wou
kinuko
2012/04/27 10:10:29
Done. (Removed this parameter in favor of using t
| |
120 | 124 |
121 // Creates new FileReader instance to read a file pointed by the given | 125 // Creates new FileReader instance to read a file pointed by the given |
122 // filesystem URL |url| starting from |offset|. | 126 // filesystem URL |url| starting from |offset|. |
123 // This method internally cracks the |url|, get an appropriate | 127 // This method internally cracks the |url|, get an appropriate |
124 // MountPointProvider for the URL and call the provider's CreateFileReader. | 128 // MountPointProvider for the URL and call the provider's CreateFileReader. |
125 // The resolved MountPointProvider could perform further specialization | 129 // The resolved MountPointProvider could perform further specialization |
126 // depending on the filesystem type pointed by the |url|. | 130 // depending on the filesystem type pointed by the |url|. |
127 webkit_blob::FileReader* CreateFileReader( | 131 webkit_blob::FileReader* CreateFileReader( |
128 const GURL& url, | 132 const GURL& url, |
129 int64 offset, | 133 int64 offset, |
130 base::MessageLoopProxy* file_proxy); | 134 base::TaskRunner* file_task_runner); |
michaeln
2012/04/27 01:04:03
ditto
kinuko
2012/04/27 10:10:29
Done.
| |
131 | 135 |
132 private: | 136 private: |
133 friend struct DefaultContextDeleter; | 137 friend struct DefaultContextDeleter; |
134 void DeleteOnCorrectThread() const; | 138 void DeleteOnCorrectThread() const; |
135 | 139 |
136 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 140 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
137 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 141 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
138 | 142 |
139 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 143 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
140 | 144 |
141 // Mount point providers. | 145 // Mount point providers. |
142 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; | 146 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; |
143 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; | 147 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; |
144 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; | 148 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; |
145 | 149 |
146 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); | 150 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); |
147 }; | 151 }; |
148 | 152 |
149 struct DefaultContextDeleter { | 153 struct DefaultContextDeleter { |
150 static void Destruct(const FileSystemContext* context) { | 154 static void Destruct(const FileSystemContext* context) { |
151 context->DeleteOnCorrectThread(); | 155 context->DeleteOnCorrectThread(); |
152 } | 156 } |
153 }; | 157 }; |
154 | 158 |
155 } // namespace fileapi | 159 } // namespace fileapi |
156 | 160 |
157 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 161 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
OLD | NEW |