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