blob: 8665a74b34ccc4397f36b83961f2762efaad384a [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]877e2612013-04-05 05:58:1815#include "content/common/content_export.h"
[email protected]4c3a23582012-08-18 08:54:3416#include "content/public/browser/storage_partition.h"
17
18namespace content {
19
20class StoragePartitionImpl : public StoragePartition {
21 public:
[email protected]877e2612013-04-05 05:58:1822 CONTENT_EXPORT virtual ~StoragePartitionImpl();
[email protected]4c3a23582012-08-18 08:54:3423
[email protected]4c3a23582012-08-18 08:54:3424 // StoragePartition interface.
[email protected]2dec8ec2013-02-07 19:20:3425 virtual base::FilePath GetPath() OVERRIDE;
[email protected]10eb28162012-09-18 03:04:0926 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
27 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE;
[email protected]4c3a23582012-08-18 08:54:3428 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
29 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
30 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
31 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
[email protected]5f2aa722013-08-07 16:59:4132 virtual DOMStorageContextWrapper* GetDOMStorageContext() OVERRIDE;
[email protected]4c3a23582012-08-18 08:54:3433 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE;
[email protected]fdf3e13c2013-07-31 06:23:4634
35 virtual void ClearDataForOrigin(
36 uint32 remove_mask,
37 uint32 quota_storage_remove_mask,
[email protected]5ef99bd92012-11-14 05:00:1138 const GURL& storage_origin,
39 net::URLRequestContextGetter* request_context_getter) OVERRIDE;
[email protected]fdf3e13c2013-07-31 06:23:4640 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;
[email protected]4c3a23582012-08-18 08:54:3448
[email protected]d3220662013-07-01 21:21:4649 WebRTCIdentityStore* GetWebRTCIdentityStore();
50
[email protected]fdf3e13c2013-07-31 06:23:4651 struct DataDeletionHelper;
52 struct QuotaManagedDataDeletionHelper;
53
[email protected]4c3a23582012-08-18 08:54:3454 private:
[email protected]10eb28162012-09-18 03:04:0955 friend class StoragePartitionImplMap;
[email protected]877e2612013-04-05 05:58:1856 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache);
[email protected]10eb28162012-09-18 03:04:0957
[email protected]b471cf42012-11-13 09:11:3058 // The |partition_path| is the absolute path to the root of this
59 // StoragePartition's on-disk storage.
[email protected]1bc28312012-11-08 08:31:5360 //
[email protected]b471cf42012-11-13 09:11:3061 // 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,
[email protected]2dec8ec2013-02-07 19:20:3466 const base::FilePath& profile_path);
[email protected]1bc28312012-11-08 08:31:5367
[email protected]fdf3e13c2013-07-31 06:23:4668 // 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
[email protected]877e2612013-04-05 05:58:1872 CONTENT_EXPORT StoragePartitionImpl(
[email protected]2dec8ec2013-02-07 19:20:3473 const base::FilePath& partition_path,
[email protected]10eb28162012-09-18 03:04:0974 quota::QuotaManager* quota_manager,
75 ChromeAppCacheService* appcache_service,
76 fileapi::FileSystemContext* filesystem_context,
77 webkit_database::DatabaseTracker* database_tracker,
[email protected]5f2aa722013-08-07 16:59:4178 DOMStorageContextWrapper* dom_storage_context,
[email protected]d3220662013-07-01 21:21:4679 IndexedDBContextImpl* indexed_db_context,
80 scoped_ptr<WebRTCIdentityStore> webrtc_identity_store);
[email protected]10eb28162012-09-18 03:04:0981
[email protected]fdf3e13c2013-07-31 06:23:4682 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
[email protected]10eb28162012-09-18 03:04:0990 // 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);
[email protected]4c3a23582012-08-18 08:54:34105
[email protected]2dec8ec2013-02-07 19:20:34106 base::FilePath partition_path_;
[email protected]10eb28162012-09-18 03:04:09107 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
108 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
[email protected]4c3a23582012-08-18 08:54:34109 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_;
[email protected]5f2aa722013-08-07 16:59:41113 scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
[email protected]4c3a23582012-08-18 08:54:34114 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
[email protected]d3220662013-07-01 21:21:46115 scoped_ptr<WebRTCIdentityStore> webrtc_identity_store_;
[email protected]4c3a23582012-08-18 08:54:34116
117 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
118};
119
120} // namespace content
121
122#endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_