[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / browser / worker_host / worker_storage_partition.h
blob1b59b906d99bd028d0c4268f2944e85eb9291903
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"
10 namespace fileapi {
11 class FileSystemContext;
12 } // namespace fileapi
14 namespace net {
15 class URLRequestContextGetter;
18 namespace webkit_database {
19 class DatabaseTracker;
20 } // namespace webkit_database
22 namespace content {
23 class ChromeAppCacheService;
24 class IndexedDBContextImpl;
26 // Contains the data from StoragePartition for use by Worker APIs.
28 // StoragePartition meant for the UI so we can't use it directly in many
29 // Worker APIs that run on the IO thread. While we could make it RefCounted,
30 // the Worker system is the only place that really needs access on the IO
31 // thread. Instead of changing the lifetime semantics of StoragePartition,
32 // we just create a parallel struct here to simplify the APIs of various
33 // methods in WorkerServiceImpl.
35 // This class is effectively a struct, but we make it a class because we want to
36 // define copy constructors, assignment operators, and an Equals() function for
37 // it which makes it look awkward as a struct.
38 class WorkerStoragePartition {
39 public:
40 WorkerStoragePartition(
41 net::URLRequestContextGetter* url_request_context,
42 net::URLRequestContextGetter* media_url_request_context,
43 ChromeAppCacheService* appcache_service,
44 fileapi::FileSystemContext* filesystem_context,
45 webkit_database::DatabaseTracker* database_tracker,
46 IndexedDBContextImpl* indexed_db_context);
47 ~WorkerStoragePartition();
49 // Declaring so these don't get inlined which has the unfortunate effect of
50 // requiring all including classes to have the full definition of every member
51 // type.
52 WorkerStoragePartition(const WorkerStoragePartition& other);
53 const WorkerStoragePartition& operator=(const WorkerStoragePartition& rhs);
55 bool Equals(const WorkerStoragePartition& other) const;
57 net::URLRequestContextGetter* url_request_context() const {
58 return url_request_context_.get();
61 net::URLRequestContextGetter* media_url_request_context() const {
62 return media_url_request_context_.get();
65 ChromeAppCacheService* appcache_service() const {
66 return appcache_service_.get();
69 fileapi::FileSystemContext* filesystem_context() const {
70 return filesystem_context_.get();
73 webkit_database::DatabaseTracker* database_tracker() const {
74 return database_tracker_.get();
77 IndexedDBContextImpl* indexed_db_context() const {
78 return indexed_db_context_.get();
81 private:
82 void Copy(const WorkerStoragePartition& other);
84 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
85 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
86 scoped_refptr<ChromeAppCacheService> appcache_service_;
87 scoped_refptr<fileapi::FileSystemContext> filesystem_context_;
88 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
89 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
92 } // namespace content
94 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_