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_SANDBOXED_FILE_SYSTEM_CONTEXT_H_ | 5 #ifndef WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_CONTEXT_H_ |
6 #define WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_CONTEXT_H_ | 6 #define WEBKIT_FILEAPI_SANDBOXED_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 | 10 |
11 class FilePath; | 11 class FilePath; |
12 class GURL; | 12 class GURL; |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class MessageLoopProxy; | 15 class MessageLoopProxy; |
16 } | 16 } |
17 | 17 |
18 namespace fileapi { | 18 namespace fileapi { |
19 | 19 |
20 class FileSystemPathManager; | 20 class FileSystemPathManager; |
21 class FileSystemQuotaManager; | 21 class FileSystemQuotaManager; |
22 class SandboxedFileSystemContext; | 22 class SandboxedFileSystemContext; |
23 | 23 |
24 struct DefaultContextDeleter; | 24 struct DefaultContextDeleter; |
25 | 25 |
26 // This class keeps and provides a sandboxed file system context. | 26 // This class keeps and provides a sandboxed file system context. |
27 class SandboxedFileSystemContext { | 27 class SandboxedFileSystemContext |
| 28 : public base::RefCountedThreadSafe<SandboxedFileSystemContext, |
| 29 DefaultContextDeleter> { |
28 public: | 30 public: |
29 SandboxedFileSystemContext( | 31 SandboxedFileSystemContext( |
30 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 32 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 33 scoped_refptr<base::MessageLoopProxy> io_message_loop, |
31 const FilePath& profile_path, | 34 const FilePath& profile_path, |
32 bool is_incognito, | 35 bool is_incognito, |
33 bool allow_file_access_from_files, | 36 bool allow_file_access_from_files, |
34 bool unlimited_quota); | 37 bool unlimited_quota); |
35 ~SandboxedFileSystemContext(); | 38 ~SandboxedFileSystemContext(); |
36 | 39 |
37 void Shutdown(); | 40 void Shutdown(); |
38 | 41 |
39 void DeleteDataForOriginOnFileThread(const GURL& origin_url); | 42 void DeleteDataForOriginOnFileThread(const GURL& origin_url); |
40 | 43 |
| 44 // Quota related methods. |
| 45 void SetOriginQuotaUnlimited(const GURL& url); |
| 46 void ResetOriginQuotaUnlimited(const GURL& url); |
| 47 |
41 FileSystemPathManager* path_manager() { return path_manager_.get(); } | 48 FileSystemPathManager* path_manager() { return path_manager_.get(); } |
42 FileSystemQuotaManager* quota_manager() { return quota_manager_.get(); } | 49 FileSystemQuotaManager* quota_manager() { return quota_manager_.get(); } |
43 | 50 |
44 private: | 51 private: |
45 friend struct DefaultContextDeleter; | 52 friend struct DefaultContextDeleter; |
46 void DeleteOnCorrectThread() const; | 53 void DeleteOnCorrectThread() const; |
47 | 54 |
48 bool allow_file_access_from_files_; | 55 bool allow_file_access_from_files_; |
49 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 56 scoped_refptr<base::MessageLoopProxy> file_message_loop_; |
| 57 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
50 scoped_ptr<FileSystemPathManager> path_manager_; | 58 scoped_ptr<FileSystemPathManager> path_manager_; |
51 scoped_ptr<FileSystemQuotaManager> quota_manager_; | 59 scoped_ptr<FileSystemQuotaManager> quota_manager_; |
52 | 60 |
53 DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxedFileSystemContext); | 61 DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxedFileSystemContext); |
54 }; | 62 }; |
55 | 63 |
| 64 struct DefaultContextDeleter { |
| 65 static void Destruct(const SandboxedFileSystemContext* context) { |
| 66 context->DeleteOnCorrectThread(); |
| 67 } |
| 68 }; |
| 69 |
56 } // namespace fileapi | 70 } // namespace fileapi |
57 | 71 |
58 #endif // WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_CONTEXT_H_ | 72 #endif // WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_CONTEXT_H_ |
OLD | NEW |