blob: 8537af23cac8a48772ad079e922961b34af4ed3d [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]4c3a23582012-08-18 08:54:3414#include "content/public/browser/storage_partition.h"
15
16namespace content {
17
18class StoragePartitionImpl : public StoragePartition {
19 public:
20 virtual ~StoragePartitionImpl();
21
[email protected]4c3a23582012-08-18 08:54:3422 // StoragePartition interface.
[email protected]2dec8ec2013-02-07 19:20:3423 virtual base::FilePath GetPath() OVERRIDE;
[email protected]10eb28162012-09-18 03:04:0924 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
25 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE;
[email protected]4c3a23582012-08-18 08:54:3426 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
27 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
28 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
29 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
30 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE;
31 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE;
[email protected]5ef99bd92012-11-14 05:00:1132 virtual void AsyncClearDataForOrigin(
[email protected]7a05d9412013-03-05 03:52:0033 uint32 storage_mask,
[email protected]5ef99bd92012-11-14 05:00:1134 const GURL& storage_origin,
35 net::URLRequestContextGetter* request_context_getter) OVERRIDE;
[email protected]7a05d9412013-03-05 03:52:0036 virtual void AsyncClearData(uint32 storage_mask) OVERRIDE;
[email protected]4c3a23582012-08-18 08:54:3437
38 private:
[email protected]10eb28162012-09-18 03:04:0939 friend class StoragePartitionImplMap;
40
[email protected]b471cf42012-11-13 09:11:3041 // The |partition_path| is the absolute path to the root of this
42 // StoragePartition's on-disk storage.
[email protected]1bc28312012-11-08 08:31:5343 //
[email protected]b471cf42012-11-13 09:11:3044 // If |in_memory| is true, the |partition_path| is (ab)used as a way of
45 // distinguishing different in-memory partitions, but nothing is persisted
46 // on to disk.
47 static StoragePartitionImpl* Create(BrowserContext* context,
48 bool in_memory,
[email protected]2dec8ec2013-02-07 19:20:3449 const base::FilePath& profile_path);
[email protected]1bc28312012-11-08 08:31:5350
[email protected]10eb28162012-09-18 03:04:0951 StoragePartitionImpl(
[email protected]2dec8ec2013-02-07 19:20:3452 const base::FilePath& partition_path,
[email protected]10eb28162012-09-18 03:04:0953 quota::QuotaManager* quota_manager,
54 ChromeAppCacheService* appcache_service,
55 fileapi::FileSystemContext* filesystem_context,
56 webkit_database::DatabaseTracker* database_tracker,
57 DOMStorageContextImpl* dom_storage_context,
58 IndexedDBContextImpl* indexed_db_context);
59
60 // Used by StoragePartitionImplMap.
61 //
62 // TODO(ajwong): These should be taken in the constructor and in Create() but
63 // because the URLRequestContextGetter still lives in Profile with a tangled
64 // initialization, if we try to retrieve the URLRequestContextGetter()
65 // before the default StoragePartition is created, we end up reentering the
66 // construction and double-initializing. For now, we retain the legacy
67 // behavior while allowing StoragePartitionImpl to expose these accessors by
68 // letting StoragePartitionImplMap call these two private settings at the
69 // appropriate time. These should move back into the constructor once
70 // URLRequestContextGetter's lifetime is sorted out. We should also move the
71 // PostCreateInitialization() out of StoragePartitionImplMap.
72 void SetURLRequestContext(net::URLRequestContextGetter* url_request_context);
73 void SetMediaURLRequestContext(
74 net::URLRequestContextGetter* media_url_request_context);
[email protected]4c3a23582012-08-18 08:54:3475
[email protected]2dec8ec2013-02-07 19:20:3476 base::FilePath partition_path_;
[email protected]10eb28162012-09-18 03:04:0977 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
78 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
[email protected]4c3a23582012-08-18 08:54:3479 scoped_refptr<quota::QuotaManager> quota_manager_;
80 scoped_refptr<ChromeAppCacheService> appcache_service_;
81 scoped_refptr<fileapi::FileSystemContext> filesystem_context_;
82 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
83 scoped_refptr<DOMStorageContextImpl> dom_storage_context_;
84 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
85
86 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
87};
88
89} // namespace content
90
91#endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_