aw: Rendering test harness and end-to-end smoke test
[chromium-blink-merge.git] / content / browser / storage_partition_impl.h
blobbde83ad45ff4656a79242b6fa5ab9b0a2ae519c7
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/host_zoom_level_context.h"
14 #include "content/browser/indexed_db/indexed_db_context_impl.h"
15 #include "content/browser/media/webrtc_identity_store.h"
16 #include "content/browser/service_worker/service_worker_context_wrapper.h"
17 #include "content/common/content_export.h"
18 #include "content/public/browser/storage_partition.h"
19 #include "storage/browser/quota/special_storage_policy.h"
21 namespace content {
23 class StoragePartitionImpl : public StoragePartition {
24 public:
25 CONTENT_EXPORT ~StoragePartitionImpl() override;
27 // Quota managed data uses a different bitmask for types than
28 // StoragePartition uses. This method generates that mask.
29 CONTENT_EXPORT static int GenerateQuotaClientMask(uint32 remove_mask);
31 CONTENT_EXPORT void OverrideQuotaManagerForTesting(
32 storage::QuotaManager* quota_manager);
33 CONTENT_EXPORT void OverrideSpecialStoragePolicyForTesting(
34 storage::SpecialStoragePolicy* special_storage_policy);
36 // StoragePartition interface.
37 base::FilePath GetPath() override;
38 net::URLRequestContextGetter* GetURLRequestContext() override;
39 net::URLRequestContextGetter* GetMediaURLRequestContext() override;
40 storage::QuotaManager* GetQuotaManager() override;
41 ChromeAppCacheService* GetAppCacheService() override;
42 storage::FileSystemContext* GetFileSystemContext() override;
43 storage::DatabaseTracker* GetDatabaseTracker() override;
44 DOMStorageContextWrapper* GetDOMStorageContext() override;
45 IndexedDBContextImpl* GetIndexedDBContext() override;
46 ServiceWorkerContextWrapper* GetServiceWorkerContext() override;
47 GeofencingManager* GetGeofencingManager() override;
48 HostZoomMap* GetHostZoomMap() override;
49 HostZoomLevelContext* GetHostZoomLevelContext() override;
50 ZoomLevelDelegate* GetZoomLevelDelegate() override;
52 void ClearDataForOrigin(uint32 remove_mask,
53 uint32 quota_storage_remove_mask,
54 const GURL& storage_origin,
55 net::URLRequestContextGetter* request_context_getter,
56 const base::Closure& callback) override;
57 void ClearData(uint32 remove_mask,
58 uint32 quota_storage_remove_mask,
59 const GURL& storage_origin,
60 const OriginMatcherFunction& origin_matcher,
61 const base::Time begin,
62 const base::Time end,
63 const base::Closure& callback) override;
65 WebRTCIdentityStore* GetWebRTCIdentityStore();
67 struct DataDeletionHelper;
68 struct QuotaManagedDataDeletionHelper;
70 private:
71 friend class StoragePartitionImplMap;
72 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache);
73 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
74 RemoveQuotaManagedDataForeverBoth);
75 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
76 RemoveQuotaManagedDataForeverOnlyTemporary);
77 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
78 RemoveQuotaManagedDataForeverOnlyPersistent);
79 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
80 RemoveQuotaManagedDataForeverNeither);
81 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
82 RemoveQuotaManagedDataForeverSpecificOrigin);
83 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
84 RemoveQuotaManagedDataForLastHour);
85 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
86 RemoveQuotaManagedDataForLastWeek);
87 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
88 RemoveQuotaManagedUnprotectedOrigins);
89 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
90 RemoveQuotaManagedProtectedSpecificOrigin);
91 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
92 RemoveQuotaManagedProtectedOrigins);
93 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
94 RemoveQuotaManagedIgnoreDevTools);
95 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieForever);
96 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieLastHour);
97 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
98 RemoveUnprotectedLocalStorageForever);
99 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
100 RemoveProtectedLocalStorageForever);
101 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
102 RemoveLocalStorageForLastWeek);
104 // The |partition_path| is the absolute path to the root of this
105 // StoragePartition's on-disk storage.
107 // If |in_memory| is true, the |partition_path| is (ab)used as a way of
108 // distinguishing different in-memory partitions, but nothing is persisted
109 // on to disk.
110 static StoragePartitionImpl* Create(BrowserContext* context,
111 bool in_memory,
112 const base::FilePath& profile_path);
114 CONTENT_EXPORT StoragePartitionImpl(
115 const base::FilePath& partition_path,
116 storage::QuotaManager* quota_manager,
117 ChromeAppCacheService* appcache_service,
118 storage::FileSystemContext* filesystem_context,
119 storage::DatabaseTracker* database_tracker,
120 DOMStorageContextWrapper* dom_storage_context,
121 IndexedDBContextImpl* indexed_db_context,
122 ServiceWorkerContextWrapper* service_worker_context,
123 WebRTCIdentityStore* webrtc_identity_store,
124 storage::SpecialStoragePolicy* special_storage_policy,
125 GeofencingManager* geofencing_manager,
126 HostZoomLevelContext* host_zoom_level_context);
128 void ClearDataImpl(uint32 remove_mask,
129 uint32 quota_storage_remove_mask,
130 const GURL& remove_origin,
131 const OriginMatcherFunction& origin_matcher,
132 net::URLRequestContextGetter* rq_context,
133 const base::Time begin,
134 const base::Time end,
135 const base::Closure& callback);
137 // Used by StoragePartitionImplMap.
139 // TODO(ajwong): These should be taken in the constructor and in Create() but
140 // because the URLRequestContextGetter still lives in Profile with a tangled
141 // initialization, if we try to retrieve the URLRequestContextGetter()
142 // before the default StoragePartition is created, we end up reentering the
143 // construction and double-initializing. For now, we retain the legacy
144 // behavior while allowing StoragePartitionImpl to expose these accessors by
145 // letting StoragePartitionImplMap call these two private settings at the
146 // appropriate time. These should move back into the constructor once
147 // URLRequestContextGetter's lifetime is sorted out. We should also move the
148 // PostCreateInitialization() out of StoragePartitionImplMap.
149 CONTENT_EXPORT void SetURLRequestContext(
150 net::URLRequestContextGetter* url_request_context);
151 void SetMediaURLRequestContext(
152 net::URLRequestContextGetter* media_url_request_context);
154 base::FilePath partition_path_;
155 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
156 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
157 scoped_refptr<storage::QuotaManager> quota_manager_;
158 scoped_refptr<ChromeAppCacheService> appcache_service_;
159 scoped_refptr<storage::FileSystemContext> filesystem_context_;
160 scoped_refptr<storage::DatabaseTracker> database_tracker_;
161 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
162 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
163 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
164 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_;
165 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
166 scoped_refptr<GeofencingManager> geofencing_manager_;
167 scoped_refptr<HostZoomLevelContext> host_zoom_level_context_;
169 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
172 } // namespace content
174 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_