Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / shared_worker / worker_storage_partition.h
blob2f595b0e72ff086ff66831ad40a1d0f6ac662824
1 // Copyright 2014 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_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_
6 #define CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_
8 #include "base/memory/ref_counted.h"
9 #include "content/common/content_export.h"
11 namespace storage {
12 class QuotaManager;
15 namespace storage {
16 class FileSystemContext;
17 } // namespace storage
19 namespace net {
20 class URLRequestContextGetter;
23 namespace storage {
24 class DatabaseTracker;
25 } // namespace storage
27 namespace content {
28 class ChromeAppCacheService;
29 class IndexedDBContextImpl;
30 class ServiceWorkerContextWrapper;
32 // Contains the data from StoragePartition for use by Worker APIs.
34 // StoragePartition meant for the UI so we can't use it directly in many
35 // Worker APIs that run on the IO thread. While we could make it RefCounted,
36 // the Worker system is the only place that really needs access on the IO
37 // thread. Instead of changing the lifetime semantics of StoragePartition,
38 // we just create a parallel struct here to simplify the APIs of various
39 // methods in WorkerServiceImpl.
41 // This class is effectively a struct, but we make it a class because we want to
42 // define copy constructors, assignment operators, and an Equals() function for
43 // it which makes it look awkward as a struct.
44 class CONTENT_EXPORT WorkerStoragePartition {
45 public:
46 WorkerStoragePartition(
47 net::URLRequestContextGetter* url_request_context,
48 net::URLRequestContextGetter* media_url_request_context,
49 ChromeAppCacheService* appcache_service,
50 storage::QuotaManager* quota_manager,
51 storage::FileSystemContext* filesystem_context,
52 storage::DatabaseTracker* database_tracker,
53 IndexedDBContextImpl* indexed_db_context,
54 ServiceWorkerContextWrapper* service_worker_context);
55 ~WorkerStoragePartition();
57 // Declaring so these don't get inlined which has the unfortunate effect of
58 // requiring all including classes to have the full definition of every member
59 // type.
60 WorkerStoragePartition(const WorkerStoragePartition& other);
61 const WorkerStoragePartition& operator=(const WorkerStoragePartition& rhs);
63 bool Equals(const WorkerStoragePartition& other) const;
65 net::URLRequestContextGetter* url_request_context() const {
66 return url_request_context_.get();
69 net::URLRequestContextGetter* media_url_request_context() const {
70 return media_url_request_context_.get();
73 ChromeAppCacheService* appcache_service() const {
74 return appcache_service_.get();
77 storage::QuotaManager* quota_manager() const { return quota_manager_.get(); }
79 storage::FileSystemContext* filesystem_context() const {
80 return filesystem_context_.get();
83 storage::DatabaseTracker* database_tracker() const {
84 return database_tracker_.get();
87 IndexedDBContextImpl* indexed_db_context() const {
88 return indexed_db_context_.get();
91 ServiceWorkerContextWrapper* service_worker_context() const {
92 return service_worker_context_.get();
95 private:
96 void Copy(const WorkerStoragePartition& other);
98 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
99 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_;
100 scoped_refptr<ChromeAppCacheService> appcache_service_;
101 scoped_refptr<storage::QuotaManager> quota_manager_;
102 scoped_refptr<storage::FileSystemContext> filesystem_context_;
103 scoped_refptr<storage::DatabaseTracker> database_tracker_;
104 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
105 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
108 // WorkerStoragePartitionId can be used to identify each
109 // WorkerStoragePartitions. We can hold WorkerStoragePartitionId without
110 // extending the lifetime of all objects in the WorkerStoragePartition.
111 // That means that holding a WorkerStoragePartitionId doesn't mean the
112 // corresponding partition and its members are kept alive.
113 class CONTENT_EXPORT WorkerStoragePartitionId {
114 public:
115 explicit WorkerStoragePartitionId(const WorkerStoragePartition& partition);
116 ~WorkerStoragePartitionId();
117 bool Equals(const WorkerStoragePartitionId& other) const;
119 private:
120 net::URLRequestContextGetter* url_request_context_;
121 net::URLRequestContextGetter* media_url_request_context_;
122 ChromeAppCacheService* appcache_service_;
123 storage::QuotaManager* quota_manager_;
124 storage::FileSystemContext* filesystem_context_;
125 storage::DatabaseTracker* database_tracker_;
126 IndexedDBContextImpl* indexed_db_context_;
127 ServiceWorkerContextWrapper* service_worker_context_;
130 } // namespace content
132 #endif // CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_