Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: webkit/browser/fileapi/sandbox_file_system_backend.h

Issue 21116008: FileAPI: Move FileSystemQuotaUtil related functions into SandboxContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ 6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 #include "webkit/browser/fileapi/file_system_backend.h" 18 #include "webkit/browser/fileapi/file_system_backend.h"
19 #include "webkit/browser/fileapi/file_system_options.h"
20 #include "webkit/browser/fileapi/file_system_quota_util.h" 19 #include "webkit/browser/fileapi/file_system_quota_util.h"
20 #include "webkit/browser/fileapi/sandbox_context.h"
21 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" 21 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
22 #include "webkit/browser/quota/special_storage_policy.h" 22 #include "webkit/browser/quota/special_storage_policy.h"
23 #include "webkit/browser/webkit_storage_browser_export.h" 23 #include "webkit/browser/webkit_storage_browser_export.h"
24 24
25 namespace base { 25 namespace base {
26 class SequencedTaskRunner; 26 class SequencedTaskRunner;
27 } 27 }
28 28
29 namespace quota { 29 namespace quota {
30 class QuotaManagerProxy; 30 class QuotaManagerProxy;
(...skipping 15 matching lines...) Expand all
46 46
47 // An interface to construct or crack sandboxed filesystem paths for 47 // An interface to construct or crack sandboxed filesystem paths for
48 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's 48 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's
49 // profile directory in a sandboxed way. 49 // profile directory in a sandboxed way.
50 // This interface also lets one enumerate and remove storage for the origins 50 // This interface also lets one enumerate and remove storage for the origins
51 // that use the filesystem. 51 // that use the filesystem.
52 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend 52 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend
53 : public FileSystemBackend, 53 : public FileSystemBackend,
54 public FileSystemQuotaUtil { 54 public FileSystemQuotaUtil {
55 public: 55 public:
56 // Origin enumerator interface. 56 SandboxFileSystemBackend(SandboxContext* sandbox_context);
57 // An instance of this interface is assumed to be called on the file thread.
58 class OriginEnumerator {
59 public:
60 virtual ~OriginEnumerator() {}
61
62 // Returns the next origin. Returns empty if there are no more origins.
63 virtual GURL Next() = 0;
64
65 // Returns the current origin's information.
66 virtual bool HasFileSystemType(FileSystemType type) const = 0;
67 };
68
69 SandboxFileSystemBackend(
70 SandboxContext* sandbox_context,
71 const FileSystemOptions& file_system_options);
72 virtual ~SandboxFileSystemBackend(); 57 virtual ~SandboxFileSystemBackend();
73 58
74 // FileSystemBackend overrides. 59 // FileSystemBackend overrides.
75 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; 60 virtual bool CanHandleType(FileSystemType type) const OVERRIDE;
76 virtual void Initialize(FileSystemContext* context) OVERRIDE; 61 virtual void Initialize(FileSystemContext* context) OVERRIDE;
77 virtual void OpenFileSystem( 62 virtual void OpenFileSystem(
78 const GURL& origin_url, 63 const GURL& origin_url,
79 FileSystemType type, 64 FileSystemType type,
80 OpenFileSystemMode mode, 65 OpenFileSystemMode mode,
81 const OpenFileSystemCallback& callback) OVERRIDE; 66 const OpenFileSystemCallback& callback) OVERRIDE;
(...skipping 12 matching lines...) Expand all
94 const base::Time& expected_modification_time, 79 const base::Time& expected_modification_time,
95 FileSystemContext* context) const OVERRIDE; 80 FileSystemContext* context) const OVERRIDE;
96 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( 81 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
97 const FileSystemURL& url, 82 const FileSystemURL& url,
98 int64 offset, 83 int64 offset,
99 FileSystemContext* context) const OVERRIDE; 84 FileSystemContext* context) const OVERRIDE;
100 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; 85 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
101 86
102 // Returns an origin enumerator of this backend. 87 // Returns an origin enumerator of this backend.
103 // This method can only be called on the file thread. 88 // This method can only be called on the file thread.
104 OriginEnumerator* CreateOriginEnumerator(); 89 SandboxContext::OriginEnumerator* CreateOriginEnumerator();
105
106 // Gets a base directory path of the sandboxed filesystem that is
107 // specified by |origin_url| and |type|.
108 // (The path is similar to the origin's root path but doesn't contain
109 // the 'unique' part.)
110 // Returns an empty path if the given type is invalid.
111 // This method can only be called on the file thread.
112 base::FilePath GetBaseDirectoryForOriginAndType(
113 const GURL& origin_url,
114 FileSystemType type,
115 bool create);
116 90
117 // FileSystemQuotaUtil overrides. 91 // FileSystemQuotaUtil overrides.
118 virtual base::PlatformFileError DeleteOriginDataOnFileThread( 92 virtual base::PlatformFileError DeleteOriginDataOnFileThread(
119 FileSystemContext* context, 93 FileSystemContext* context,
120 quota::QuotaManagerProxy* proxy, 94 quota::QuotaManagerProxy* proxy,
121 const GURL& origin_url, 95 const GURL& origin_url,
122 FileSystemType type) OVERRIDE; 96 FileSystemType type) OVERRIDE;
123 virtual void GetOriginsForTypeOnFileThread( 97 virtual void GetOriginsForTypeOnFileThread(
124 FileSystemType type, 98 FileSystemType type,
125 std::set<GURL>* origins) OVERRIDE; 99 std::set<GURL>* origins) OVERRIDE;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 ObfuscatedFileUtil* sandbox_file_util, 156 ObfuscatedFileUtil* sandbox_file_util,
183 const GURL& origin_url, 157 const GURL& origin_url,
184 FileSystemType type, 158 FileSystemType type,
185 base::PlatformFileError* error_out); 159 base::PlatformFileError* error_out);
186 160
187 // Returns true if the given |url|'s scheme is allowed to access 161 // Returns true if the given |url|'s scheme is allowed to access
188 // filesystem. 162 // filesystem.
189 bool IsAllowedScheme(const GURL& url) const; 163 bool IsAllowedScheme(const GURL& url) const;
190 164
191 ObfuscatedFileUtil* sandbox_sync_file_util(); 165 ObfuscatedFileUtil* sandbox_sync_file_util();
192 FileSystemUsageCache* usage_cache();
193
194 static void InvalidateUsageCacheOnFileThread(
195 ObfuscatedFileUtil* file_util,
196 const GURL& origin,
197 FileSystemType type,
198 FileSystemUsageCache* usage_cache);
199
200 int64 RecalculateUsage(FileSystemContext* context,
201 const GURL& origin,
202 FileSystemType type);
203 166
204 SandboxContext* sandbox_context_; // Not owned. 167 SandboxContext* sandbox_context_; // Not owned.
205 168
206 FileSystemOptions file_system_options_;
207 bool enable_temporary_file_system_in_incognito_; 169 bool enable_temporary_file_system_in_incognito_;
208 170
209 // Acccessed only on the file thread.
210 std::set<GURL> visited_origins_;
211
212 // Observers. 171 // Observers.
213 UpdateObserverList update_observers_; 172 UpdateObserverList update_observers_;
214 ChangeObserverList change_observers_; 173 ChangeObserverList change_observers_;
215 AccessObserverList access_observers_; 174 AccessObserverList access_observers_;
216 175
217 // Observers for syncable file systems. 176 // Observers for syncable file systems.
218 UpdateObserverList syncable_update_observers_; 177 UpdateObserverList syncable_update_observers_;
219 ChangeObserverList syncable_change_observers_; 178 ChangeObserverList syncable_change_observers_;
220 179
221 base::Time next_release_time_for_open_filesystem_stat_; 180 base::Time next_release_time_for_open_filesystem_stat_;
222 181
223 std::set<std::pair<GURL, FileSystemType> > sticky_dirty_origins_; 182 std::set<std::pair<GURL, FileSystemType> > sticky_dirty_origins_;
224 183
225 base::WeakPtrFactory<SandboxFileSystemBackend> weak_factory_; 184 base::WeakPtrFactory<SandboxFileSystemBackend> weak_factory_;
226 185
227 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); 186 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend);
228 }; 187 };
229 188
230 } // namespace fileapi 189 } // namespace fileapi
231 190
232 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ 191 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698