blob: af206f518ba433f97005b7c878aa1d8d2b67ce7a [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"
12#include "content/browser/dom_storage/dom_storage_context_impl.h"
[email protected]c4d281662013-03-31 00:35:0813#include "content/browser/indexed_db/indexed_db_context_impl.h"
[email protected]877e2612013-04-05 05:58:1814#include "content/common/content_export.h"
[email protected]4c3a23582012-08-18 08:54:3415#include "content/public/browser/storage_partition.h"
16
17namespace content {
18
19class StoragePartitionImpl : public StoragePartition {
20 public:
[email protected]877e2612013-04-05 05:58:1821 CONTENT_EXPORT virtual ~StoragePartitionImpl();
[email protected]4c3a23582012-08-18 08:54:3422
[email protected]4c3a23582012-08-18 08:54:3423 // StoragePartition interface.
[email protected]2dec8ec2013-02-07 19:20:3424 virtual base::FilePath GetPath() OVERRIDE;
[email protected]10eb28162012-09-18 03:04:0925 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
26 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE;
[email protected]4c3a23582012-08-18 08:54:3427 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]5ef99bd92012-11-14 05:00:1133 virtual void AsyncClearDataForOrigin(
[email protected]7a05d9412013-03-05 03:52:0034 uint32 storage_mask,
[email protected]5ef99bd92012-11-14 05:00:1135 const GURL& storage_origin,
36 net::URLRequestContextGetter* request_context_getter) OVERRIDE;
[email protected]7a05d9412013-03-05 03:52:0037 virtual void AsyncClearData(uint32 storage_mask) OVERRIDE;
[email protected]877e2612013-04-05 05:58:1838 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]4c3a23582012-08-18 08:54:3443
44 private:
[email protected]10eb28162012-09-18 03:04:0945 friend class StoragePartitionImplMap;
[email protected]877e2612013-04-05 05:58:1846 FRIEND_TEST_ALL_PREFIXES(StoragePartitionShaderClearTest, ClearShaderCache);
[email protected]10eb28162012-09-18 03:04:0947
[email protected]b471cf42012-11-13 09:11:3048 // The |partition_path| is the absolute path to the root of this
49 // StoragePartition's on-disk storage.
[email protected]1bc28312012-11-08 08:31:5350 //
[email protected]b471cf42012-11-13 09:11:3051 // 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]2dec8ec2013-02-07 19:20:3456 const base::FilePath& profile_path);
[email protected]1bc28312012-11-08 08:31:5357
[email protected]877e2612013-04-05 05:58:1858 CONTENT_EXPORT StoragePartitionImpl(
[email protected]2dec8ec2013-02-07 19:20:3459 const base::FilePath& partition_path,
[email protected]10eb28162012-09-18 03:04:0960 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]4c3a23582012-08-18 08:54:3482
[email protected]2dec8ec2013-02-07 19:20:3483 base::FilePath partition_path_;
[email protected]10eb28162012-09-18 03:04:0984 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
85 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
[email protected]4c3a23582012-08-18 08:54:3486 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_