Android media: VideoFrame should not store so many sync points.
[chromium-blink-merge.git] / content / browser / storage_partition_impl.h
blob717038e7afc93639b6785ba37c7a0da4842e3f2e
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_
6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/browser/appcache/chrome_appcache_service.h"
12 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
13 #include "content/browser/indexed_db/indexed_db_context_impl.h"
14 #include "content/browser/media/webrtc_identity_store.h"
15 #include "content/browser/service_worker/service_worker_context_wrapper.h"
16 #include "content/common/content_export.h"
17 #include "content/public/browser/storage_partition.h"
18 #include "webkit/browser/quota/special_storage_policy.h"
20 namespace content {
22 class StoragePartitionImpl : public StoragePartition {
23 public:
24 CONTENT_EXPORT virtual ~StoragePartitionImpl();
26 // Quota managed data uses a different bitmask for types than
27 // StoragePartition uses. This method generates that mask.
28 CONTENT_EXPORT static int GenerateQuotaClientMask(uint32 remove_mask);
30 CONTENT_EXPORT void OverrideQuotaManagerForTesting(
31 quota::QuotaManager* quota_manager);
32 CONTENT_EXPORT void OverrideSpecialStoragePolicyForTesting(
33 quota::SpecialStoragePolicy* special_storage_policy);
35 // StoragePartition interface.
36 virtual base::FilePath GetPath() OVERRIDE;
37 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
38 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE;
39 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
40 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
41 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
42 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
43 virtual DOMStorageContextWrapper* GetDOMStorageContext() OVERRIDE;
44 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE;
45 virtual ServiceWorkerContextWrapper* GetServiceWorkerContext() OVERRIDE;
47 virtual void ClearDataForOrigin(
48 uint32 remove_mask,
49 uint32 quota_storage_remove_mask,
50 const GURL& storage_origin,
51 net::URLRequestContextGetter* request_context_getter) OVERRIDE;
52 virtual void ClearData(uint32 remove_mask,
53 uint32 quota_storage_remove_mask,
54 const GURL& storage_origin,
55 const OriginMatcherFunction& origin_matcher,
56 const base::Time begin,
57 const base::Time end,
58 const base::Closure& callback) OVERRIDE;
60 WebRTCIdentityStore* GetWebRTCIdentityStore();
62 struct DataDeletionHelper;
63 struct QuotaManagedDataDeletionHelper;
65 private:
66 friend class StoragePartitionImplMap;
67 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache);
68 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
69 RemoveQuotaManagedDataForeverBoth);
70 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
71 RemoveQuotaManagedDataForeverOnlyTemporary);
72 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
73 RemoveQuotaManagedDataForeverOnlyPersistent);
74 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
75 RemoveQuotaManagedDataForeverNeither);
76 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
77 RemoveQuotaManagedDataForeverSpecificOrigin);
78 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
79 RemoveQuotaManagedDataForLastHour);
80 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
81 RemoveQuotaManagedDataForLastWeek);
82 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
83 RemoveQuotaManagedUnprotectedOrigins);
84 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
85 RemoveQuotaManagedProtectedSpecificOrigin);
86 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
87 RemoveQuotaManagedProtectedOrigins);
88 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
89 RemoveQuotaManagedIgnoreDevTools);
90 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieForever);
91 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieLastHour);
92 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
93 RemoveUnprotectedLocalStorageForever);
94 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
95 RemoveProtectedLocalStorageForever);
96 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
97 RemoveLocalStorageForLastWeek);
99 // The |partition_path| is the absolute path to the root of this
100 // StoragePartition's on-disk storage.
102 // If |in_memory| is true, the |partition_path| is (ab)used as a way of
103 // distinguishing different in-memory partitions, but nothing is persisted
104 // on to disk.
105 static StoragePartitionImpl* Create(BrowserContext* context,
106 bool in_memory,
107 const base::FilePath& profile_path);
109 CONTENT_EXPORT StoragePartitionImpl(
110 const base::FilePath& partition_path,
111 quota::QuotaManager* quota_manager,
112 ChromeAppCacheService* appcache_service,
113 fileapi::FileSystemContext* filesystem_context,
114 webkit_database::DatabaseTracker* database_tracker,
115 DOMStorageContextWrapper* dom_storage_context,
116 IndexedDBContextImpl* indexed_db_context,
117 ServiceWorkerContextWrapper* service_worker_context,
118 WebRTCIdentityStore* webrtc_identity_store,
119 quota::SpecialStoragePolicy* special_storage_policy);
121 void ClearDataImpl(uint32 remove_mask,
122 uint32 quota_storage_remove_mask,
123 const GURL& remove_origin,
124 const OriginMatcherFunction& origin_matcher,
125 net::URLRequestContextGetter* rq_context,
126 const base::Time begin,
127 const base::Time end,
128 const base::Closure& callback);
130 // Used by StoragePartitionImplMap.
132 // TODO(ajwong): These should be taken in the constructor and in Create() but
133 // because the URLRequestContextGetter still lives in Profile with a tangled
134 // initialization, if we try to retrieve the URLRequestContextGetter()
135 // before the default StoragePartition is created, we end up reentering the
136 // construction and double-initializing. For now, we retain the legacy
137 // behavior while allowing StoragePartitionImpl to expose these accessors by
138 // letting StoragePartitionImplMap call these two private settings at the
139 // appropriate time. These should move back into the constructor once
140 // URLRequestContextGetter's lifetime is sorted out. We should also move the
141 // PostCreateInitialization() out of StoragePartitionImplMap.
142 CONTENT_EXPORT void SetURLRequestContext(
143 net::URLRequestContextGetter* url_request_context);
144 void SetMediaURLRequestContext(
145 net::URLRequestContextGetter* media_url_request_context);
147 base::FilePath partition_path_;
148 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
149 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
150 scoped_refptr<quota::QuotaManager> quota_manager_;
151 scoped_refptr<ChromeAppCacheService> appcache_service_;
152 scoped_refptr<fileapi::FileSystemContext> filesystem_context_;
153 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
154 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
155 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
156 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
157 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_;
158 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
160 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
163 } // namespace content
165 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_