Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / storage / browser / fileapi / plugin_private_file_system_backend.h
blob72599fae73d8ad5feb720ae72f7cc434545566eb
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef STORAGE_BROWSER_FILEAPI_PLUGIN_PRIVATE_FILE_SYSTEM_BACKEND_H_
6 #define STORAGE_BROWSER_FILEAPI_PLUGIN_PRIVATE_FILE_SYSTEM_BACKEND_H_
8 #include <set>
9 #include <string>
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "storage/browser/fileapi/file_system_backend.h"
14 #include "storage/browser/fileapi/file_system_options.h"
15 #include "storage/browser/fileapi/file_system_quota_util.h"
16 #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
18 namespace base {
19 class SequencedTaskRunner;
22 namespace content {
23 class PluginPrivateFileSystemBackendTest;
26 namespace storage {
27 class SpecialStoragePolicy;
30 namespace storage {
32 class ObfuscatedFileUtil;
33 class WatcherManager;
35 class STORAGE_EXPORT PluginPrivateFileSystemBackend
36 : public FileSystemBackend,
37 public FileSystemQuotaUtil {
38 public:
39 class FileSystemIDToPluginMap;
40 typedef base::Callback<void(base::File::Error result)> StatusCallback;
42 PluginPrivateFileSystemBackend(
43 base::SequencedTaskRunner* file_task_runner,
44 const base::FilePath& profile_path,
45 storage::SpecialStoragePolicy* special_storage_policy,
46 const FileSystemOptions& file_system_options);
47 ~PluginPrivateFileSystemBackend() override;
49 // This must be used to open 'private' filesystem instead of regular
50 // OpenFileSystem.
51 // |plugin_id| must be an identifier string for per-plugin
52 // isolation, e.g. name, MIME type etc.
53 // NOTE: |plugin_id| must be sanitized ASCII string that doesn't
54 // include *any* dangerous character like '/'.
55 void OpenPrivateFileSystem(
56 const GURL& origin_url,
57 FileSystemType type,
58 const std::string& filesystem_id,
59 const std::string& plugin_id,
60 OpenFileSystemMode mode,
61 const StatusCallback& callback);
63 // FileSystemBackend overrides.
64 bool CanHandleType(FileSystemType type) const override;
65 void Initialize(FileSystemContext* context) override;
66 void ResolveURL(const FileSystemURL& url,
67 OpenFileSystemMode mode,
68 const OpenFileSystemCallback& callback) override;
69 AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) override;
70 WatcherManager* GetWatcherManager(FileSystemType type) override;
71 CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
72 FileSystemType type,
73 base::File::Error* error_code) override;
74 FileSystemOperation* CreateFileSystemOperation(
75 const FileSystemURL& url,
76 FileSystemContext* context,
77 base::File::Error* error_code) const override;
78 bool SupportsStreaming(const FileSystemURL& url) const override;
79 bool HasInplaceCopyImplementation(
80 storage::FileSystemType type) const override;
81 scoped_ptr<storage::FileStreamReader> CreateFileStreamReader(
82 const FileSystemURL& url,
83 int64 offset,
84 int64 max_bytes_to_read,
85 const base::Time& expected_modification_time,
86 FileSystemContext* context) const override;
87 scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
88 const FileSystemURL& url,
89 int64 offset,
90 FileSystemContext* context) const override;
91 FileSystemQuotaUtil* GetQuotaUtil() override;
92 const UpdateObserverList* GetUpdateObservers(
93 FileSystemType type) const override;
94 const ChangeObserverList* GetChangeObservers(
95 FileSystemType type) const override;
96 const AccessObserverList* GetAccessObservers(
97 FileSystemType type) const override;
99 // FileSystemQuotaUtil overrides.
100 base::File::Error DeleteOriginDataOnFileTaskRunner(
101 FileSystemContext* context,
102 storage::QuotaManagerProxy* proxy,
103 const GURL& origin_url,
104 FileSystemType type) override;
105 void GetOriginsForTypeOnFileTaskRunner(FileSystemType type,
106 std::set<GURL>* origins) override;
107 void GetOriginsForHostOnFileTaskRunner(FileSystemType type,
108 const std::string& host,
109 std::set<GURL>* origins) override;
110 int64 GetOriginUsageOnFileTaskRunner(FileSystemContext* context,
111 const GURL& origin_url,
112 FileSystemType type) override;
113 scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner(
114 const GURL& origin_url,
115 FileSystemType type) override;
117 private:
118 friend class content::PluginPrivateFileSystemBackendTest;
120 ObfuscatedFileUtil* obfuscated_file_util();
121 const base::FilePath& base_path() const { return base_path_; }
123 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
124 const FileSystemOptions file_system_options_;
125 const base::FilePath base_path_;
126 scoped_ptr<AsyncFileUtil> file_util_;
127 FileSystemIDToPluginMap* plugin_map_; // Owned by file_util_.
128 base::WeakPtrFactory<PluginPrivateFileSystemBackend> weak_factory_;
130 DISALLOW_COPY_AND_ASSIGN(PluginPrivateFileSystemBackend);
133 } // namespace storage
135 #endif // STORAGE_BROWSER_FILEAPI_PLUGIN_PRIVATE_FILE_SYSTEM_BACKEND_H_