blob: f53447eb1b4e1d4610e402e35c7ed5cf3a2d9787 [file] [log] [blame]
[email protected]4c3a23582012-08-18 08:54:341// 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.
4
5#ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_
6#define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_
7
8#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:529#include "base/files/file_path.h"
[email protected]4c3a23582012-08-18 08:54:3410#include "base/memory/ref_counted.h"
11#include "content/browser/appcache/chrome_appcache_service.h"
[email protected]5f2aa722013-08-07 16:59:4112#include "content/browser/dom_storage/dom_storage_context_wrapper.h"
wjmacleancaa7d6d2014-11-12 16:42:1113#include "content/browser/host_zoom_level_context.h"
[email protected]c4d281662013-03-31 00:35:0814#include "content/browser/indexed_db/indexed_db_context_impl.h"
[email protected]d3220662013-07-01 21:21:4615#include "content/browser/media/webrtc_identity_store.h"
[email protected]1f1e8562013-11-13 05:05:1616#include "content/browser/service_worker/service_worker_context_wrapper.h"
[email protected]877e2612013-04-05 05:58:1817#include "content/common/content_export.h"
[email protected]4c3a23582012-08-18 08:54:3418#include "content/public/browser/storage_partition.h"
pilgrime92c5fcd2014-09-10 23:31:2319#include "storage/browser/quota/special_storage_policy.h"
[email protected]4c3a23582012-08-18 08:54:3420
21namespace content {
22
23class StoragePartitionImpl : public StoragePartition {
24 public:
dchengc2282aa2014-10-21 12:07:5825 CONTENT_EXPORT ~StoragePartitionImpl() override;
[email protected]4c3a23582012-08-18 08:54:3426
[email protected]88562b512013-11-06 21:10:4427 // 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);
30
31 CONTENT_EXPORT void OverrideQuotaManagerForTesting(
[email protected]cd501a72014-08-22 19:58:3132 storage::QuotaManager* quota_manager);
[email protected]88562b512013-11-06 21:10:4433 CONTENT_EXPORT void OverrideSpecialStoragePolicyForTesting(
[email protected]cd501a72014-08-22 19:58:3134 storage::SpecialStoragePolicy* special_storage_policy);
[email protected]88562b512013-11-06 21:10:4435
[email protected]4c3a23582012-08-18 08:54:3436 // StoragePartition interface.
dchengc2282aa2014-10-21 12:07:5837 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;
mek0c55c7f62014-10-23 22:06:0947 GeofencingManager* GetGeofencingManager() override;
wjmacleancaa7d6d2014-11-12 16:42:1148 HostZoomMap* GetHostZoomMap() override;
49 HostZoomLevelContext* GetHostZoomLevelContext() override;
50 ZoomLevelDelegate* GetZoomLevelDelegate() override;
meke6b83032014-12-19 23:35:3451 NavigatorConnectContext* GetNavigatorConnectContext() override;
[email protected]33ad6ce92013-08-27 14:39:0852
dchengc2282aa2014-10-21 12:07:5853 void ClearDataForOrigin(uint32 remove_mask,
54 uint32 quota_storage_remove_mask,
55 const GURL& storage_origin,
56 net::URLRequestContextGetter* request_context_getter,
57 const base::Closure& callback) override;
58 void ClearData(uint32 remove_mask,
59 uint32 quota_storage_remove_mask,
60 const GURL& storage_origin,
61 const OriginMatcherFunction& origin_matcher,
62 const base::Time begin,
63 const base::Time end,
64 const base::Closure& callback) override;
[email protected]4c3a23582012-08-18 08:54:3465
[email protected]d3220662013-07-01 21:21:4666 WebRTCIdentityStore* GetWebRTCIdentityStore();
67
[email protected]fdf3e13c2013-07-31 06:23:4668 struct DataDeletionHelper;
69 struct QuotaManagedDataDeletionHelper;
70
[email protected]4c3a23582012-08-18 08:54:3471 private:
[email protected]10eb28162012-09-18 03:04:0972 friend class StoragePartitionImplMap;
[email protected]877e2612013-04-05 05:58:1873 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache);
[email protected]88562b512013-11-06 21:10:4474 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
75 RemoveQuotaManagedDataForeverBoth);
76 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
77 RemoveQuotaManagedDataForeverOnlyTemporary);
78 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
79 RemoveQuotaManagedDataForeverOnlyPersistent);
80 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
81 RemoveQuotaManagedDataForeverNeither);
82 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
83 RemoveQuotaManagedDataForeverSpecificOrigin);
84 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
85 RemoveQuotaManagedDataForLastHour);
86 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
87 RemoveQuotaManagedDataForLastWeek);
88 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
89 RemoveQuotaManagedUnprotectedOrigins);
90 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
91 RemoveQuotaManagedProtectedSpecificOrigin);
92 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
93 RemoveQuotaManagedProtectedOrigins);
94 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
95 RemoveQuotaManagedIgnoreDevTools);
96 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieForever);
97 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieLastHour);
98 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
99 RemoveUnprotectedLocalStorageForever);
100 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
101 RemoveProtectedLocalStorageForever);
102 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
103 RemoveLocalStorageForLastWeek);
[email protected]10eb28162012-09-18 03:04:09104
[email protected]b471cf42012-11-13 09:11:30105 // The |partition_path| is the absolute path to the root of this
106 // StoragePartition's on-disk storage.
[email protected]1bc28312012-11-08 08:31:53107 //
[email protected]33ad6ce92013-08-27 14:39:08108 // If |in_memory| is true, the |partition_path| is (ab)used as a way of
[email protected]b471cf42012-11-13 09:11:30109 // distinguishing different in-memory partitions, but nothing is persisted
110 // on to disk.
[email protected]33ad6ce92013-08-27 14:39:08111 static StoragePartitionImpl* Create(BrowserContext* context,
112 bool in_memory,
113 const base::FilePath& profile_path);
[email protected]1bc28312012-11-08 08:31:53114
[email protected]877e2612013-04-05 05:58:18115 CONTENT_EXPORT StoragePartitionImpl(
[email protected]2dec8ec2013-02-07 19:20:34116 const base::FilePath& partition_path,
[email protected]cd501a72014-08-22 19:58:31117 storage::QuotaManager* quota_manager,
[email protected]10eb28162012-09-18 03:04:09118 ChromeAppCacheService* appcache_service,
[email protected]cd501a72014-08-22 19:58:31119 storage::FileSystemContext* filesystem_context,
120 storage::DatabaseTracker* database_tracker,
[email protected]5f2aa722013-08-07 16:59:41121 DOMStorageContextWrapper* dom_storage_context,
[email protected]d3220662013-07-01 21:21:46122 IndexedDBContextImpl* indexed_db_context,
[email protected]1f1e8562013-11-13 05:05:16123 ServiceWorkerContextWrapper* service_worker_context,
[email protected]88562b512013-11-06 21:10:44124 WebRTCIdentityStore* webrtc_identity_store,
mek0c55c7f62014-10-23 22:06:09125 storage::SpecialStoragePolicy* special_storage_policy,
wjmacleancaa7d6d2014-11-12 16:42:11126 GeofencingManager* geofencing_manager,
meke6b83032014-12-19 23:35:34127 HostZoomLevelContext* host_zoom_level_context,
128 NavigatorConnectContext* navigator_connect_context);
[email protected]10eb28162012-09-18 03:04:09129
[email protected]fdf3e13c2013-07-31 06:23:46130 void ClearDataImpl(uint32 remove_mask,
131 uint32 quota_storage_remove_mask,
[email protected]5ff8b2a2013-12-28 06:51:42132 const GURL& remove_origin,
[email protected]88562b512013-11-06 21:10:44133 const OriginMatcherFunction& origin_matcher,
[email protected]33ad6ce92013-08-27 14:39:08134 net::URLRequestContextGetter* rq_context,
[email protected]fdf3e13c2013-07-31 06:23:46135 const base::Time begin,
136 const base::Time end,
137 const base::Closure& callback);
138
[email protected]10eb28162012-09-18 03:04:09139 // Used by StoragePartitionImplMap.
140 //
141 // TODO(ajwong): These should be taken in the constructor and in Create() but
142 // because the URLRequestContextGetter still lives in Profile with a tangled
143 // initialization, if we try to retrieve the URLRequestContextGetter()
144 // before the default StoragePartition is created, we end up reentering the
145 // construction and double-initializing. For now, we retain the legacy
146 // behavior while allowing StoragePartitionImpl to expose these accessors by
147 // letting StoragePartitionImplMap call these two private settings at the
148 // appropriate time. These should move back into the constructor once
149 // URLRequestContextGetter's lifetime is sorted out. We should also move the
150 // PostCreateInitialization() out of StoragePartitionImplMap.
[email protected]88562b512013-11-06 21:10:44151 CONTENT_EXPORT void SetURLRequestContext(
152 net::URLRequestContextGetter* url_request_context);
[email protected]10eb28162012-09-18 03:04:09153 void SetMediaURLRequestContext(
154 net::URLRequestContextGetter* media_url_request_context);
[email protected]4c3a23582012-08-18 08:54:34155
[email protected]2dec8ec2013-02-07 19:20:34156 base::FilePath partition_path_;
[email protected]10eb28162012-09-18 03:04:09157 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
158 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
[email protected]cd501a72014-08-22 19:58:31159 scoped_refptr<storage::QuotaManager> quota_manager_;
[email protected]4c3a23582012-08-18 08:54:34160 scoped_refptr<ChromeAppCacheService> appcache_service_;
[email protected]cd501a72014-08-22 19:58:31161 scoped_refptr<storage::FileSystemContext> filesystem_context_;
162 scoped_refptr<storage::DatabaseTracker> database_tracker_;
[email protected]5f2aa722013-08-07 16:59:41163 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
[email protected]4c3a23582012-08-18 08:54:34164 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
[email protected]1f1e8562013-11-13 05:05:16165 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
[email protected]ec346e02013-08-08 22:03:53166 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_;
[email protected]cd501a72014-08-22 19:58:31167 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
mek0c55c7f62014-10-23 22:06:09168 scoped_refptr<GeofencingManager> geofencing_manager_;
wjmacleancaa7d6d2014-11-12 16:42:11169 scoped_refptr<HostZoomLevelContext> host_zoom_level_context_;
meke6b83032014-12-19 23:35:34170 scoped_refptr<NavigatorConnectContext> navigator_connect_context_;
[email protected]4c3a23582012-08-18 08:54:34171
172 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
173};
174
175} // namespace content
176
177#endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_