Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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. |
| 4 | |
| 5 | #ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
| 6 | #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
| 7 | |
| 8 | #include "base/compiler_specific.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 9 | #include "base/files/file_path.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
| 11 | #include "content/browser/appcache/chrome_appcache_service.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 12 | #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 13 | #include "content/browser/indexed_db/indexed_db_context_impl.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 14 | #include "content/browser/media/webrtc_identity_store.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 15 | #include "content/common/content_export.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 16 | #include "content/public/browser/storage_partition.h" |
| 17 | |
| 18 | namespace content { |
| 19 | |
| 20 | class StoragePartitionImpl : public StoragePartition { |
| 21 | public: |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 22 | CONTENT_EXPORT virtual ~StoragePartitionImpl(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 23 | |
| 24 | // StoragePartition interface. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 25 | virtual base::FilePath GetPath() OVERRIDE; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 26 | virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; |
| 27 | virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; |
| 28 | virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; |
| 29 | virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; |
| 30 | virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
| 31 | virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 32 | virtual DOMStorageContextWrapper* GetDOMStorageContext() OVERRIDE; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 33 | virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 34 | |
| 35 | virtual void ClearDataForOrigin( |
| 36 | uint32 remove_mask, |
| 37 | uint32 quota_storage_remove_mask, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 38 | const GURL& storage_origin, |
| 39 | net::URLRequestContextGetter* request_context_getter) OVERRIDE; |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 40 | virtual void ClearDataForUnboundedRange( |
| 41 | uint32 remove_mask, |
| 42 | uint32 quota_storage_remove_mask) OVERRIDE; |
| 43 | virtual void ClearDataForRange(uint32 remove_mask, |
| 44 | uint32 quota_storage_remove_mask, |
| 45 | const base::Time& begin, |
| 46 | const base::Time& end, |
| 47 | const base::Closure& callback) OVERRIDE; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 48 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 49 | WebRTCIdentityStore* GetWebRTCIdentityStore(); |
| 50 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 51 | struct DataDeletionHelper; |
| 52 | struct QuotaManagedDataDeletionHelper; |
| 53 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 54 | private: |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 55 | friend class StoragePartitionImplMap; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 56 | FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 57 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 58 | // The |partition_path| is the absolute path to the root of this |
| 59 | // StoragePartition's on-disk storage. |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 60 | // |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 61 | // If |in_memory| is true, the |partition_path| is (ab)used as a way of |
| 62 | // distinguishing different in-memory partitions, but nothing is persisted |
| 63 | // on to disk. |
| 64 | static StoragePartitionImpl* Create(BrowserContext* context, |
| 65 | bool in_memory, |
| 66 | const base::FilePath& profile_path); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 67 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 68 | // Quota managed data uses a different bitmask for types than |
| 69 | // StoragePartition uses. This method generates that mask. |
| 70 | static int GenerateQuotaClientMask(uint32 remove_mask); |
| 71 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 72 | CONTENT_EXPORT StoragePartitionImpl( |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 73 | const base::FilePath& partition_path, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 74 | quota::QuotaManager* quota_manager, |
| 75 | ChromeAppCacheService* appcache_service, |
| 76 | fileapi::FileSystemContext* filesystem_context, |
| 77 | webkit_database::DatabaseTracker* database_tracker, |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 78 | DOMStorageContextWrapper* dom_storage_context, |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 79 | IndexedDBContextImpl* indexed_db_context, |
| 80 | scoped_ptr<WebRTCIdentityStore> webrtc_identity_store); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 81 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 82 | void ClearDataImpl(uint32 remove_mask, |
| 83 | uint32 quota_storage_remove_mask, |
| 84 | const GURL& remove_origin, |
| 85 | net::URLRequestContextGetter* rq_context, |
| 86 | const base::Time begin, |
| 87 | const base::Time end, |
| 88 | const base::Closure& callback); |
| 89 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 90 | // Used by StoragePartitionImplMap. |
| 91 | // |
| 92 | // TODO(ajwong): These should be taken in the constructor and in Create() but |
| 93 | // because the URLRequestContextGetter still lives in Profile with a tangled |
| 94 | // initialization, if we try to retrieve the URLRequestContextGetter() |
| 95 | // before the default StoragePartition is created, we end up reentering the |
| 96 | // construction and double-initializing. For now, we retain the legacy |
| 97 | // behavior while allowing StoragePartitionImpl to expose these accessors by |
| 98 | // letting StoragePartitionImplMap call these two private settings at the |
| 99 | // appropriate time. These should move back into the constructor once |
| 100 | // URLRequestContextGetter's lifetime is sorted out. We should also move the |
| 101 | // PostCreateInitialization() out of StoragePartitionImplMap. |
| 102 | void SetURLRequestContext(net::URLRequestContextGetter* url_request_context); |
| 103 | void SetMediaURLRequestContext( |
| 104 | net::URLRequestContextGetter* media_url_request_context); |
| 105 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 106 | base::FilePath partition_path_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 107 | scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
| 108 | scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; |
| 109 | scoped_refptr<quota::QuotaManager> quota_manager_; |
| 110 | scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 111 | scoped_refptr<fileapi::FileSystemContext> filesystem_context_; |
| 112 | scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 113 | scoped_refptr<DOMStorageContextWrapper> dom_storage_context_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 114 | scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 115 | scoped_ptr<WebRTCIdentityStore> webrtc_identity_store_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 116 | |
| 117 | DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); |
| 118 | }; |
| 119 | |
| 120 | } // namespace content |
| 121 | |
| 122 | #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |