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_WORKER_HOST_WORKER_STORAGE_PARTITION_H_
6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_
8 #include "base/memory/ref_counted.h"
15 class FileSystemContext
;
16 } // namespace fileapi
19 class URLRequestContextGetter
;
22 namespace webkit_database
{
23 class DatabaseTracker
;
24 } // namespace webkit_database
27 class ChromeAppCacheService
;
28 class IndexedDBContextImpl
;
30 // Contains the data from StoragePartition for use by Worker APIs.
32 // StoragePartition meant for the UI so we can't use it directly in many
33 // Worker APIs that run on the IO thread. While we could make it RefCounted,
34 // the Worker system is the only place that really needs access on the IO
35 // thread. Instead of changing the lifetime semantics of StoragePartition,
36 // we just create a parallel struct here to simplify the APIs of various
37 // methods in WorkerServiceImpl.
39 // This class is effectively a struct, but we make it a class because we want to
40 // define copy constructors, assignment operators, and an Equals() function for
41 // it which makes it look awkward as a struct.
42 class WorkerStoragePartition
{
44 WorkerStoragePartition(
45 net::URLRequestContextGetter
* url_request_context
,
46 net::URLRequestContextGetter
* media_url_request_context
,
47 ChromeAppCacheService
* appcache_service
,
48 quota::QuotaManager
* quota_manager
,
49 fileapi::FileSystemContext
* filesystem_context
,
50 webkit_database::DatabaseTracker
* database_tracker
,
51 IndexedDBContextImpl
* indexed_db_context
);
52 ~WorkerStoragePartition();
54 // Declaring so these don't get inlined which has the unfortunate effect of
55 // requiring all including classes to have the full definition of every member
57 WorkerStoragePartition(const WorkerStoragePartition
& other
);
58 const WorkerStoragePartition
& operator=(const WorkerStoragePartition
& rhs
);
60 bool Equals(const WorkerStoragePartition
& other
) const;
62 net::URLRequestContextGetter
* url_request_context() const {
63 return url_request_context_
.get();
66 net::URLRequestContextGetter
* media_url_request_context() const {
67 return media_url_request_context_
.get();
70 ChromeAppCacheService
* appcache_service() const {
71 return appcache_service_
.get();
74 quota::QuotaManager
* quota_manager() const {
75 return quota_manager_
.get();
78 fileapi::FileSystemContext
* filesystem_context() const {
79 return filesystem_context_
.get();
82 webkit_database::DatabaseTracker
* database_tracker() const {
83 return database_tracker_
.get();
86 IndexedDBContextImpl
* indexed_db_context() const {
87 return indexed_db_context_
.get();
91 void Copy(const WorkerStoragePartition
& other
);
93 scoped_refptr
<net::URLRequestContextGetter
> url_request_context_
;
94 scoped_refptr
<net::URLRequestContextGetter
> media_url_request_context_
;
95 scoped_refptr
<ChromeAppCacheService
> appcache_service_
;
96 scoped_refptr
<quota::QuotaManager
> quota_manager_
;
97 scoped_refptr
<fileapi::FileSystemContext
> filesystem_context_
;
98 scoped_refptr
<webkit_database::DatabaseTracker
> database_tracker_
;
99 scoped_refptr
<IndexedDBContextImpl
> indexed_db_context_
;
102 } // namespace content
104 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_