Chromium Code Reviews| 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 SequencedTaskRunner; | |
|
michaeln
2012/04/27 22:31:08
nit(picky-nit): alpha ordering
kinuko
2012/05/04 19:05:35
Done.
| |
| 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 // |file_task_runner| is used for all file operations and file related | |
| 54 // meta operations. | |
| 55 // The code assumes that file_task_runner->RunsTasksOnCurrentThread() returns | |
| 56 // false if the current task is not running on the thread that allows | |
|
michaeln
2012/04/27 22:31:08
fyi: the semantics/implemetation of RunsTasksOnCur
kinuko
2012/05/04 19:05:35
Yes, I had read this comment and how they are impl
| |
| 57 // blocking file operations (like SequencedWorkerPool implementation does). | |
| 52 FileSystemContext( | 58 FileSystemContext( |
| 53 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 59 base::SequencedTaskRunner* file_task_runner, |
| 54 scoped_refptr<base::MessageLoopProxy> io_message_loop, | 60 base::SingleThreadTaskRunner* io_task_runner, |
| 55 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 61 quota::SpecialStoragePolicy* special_storage_policy, |
| 56 quota::QuotaManagerProxy* quota_manager_proxy, | 62 quota::QuotaManagerProxy* quota_manager_proxy, |
| 57 const FilePath& profile_path, | 63 const FilePath& profile_path, |
| 58 const FileSystemOptions& options); | 64 const FileSystemOptions& options); |
| 59 ~FileSystemContext(); | 65 ~FileSystemContext(); |
| 60 | 66 |
| 61 // This method can be called on any thread. | 67 // This method can be called on any thread. |
|
michaeln
2012/04/27 22:31:08
Is this this comment correct? DCHECKs in the metho
ericu
2012/05/01 00:30:35
It used to go with IsStorageUnlimited, and should
kinuko
2012/05/04 19:05:35
Done.
| |
| 62 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); | 68 bool DeleteDataForOriginOnFileThread(const GURL& origin_url); |
| 63 bool DeleteDataForOriginAndTypeOnFileThread(const GURL& origin_url, | 69 bool DeleteDataForOriginAndTypeOnFileThread(const GURL& origin_url, |
| 64 FileSystemType type); | 70 FileSystemType type); |
| 65 | 71 |
| 66 quota::QuotaManagerProxy* quota_manager_proxy() const { | 72 quota::QuotaManagerProxy* quota_manager_proxy() const { |
| 67 return quota_manager_proxy_.get(); | 73 return quota_manager_proxy_.get(); |
| 68 } | 74 } |
| 69 | 75 |
| 70 // Returns a quota util for a given filesystem type. This may | 76 // Returns a quota util for a given filesystem type. This may |
| 71 // return NULL if the type does not support the usage tracking or | 77 // return NULL if the type does not support the usage tracking or |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 const GURL& origin_url, | 113 const GURL& origin_url, |
| 108 FileSystemType type, | 114 FileSystemType type, |
| 109 bool create, | 115 bool create, |
| 110 OpenFileSystemCallback callback); | 116 OpenFileSystemCallback callback); |
| 111 | 117 |
| 112 // Creates a new FileSystemOperation instance by cracking | 118 // Creates a new FileSystemOperation instance by cracking |
| 113 // the given filesystem URL |url| to get an appropriate MountPointProvider | 119 // the given filesystem URL |url| to get an appropriate MountPointProvider |
| 114 // and calling the provider's corresponding CreateFileSystemOperation method. | 120 // and calling the provider's corresponding CreateFileSystemOperation method. |
| 115 // The resolved MountPointProvider could perform further specialization | 121 // The resolved MountPointProvider could perform further specialization |
| 116 // depending on the filesystem type pointed by the |url|. | 122 // depending on the filesystem type pointed by the |url|. |
| 117 FileSystemOperationInterface* CreateFileSystemOperation( | 123 FileSystemOperationInterface* CreateFileSystemOperation(const GURL& url); |
| 118 const GURL& url, | |
| 119 base::MessageLoopProxy* file_proxy); | |
| 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); | |
| 131 | 134 |
| 132 private: | 135 private: |
| 133 friend struct DefaultContextDeleter; | 136 friend struct DefaultContextDeleter; |
| 134 void DeleteOnCorrectThread() const; | 137 void DeleteOnCorrectThread() const; |
| 135 | 138 |
| 136 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 139 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 137 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 140 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 138 | 141 |
| 139 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 142 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 140 | 143 |
| 141 // Mount point providers. | 144 // Mount point providers. |
| 142 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; | 145 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; |
| 143 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; | 146 scoped_ptr<IsolatedMountPointProvider> isolated_provider_; |
| 144 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; | 147 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; |
| 145 | 148 |
| 146 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); | 149 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); |
| 147 }; | 150 }; |
| 148 | 151 |
| 149 struct DefaultContextDeleter { | 152 struct DefaultContextDeleter { |
| 150 static void Destruct(const FileSystemContext* context) { | 153 static void Destruct(const FileSystemContext* context) { |
| 151 context->DeleteOnCorrectThread(); | 154 context->DeleteOnCorrectThread(); |
| 152 } | 155 } |
| 153 }; | 156 }; |
| 154 | 157 |
| 155 } // namespace fileapi | 158 } // namespace fileapi |
| 156 | 159 |
| 157 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 160 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| OLD | NEW |