blob: 6de28ed2de7ee00b791759f6edb64ee3d67aa449 [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"
9#include "base/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/in_process_webkit/indexed_db_context_impl.h"
14#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(
33 const GURL& storage_origin,
34 net::URLRequestContextGetter* request_context_getter) OVERRIDE;
[email protected]14acc642012-11-17 12:20:1035 virtual void AsyncClearAllData() OVERRIDE;
[email protected]4c3a23582012-08-18 08:54:3436
37 private:
[email protected]10eb28162012-09-18 03:04:0938 friend class StoragePartitionImplMap;
39
[email protected]b471cf42012-11-13 09:11:3040 // The |partition_path| is the absolute path to the root of this
41 // StoragePartition's on-disk storage.
[email protected]1bc28312012-11-08 08:31:5342 //
[email protected]b471cf42012-11-13 09:11:3043 // If |in_memory| is true, the |partition_path| is (ab)used as a way of
44 // distinguishing different in-memory partitions, but nothing is persisted
45 // on to disk.
46 static StoragePartitionImpl* Create(BrowserContext* context,
47 bool in_memory,
[email protected]2dec8ec2013-02-07 19:20:3448 const base::FilePath& profile_path);
[email protected]1bc28312012-11-08 08:31:5349
[email protected]10eb28162012-09-18 03:04:0950 StoragePartitionImpl(
[email protected]2dec8ec2013-02-07 19:20:3451 const base::FilePath& partition_path,
[email protected]10eb28162012-09-18 03:04:0952 quota::QuotaManager* quota_manager,
53 ChromeAppCacheService* appcache_service,
54 fileapi::FileSystemContext* filesystem_context,
55 webkit_database::DatabaseTracker* database_tracker,
56 DOMStorageContextImpl* dom_storage_context,
57 IndexedDBContextImpl* indexed_db_context);
58
59 // Used by StoragePartitionImplMap.
60 //
61 // TODO(ajwong): These should be taken in the constructor and in Create() but
62 // because the URLRequestContextGetter still lives in Profile with a tangled
63 // initialization, if we try to retrieve the URLRequestContextGetter()
64 // before the default StoragePartition is created, we end up reentering the
65 // construction and double-initializing. For now, we retain the legacy
66 // behavior while allowing StoragePartitionImpl to expose these accessors by
67 // letting StoragePartitionImplMap call these two private settings at the
68 // appropriate time. These should move back into the constructor once
69 // URLRequestContextGetter's lifetime is sorted out. We should also move the
70 // PostCreateInitialization() out of StoragePartitionImplMap.
71 void SetURLRequestContext(net::URLRequestContextGetter* url_request_context);
72 void SetMediaURLRequestContext(
73 net::URLRequestContextGetter* media_url_request_context);
[email protected]4c3a23582012-08-18 08:54:3474
[email protected]2dec8ec2013-02-07 19:20:3475 base::FilePath partition_path_;
[email protected]10eb28162012-09-18 03:04:0976 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
77 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
[email protected]4c3a23582012-08-18 08:54:3478 scoped_refptr<quota::QuotaManager> quota_manager_;
79 scoped_refptr<ChromeAppCacheService> appcache_service_;
80 scoped_refptr<fileapi::FileSystemContext> filesystem_context_;
81 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
82 scoped_refptr<DOMStorageContextImpl> dom_storage_context_;
83 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
84
85 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
86};
87
88} // namespace content
89
90#endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_