Make crazy linker work in gn build
[chromium-blink-merge.git] / content / browser / storage_partition_impl.h
blobf8fda1c03526f76c452e174af0361bfae14af3ae
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 "storage/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 storage::QuotaManager* quota_manager);
32 CONTENT_EXPORT void OverrideSpecialStoragePolicyForTesting(
33 storage::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 storage::QuotaManager* GetQuotaManager() override;
40 virtual ChromeAppCacheService* GetAppCacheService() override;
41 virtual storage::FileSystemContext* GetFileSystemContext() override;
42 virtual storage::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,
52 const base::Closure& callback) override;
53 virtual 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;
61 WebRTCIdentityStore* GetWebRTCIdentityStore();
63 struct DataDeletionHelper;
64 struct QuotaManagedDataDeletionHelper;
66 private:
67 friend class StoragePartitionImplMap;
68 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache);
69 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);
100 // The |partition_path| is the absolute path to the root of this
101 // StoragePartition's on-disk storage.
103 // If |in_memory| is true, the |partition_path| is (ab)used as a way of
104 // distinguishing different in-memory partitions, but nothing is persisted
105 // on to disk.
106 static StoragePartitionImpl* Create(BrowserContext* context,
107 bool in_memory,
108 const base::FilePath& profile_path);
110 CONTENT_EXPORT StoragePartitionImpl(
111 const base::FilePath& partition_path,
112 storage::QuotaManager* quota_manager,
113 ChromeAppCacheService* appcache_service,
114 storage::FileSystemContext* filesystem_context,
115 storage::DatabaseTracker* database_tracker,
116 DOMStorageContextWrapper* dom_storage_context,
117 IndexedDBContextImpl* indexed_db_context,
118 ServiceWorkerContextWrapper* service_worker_context,
119 WebRTCIdentityStore* webrtc_identity_store,
120 storage::SpecialStoragePolicy* special_storage_policy);
122 void ClearDataImpl(uint32 remove_mask,
123 uint32 quota_storage_remove_mask,
124 const GURL& remove_origin,
125 const OriginMatcherFunction& origin_matcher,
126 net::URLRequestContextGetter* rq_context,
127 const base::Time begin,
128 const base::Time end,
129 const base::Closure& callback);
131 // Used by StoragePartitionImplMap.
133 // TODO(ajwong): These should be taken in the constructor and in Create() but
134 // because the URLRequestContextGetter still lives in Profile with a tangled
135 // initialization, if we try to retrieve the URLRequestContextGetter()
136 // before the default StoragePartition is created, we end up reentering the
137 // construction and double-initializing. For now, we retain the legacy
138 // behavior while allowing StoragePartitionImpl to expose these accessors by
139 // letting StoragePartitionImplMap call these two private settings at the
140 // appropriate time. These should move back into the constructor once
141 // URLRequestContextGetter's lifetime is sorted out. We should also move the
142 // PostCreateInitialization() out of StoragePartitionImplMap.
143 CONTENT_EXPORT void SetURLRequestContext(
144 net::URLRequestContextGetter* url_request_context);
145 void SetMediaURLRequestContext(
146 net::URLRequestContextGetter* media_url_request_context);
148 base::FilePath partition_path_;
149 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
150 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
151 scoped_refptr<storage::QuotaManager> quota_manager_;
152 scoped_refptr<ChromeAppCacheService> appcache_service_;
153 scoped_refptr<storage::FileSystemContext> filesystem_context_;
154 scoped_refptr<storage::DatabaseTracker> database_tracker_;
155 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
156 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
157 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
158 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_;
159 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
161 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
164 } // namespace content
166 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_