blob: 30377392100af9ee75d03a15e1462b585eeb1b33 [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"
[email protected]c4d281662013-03-31 00:35:0813#include "content/browser/indexed_db/indexed_db_context_impl.h"
[email protected]d3220662013-07-01 21:21:4614#include "content/browser/media/webrtc_identity_store.h"
[email protected]1f1e8562013-11-13 05:05:1615#include "content/browser/service_worker/service_worker_context_wrapper.h"
[email protected]877e2612013-04-05 05:58:1816#include "content/common/content_export.h"
[email protected]4c3a23582012-08-18 08:54:3417#include "content/public/browser/storage_partition.h"
pilgrime92c5fcd2014-09-10 23:31:2318#include "storage/browser/quota/special_storage_policy.h"
[email protected]4c3a23582012-08-18 08:54:3419
20namespace content {
21
22class StoragePartitionImpl : public StoragePartition {
23 public:
dchengc2282aa2014-10-21 12:07:5824 CONTENT_EXPORT ~StoragePartitionImpl() override;
[email protected]4c3a23582012-08-18 08:54:3425
[email protected]88562b512013-11-06 21:10:4426 // 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);
29
30 CONTENT_EXPORT void OverrideQuotaManagerForTesting(
[email protected]cd501a72014-08-22 19:58:3131 storage::QuotaManager* quota_manager);
[email protected]88562b512013-11-06 21:10:4432 CONTENT_EXPORT void OverrideSpecialStoragePolicyForTesting(
[email protected]cd501a72014-08-22 19:58:3133 storage::SpecialStoragePolicy* special_storage_policy);
[email protected]88562b512013-11-06 21:10:4434
[email protected]4c3a23582012-08-18 08:54:3435 // StoragePartition interface.
dchengc2282aa2014-10-21 12:07:5836 base::FilePath GetPath() override;
37 net::URLRequestContextGetter* GetURLRequestContext() override;
38 net::URLRequestContextGetter* GetMediaURLRequestContext() override;
39 storage::QuotaManager* GetQuotaManager() override;
40 ChromeAppCacheService* GetAppCacheService() override;
41 storage::FileSystemContext* GetFileSystemContext() override;
42 storage::DatabaseTracker* GetDatabaseTracker() override;
43 DOMStorageContextWrapper* GetDOMStorageContext() override;
44 IndexedDBContextImpl* GetIndexedDBContext() override;
45 ServiceWorkerContextWrapper* GetServiceWorkerContext() override;
mek0c55c7f62014-10-23 22:06:0946 GeofencingManager* GetGeofencingManager() override;
[email protected]33ad6ce92013-08-27 14:39:0847
dchengc2282aa2014-10-21 12:07:5848 void ClearDataForOrigin(uint32 remove_mask,
49 uint32 quota_storage_remove_mask,
50 const GURL& storage_origin,
51 net::URLRequestContextGetter* request_context_getter,
52 const base::Closure& callback) override;
53 void ClearData(uint32 remove_mask,
54 uint32 quota_storage_remove_mask,
55 const GURL& storage_origin,
56 const OriginMatcherFunction& origin_matcher,
57 const base::Time begin,
58 const base::Time end,
59 const base::Closure& callback) override;
[email protected]4c3a23582012-08-18 08:54:3460
[email protected]d3220662013-07-01 21:21:4661 WebRTCIdentityStore* GetWebRTCIdentityStore();
62
[email protected]fdf3e13c2013-07-31 06:23:4663 struct DataDeletionHelper;
64 struct QuotaManagedDataDeletionHelper;
65
[email protected]4c3a23582012-08-18 08:54:3466 private:
[email protected]10eb28162012-09-18 03:04:0967 friend class StoragePartitionImplMap;
[email protected]877e2612013-04-05 05:58:1868 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache);
[email protected]88562b512013-11-06 21:10:4469 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
70 RemoveQuotaManagedDataForeverBoth);
71 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
72 RemoveQuotaManagedDataForeverOnlyTemporary);
73 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
74 RemoveQuotaManagedDataForeverOnlyPersistent);
75 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
76 RemoveQuotaManagedDataForeverNeither);
77 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
78 RemoveQuotaManagedDataForeverSpecificOrigin);
79 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
80 RemoveQuotaManagedDataForLastHour);
81 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
82 RemoveQuotaManagedDataForLastWeek);
83 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
84 RemoveQuotaManagedUnprotectedOrigins);
85 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
86 RemoveQuotaManagedProtectedSpecificOrigin);
87 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
88 RemoveQuotaManagedProtectedOrigins);
89 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
90 RemoveQuotaManagedIgnoreDevTools);
91 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieForever);
92 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, RemoveCookieLastHour);
93 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
94 RemoveUnprotectedLocalStorageForever);
95 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
96 RemoveProtectedLocalStorageForever);
97 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest,
98 RemoveLocalStorageForLastWeek);
[email protected]10eb28162012-09-18 03:04:0999
[email protected]b471cf42012-11-13 09:11:30100 // The |partition_path| is the absolute path to the root of this
101 // StoragePartition's on-disk storage.
[email protected]1bc28312012-11-08 08:31:53102 //
[email protected]33ad6ce92013-08-27 14:39:08103 // If |in_memory| is true, the |partition_path| is (ab)used as a way of
[email protected]b471cf42012-11-13 09:11:30104 // distinguishing different in-memory partitions, but nothing is persisted
105 // on to disk.
[email protected]33ad6ce92013-08-27 14:39:08106 static StoragePartitionImpl* Create(BrowserContext* context,
107 bool in_memory,
108 const base::FilePath& profile_path);
[email protected]1bc28312012-11-08 08:31:53109
[email protected]877e2612013-04-05 05:58:18110 CONTENT_EXPORT StoragePartitionImpl(
[email protected]2dec8ec2013-02-07 19:20:34111 const base::FilePath& partition_path,
[email protected]cd501a72014-08-22 19:58:31112 storage::QuotaManager* quota_manager,
[email protected]10eb28162012-09-18 03:04:09113 ChromeAppCacheService* appcache_service,
[email protected]cd501a72014-08-22 19:58:31114 storage::FileSystemContext* filesystem_context,
115 storage::DatabaseTracker* database_tracker,
[email protected]5f2aa722013-08-07 16:59:41116 DOMStorageContextWrapper* dom_storage_context,
[email protected]d3220662013-07-01 21:21:46117 IndexedDBContextImpl* indexed_db_context,
[email protected]1f1e8562013-11-13 05:05:16118 ServiceWorkerContextWrapper* service_worker_context,
[email protected]88562b512013-11-06 21:10:44119 WebRTCIdentityStore* webrtc_identity_store,
mek0c55c7f62014-10-23 22:06:09120 storage::SpecialStoragePolicy* special_storage_policy,
121 GeofencingManager* geofencing_manager);
[email protected]10eb28162012-09-18 03:04:09122
[email protected]fdf3e13c2013-07-31 06:23:46123 void ClearDataImpl(uint32 remove_mask,
124 uint32 quota_storage_remove_mask,
[email protected]5ff8b2a2013-12-28 06:51:42125 const GURL& remove_origin,
[email protected]88562b512013-11-06 21:10:44126 const OriginMatcherFunction& origin_matcher,
[email protected]33ad6ce92013-08-27 14:39:08127 net::URLRequestContextGetter* rq_context,
[email protected]fdf3e13c2013-07-31 06:23:46128 const base::Time begin,
129 const base::Time end,
130 const base::Closure& callback);
131
[email protected]10eb28162012-09-18 03:04:09132 // Used by StoragePartitionImplMap.
133 //
134 // TODO(ajwong): These should be taken in the constructor and in Create() but
135 // because the URLRequestContextGetter still lives in Profile with a tangled
136 // initialization, if we try to retrieve the URLRequestContextGetter()
137 // before the default StoragePartition is created, we end up reentering the
138 // construction and double-initializing. For now, we retain the legacy
139 // behavior while allowing StoragePartitionImpl to expose these accessors by
140 // letting StoragePartitionImplMap call these two private settings at the
141 // appropriate time. These should move back into the constructor once
142 // URLRequestContextGetter's lifetime is sorted out. We should also move the
143 // PostCreateInitialization() out of StoragePartitionImplMap.
[email protected]88562b512013-11-06 21:10:44144 CONTENT_EXPORT void SetURLRequestContext(
145 net::URLRequestContextGetter* url_request_context);
[email protected]10eb28162012-09-18 03:04:09146 void SetMediaURLRequestContext(
147 net::URLRequestContextGetter* media_url_request_context);
[email protected]4c3a23582012-08-18 08:54:34148
[email protected]2dec8ec2013-02-07 19:20:34149 base::FilePath partition_path_;
[email protected]10eb28162012-09-18 03:04:09150 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
151 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
[email protected]cd501a72014-08-22 19:58:31152 scoped_refptr<storage::QuotaManager> quota_manager_;
[email protected]4c3a23582012-08-18 08:54:34153 scoped_refptr<ChromeAppCacheService> appcache_service_;
[email protected]cd501a72014-08-22 19:58:31154 scoped_refptr<storage::FileSystemContext> filesystem_context_;
155 scoped_refptr<storage::DatabaseTracker> database_tracker_;
[email protected]5f2aa722013-08-07 16:59:41156 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
[email protected]4c3a23582012-08-18 08:54:34157 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
[email protected]1f1e8562013-11-13 05:05:16158 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
[email protected]ec346e02013-08-08 22:03:53159 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_;
[email protected]cd501a72014-08-22 19:58:31160 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
mek0c55c7f62014-10-23 22:06:09161 scoped_refptr<GeofencingManager> geofencing_manager_;
[email protected]4c3a23582012-08-18 08:54:34162
163 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
164};
165
166} // namespace content
167
168#endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_