[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [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" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 9 | #include "base/files/file_path.h" |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 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_impl.h" |
[email protected] | c4d28166 | 2013-03-31 00:35:08 | [diff] [blame] | 13 | #include "content/browser/indexed_db/indexed_db_context_impl.h" |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame^] | 14 | #include "content/common/content_export.h" |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 15 | #include "content/public/browser/storage_partition.h" |
| 16 | |
| 17 | namespace content { |
| 18 | |
| 19 | class StoragePartitionImpl : public StoragePartition { |
| 20 | public: |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame^] | 21 | CONTENT_EXPORT virtual ~StoragePartitionImpl(); |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 22 | |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 23 | // StoragePartition interface. |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 24 | virtual base::FilePath GetPath() OVERRIDE; |
[email protected] | 10eb2816 | 2012-09-18 03:04:09 | [diff] [blame] | 25 | virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; |
| 26 | virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 27 | virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; |
| 28 | virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; |
| 29 | virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
| 30 | virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; |
| 31 | virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; |
| 32 | virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; |
[email protected] | 5ef99bd9 | 2012-11-14 05:00:11 | [diff] [blame] | 33 | virtual void AsyncClearDataForOrigin( |
[email protected] | 7a05d941 | 2013-03-05 03:52:00 | [diff] [blame] | 34 | uint32 storage_mask, |
[email protected] | 5ef99bd9 | 2012-11-14 05:00:11 | [diff] [blame] | 35 | const GURL& storage_origin, |
| 36 | net::URLRequestContextGetter* request_context_getter) OVERRIDE; |
[email protected] | 7a05d941 | 2013-03-05 03:52:00 | [diff] [blame] | 37 | virtual void AsyncClearData(uint32 storage_mask) OVERRIDE; |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame^] | 38 | virtual void AsyncClearDataBetween( |
| 39 | uint32 storage_mask, |
| 40 | const base::Time& begin, |
| 41 | const base::Time& end, |
| 42 | const base::Closure& callback) OVERRIDE; |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 43 | |
| 44 | private: |
[email protected] | 10eb2816 | 2012-09-18 03:04:09 | [diff] [blame] | 45 | friend class StoragePartitionImplMap; |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame^] | 46 | FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache); |
[email protected] | 10eb2816 | 2012-09-18 03:04:09 | [diff] [blame] | 47 | |
[email protected] | b471cf4 | 2012-11-13 09:11:30 | [diff] [blame] | 48 | // The |partition_path| is the absolute path to the root of this |
| 49 | // StoragePartition's on-disk storage. |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 50 | // |
[email protected] | b471cf4 | 2012-11-13 09:11:30 | [diff] [blame] | 51 | // If |in_memory| is true, the |partition_path| is (ab)used as a way of |
| 52 | // distinguishing different in-memory partitions, but nothing is persisted |
| 53 | // on to disk. |
| 54 | static StoragePartitionImpl* Create(BrowserContext* context, |
| 55 | bool in_memory, |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 56 | const base::FilePath& profile_path); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 57 | |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame^] | 58 | CONTENT_EXPORT StoragePartitionImpl( |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 59 | const base::FilePath& partition_path, |
[email protected] | 10eb2816 | 2012-09-18 03:04:09 | [diff] [blame] | 60 | quota::QuotaManager* quota_manager, |
| 61 | ChromeAppCacheService* appcache_service, |
| 62 | fileapi::FileSystemContext* filesystem_context, |
| 63 | webkit_database::DatabaseTracker* database_tracker, |
| 64 | DOMStorageContextImpl* dom_storage_context, |
| 65 | IndexedDBContextImpl* indexed_db_context); |
| 66 | |
| 67 | // Used by StoragePartitionImplMap. |
| 68 | // |
| 69 | // TODO(ajwong): These should be taken in the constructor and in Create() but |
| 70 | // because the URLRequestContextGetter still lives in Profile with a tangled |
| 71 | // initialization, if we try to retrieve the URLRequestContextGetter() |
| 72 | // before the default StoragePartition is created, we end up reentering the |
| 73 | // construction and double-initializing. For now, we retain the legacy |
| 74 | // behavior while allowing StoragePartitionImpl to expose these accessors by |
| 75 | // letting StoragePartitionImplMap call these two private settings at the |
| 76 | // appropriate time. These should move back into the constructor once |
| 77 | // URLRequestContextGetter's lifetime is sorted out. We should also move the |
| 78 | // PostCreateInitialization() out of StoragePartitionImplMap. |
| 79 | void SetURLRequestContext(net::URLRequestContextGetter* url_request_context); |
| 80 | void SetMediaURLRequestContext( |
| 81 | net::URLRequestContextGetter* media_url_request_context); |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 82 | |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 83 | base::FilePath partition_path_; |
[email protected] | 10eb2816 | 2012-09-18 03:04:09 | [diff] [blame] | 84 | scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
| 85 | scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 86 | scoped_refptr<quota::QuotaManager> quota_manager_; |
| 87 | scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 88 | scoped_refptr<fileapi::FileSystemContext> filesystem_context_; |
| 89 | scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 90 | scoped_refptr<DOMStorageContextImpl> dom_storage_context_; |
| 91 | scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
| 92 | |
| 93 | DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); |
| 94 | }; |
| 95 | |
| 96 | } // namespace content |
| 97 | |
| 98 | #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |