OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ | 6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/browser/appcache/chrome_appcache_service.h" | 11 #include "content/browser/appcache/chrome_appcache_service.h" |
12 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 12 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
13 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 13 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
14 #include "content/browser/media/webrtc_identity_store.h" | 14 #include "content/browser/media/webrtc_identity_store.h" |
15 #include "content/browser/service_worker/service_worker_context.h" | 15 #include "content/browser/service_worker/service_worker_context.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
| 18 #include "webkit/browser/quota/special_storage_policy.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 class StoragePartitionImpl : public StoragePartition { | 22 class StoragePartitionImpl : public StoragePartition { |
22 public: | 23 public: |
23 CONTENT_EXPORT virtual ~StoragePartitionImpl(); | 24 CONTENT_EXPORT virtual ~StoragePartitionImpl(); |
24 | 25 |
| 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); |
| 29 |
| 30 CONTENT_EXPORT void OverrideQuotaManagerForTesting( |
| 31 quota::QuotaManager* quota_manager); |
| 32 CONTENT_EXPORT void OverrideSpecialStoragePolicyForTesting( |
| 33 quota::SpecialStoragePolicy* special_storage_policy); |
| 34 |
25 // StoragePartition interface. | 35 // StoragePartition interface. |
26 virtual base::FilePath GetPath() OVERRIDE; | 36 virtual base::FilePath GetPath() OVERRIDE; |
27 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; | 37 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; |
28 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; | 38 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; |
29 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; | 39 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; |
30 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; | 40 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; |
31 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; | 41 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
32 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; | 42 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; |
33 virtual DOMStorageContextWrapper* GetDOMStorageContext() OVERRIDE; | 43 virtual DOMStorageContextWrapper* GetDOMStorageContext() OVERRIDE; |
34 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; | 44 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; |
35 | 45 |
36 virtual void ClearDataForOrigin( | 46 virtual void ClearDataForOrigin( |
37 uint32 remove_mask, | 47 uint32 remove_mask, |
38 uint32 quota_storage_remove_mask, | 48 uint32 quota_storage_remove_mask, |
39 const GURL& storage_origin, | 49 const GURL& storage_origin, |
40 net::URLRequestContextGetter* request_context_getter) OVERRIDE; | 50 net::URLRequestContextGetter* request_context_getter) OVERRIDE; |
41 virtual void ClearDataForUnboundedRange( | 51 virtual void ClearDataForUnboundedRange( |
42 uint32 remove_mask, | 52 uint32 remove_mask, |
43 uint32 quota_storage_remove_mask) OVERRIDE; | 53 uint32 quota_storage_remove_mask) OVERRIDE; |
44 virtual void ClearDataForRange(uint32 remove_mask, | 54 virtual void ClearDataForRange(uint32 remove_mask, |
45 uint32 quota_storage_remove_mask, | 55 uint32 quota_storage_remove_mask, |
46 const base::Time& begin, | 56 const base::Time begin, |
47 const base::Time& end, | 57 const base::Time end, |
48 const base::Closure& callback) OVERRIDE; | 58 const base::Closure& callback) OVERRIDE; |
| 59 virtual void ClearDataForOriginWithinRange( |
| 60 uint32 remove_mask, |
| 61 uint32 quota_storage_remove_mask, |
| 62 const GURL& storage_origin, |
| 63 const OriginMatcherFunction& origin_matcher, |
| 64 const base::Time begin, |
| 65 const base::Time end, |
| 66 const base::Closure& callback) OVERRIDE; |
49 | 67 |
50 ServiceWorkerContext* GetServiceWorkerContext(); | 68 ServiceWorkerContext* GetServiceWorkerContext(); |
51 | 69 |
52 WebRTCIdentityStore* GetWebRTCIdentityStore(); | 70 WebRTCIdentityStore* GetWebRTCIdentityStore(); |
53 | 71 |
54 struct DataDeletionHelper; | 72 struct DataDeletionHelper; |
55 struct QuotaManagedDataDeletionHelper; | 73 struct QuotaManagedDataDeletionHelper; |
56 | 74 |
57 private: | 75 private: |
58 friend class StoragePartitionImplMap; | 76 friend class StoragePartitionImplMap; |
59 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache); | 77 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache); |
| 78 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 79 RemoveQuotaManagedDataForeverBoth); |
| 80 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 81 RemoveQuotaManagedDataForeverOnlyTemporary); |
| 82 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 83 RemoveQuotaManagedDataForeverOnlyPersistent); |
| 84 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 85 RemoveQuotaManagedDataForeverOnlyPersistent); |
| 86 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 87 RemoveQuotaManagedDataForeverNeither); |
| 88 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 89 RemoveQuotaManagedDataForeverSpecificOrigin); |
| 90 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 91 RemoveQuotaManagedDataForLastHour); |
| 92 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 93 RemoveQuotaManagedDataForLastWeek); |
| 94 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 95 RemoveQuotaManagedUnprotectedOrigins); |
| 96 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 97 RemoveQuotaManagedProtectedSpecificOrigin); |
| 98 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 99 RemoveQuotaManagedProtectedOrigins); |
| 100 FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplTest, |
| 101 RemoveQuotaManagedIgnoreDevTools); |
60 | 102 |
61 // The |partition_path| is the absolute path to the root of this | 103 // The |partition_path| is the absolute path to the root of this |
62 // StoragePartition's on-disk storage. | 104 // StoragePartition's on-disk storage. |
63 // | 105 // |
64 // If |in_memory| is true, the |partition_path| is (ab)used as a way of | 106 // If |in_memory| is true, the |partition_path| is (ab)used as a way of |
65 // distinguishing different in-memory partitions, but nothing is persisted | 107 // distinguishing different in-memory partitions, but nothing is persisted |
66 // on to disk. | 108 // on to disk. |
67 static StoragePartitionImpl* Create(BrowserContext* context, | 109 static StoragePartitionImpl* Create(BrowserContext* context, |
68 bool in_memory, | 110 bool in_memory, |
69 const base::FilePath& profile_path); | 111 const base::FilePath& profile_path); |
70 | 112 |
71 // Quota managed data uses a different bitmask for types than | |
72 // StoragePartition uses. This method generates that mask. | |
73 static int GenerateQuotaClientMask(uint32 remove_mask); | |
74 | |
75 CONTENT_EXPORT StoragePartitionImpl( | 113 CONTENT_EXPORT StoragePartitionImpl( |
76 const base::FilePath& partition_path, | 114 const base::FilePath& partition_path, |
77 quota::QuotaManager* quota_manager, | 115 quota::QuotaManager* quota_manager, |
78 ChromeAppCacheService* appcache_service, | 116 ChromeAppCacheService* appcache_service, |
79 fileapi::FileSystemContext* filesystem_context, | 117 fileapi::FileSystemContext* filesystem_context, |
80 webkit_database::DatabaseTracker* database_tracker, | 118 webkit_database::DatabaseTracker* database_tracker, |
81 DOMStorageContextWrapper* dom_storage_context, | 119 DOMStorageContextWrapper* dom_storage_context, |
82 IndexedDBContextImpl* indexed_db_context, | 120 IndexedDBContextImpl* indexed_db_context, |
83 ServiceWorkerContext* service_worker_context, | 121 ServiceWorkerContext* service_worker_context, |
84 WebRTCIdentityStore* webrtc_identity_store); | 122 WebRTCIdentityStore* webrtc_identity_store, |
| 123 quota::SpecialStoragePolicy* special_storage_policy); |
85 | 124 |
86 void ClearDataImpl(uint32 remove_mask, | 125 void ClearDataImpl(uint32 remove_mask, |
87 uint32 quota_storage_remove_mask, | 126 uint32 quota_storage_remove_mask, |
88 const GURL& remove_origin, | 127 const GURL& remove_origin, |
| 128 const OriginMatcherFunction& origin_matcher, |
89 net::URLRequestContextGetter* rq_context, | 129 net::URLRequestContextGetter* rq_context, |
90 const base::Time begin, | 130 const base::Time begin, |
91 const base::Time end, | 131 const base::Time end, |
92 const base::Closure& callback); | 132 const base::Closure& callback); |
93 | 133 |
94 // Used by StoragePartitionImplMap. | 134 // Used by StoragePartitionImplMap. |
95 // | 135 // |
96 // TODO(ajwong): These should be taken in the constructor and in Create() but | 136 // TODO(ajwong): These should be taken in the constructor and in Create() but |
97 // because the URLRequestContextGetter still lives in Profile with a tangled | 137 // because the URLRequestContextGetter still lives in Profile with a tangled |
98 // initialization, if we try to retrieve the URLRequestContextGetter() | 138 // initialization, if we try to retrieve the URLRequestContextGetter() |
(...skipping 12 matching lines...) Expand all Loading... |
111 scoped_refptr<net::URLRequestContextGetter> url_request_context_; | 151 scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
112 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; | 152 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; |
113 scoped_refptr<quota::QuotaManager> quota_manager_; | 153 scoped_refptr<quota::QuotaManager> quota_manager_; |
114 scoped_refptr<ChromeAppCacheService> appcache_service_; | 154 scoped_refptr<ChromeAppCacheService> appcache_service_; |
115 scoped_refptr<fileapi::FileSystemContext> filesystem_context_; | 155 scoped_refptr<fileapi::FileSystemContext> filesystem_context_; |
116 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 156 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
117 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_; | 157 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_; |
118 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; | 158 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
119 scoped_refptr<ServiceWorkerContext> service_worker_context_; | 159 scoped_refptr<ServiceWorkerContext> service_worker_context_; |
120 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_; | 160 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_; |
| 161 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
121 | 162 |
122 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); | 163 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); |
123 }; | 164 }; |
124 | 165 |
125 } // namespace content | 166 } // namespace content |
126 | 167 |
127 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ | 168 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
OLD | NEW |