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.
5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_
6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h"
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"
13 #include "content/browser/indexed_db/indexed_db_context_impl.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/storage_partition.h"
19 class StoragePartitionImpl
: public StoragePartition
{
21 CONTENT_EXPORT
virtual ~StoragePartitionImpl();
23 // StoragePartition interface.
24 virtual base::FilePath
GetPath() OVERRIDE
;
25 virtual net::URLRequestContextGetter
* GetURLRequestContext() OVERRIDE
;
26 virtual net::URLRequestContextGetter
* GetMediaURLRequestContext() OVERRIDE
;
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
;
33 virtual void AsyncClearDataForOrigin(
35 const GURL
& storage_origin
,
36 net::URLRequestContextGetter
* request_context_getter
) OVERRIDE
;
37 virtual void AsyncClearData(uint32 storage_mask
) OVERRIDE
;
38 virtual void AsyncClearDataBetween(
40 const base::Time
& begin
,
41 const base::Time
& end
,
42 const base::Closure
& callback
) OVERRIDE
;
45 friend class StoragePartitionImplMap
;
46 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest
, ClearShaderCache
);
48 // The |partition_path| is the absolute path to the root of this
49 // StoragePartition's on-disk storage.
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
54 static StoragePartitionImpl
* Create(BrowserContext
* context
,
56 const base::FilePath
& profile_path
);
58 CONTENT_EXPORT
StoragePartitionImpl(
59 const base::FilePath
& partition_path
,
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
);
67 // Used by StoragePartitionImplMap.
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
);
83 base::FilePath partition_path_
;
84 scoped_refptr
<net::URLRequestContextGetter
> url_request_context_
;
85 scoped_refptr
<net::URLRequestContextGetter
> media_url_request_context_
;
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_
;
93 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl
);
96 } // namespace content
98 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_