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