OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ | 5 #ifndef CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ |
6 #define CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ | 6 #define CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 | 10 |
11 namespace quota { | 11 namespace storage { |
12 class QuotaManager; | 12 class QuotaManager; |
13 } | 13 } |
14 | 14 |
15 namespace fileapi { | 15 namespace storage { |
16 class FileSystemContext; | 16 class FileSystemContext; |
17 } // namespace fileapi | 17 } // namespace storage |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 class URLRequestContextGetter; | 20 class URLRequestContextGetter; |
21 } | 21 } |
22 | 22 |
23 namespace webkit_database { | 23 namespace storage { |
24 class DatabaseTracker; | 24 class DatabaseTracker; |
25 } // namespace webkit_database | 25 } // namespace storage |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 class ChromeAppCacheService; | 28 class ChromeAppCacheService; |
29 class IndexedDBContextImpl; | 29 class IndexedDBContextImpl; |
30 class ServiceWorkerContextWrapper; | 30 class ServiceWorkerContextWrapper; |
31 | 31 |
32 // Contains the data from StoragePartition for use by Worker APIs. | 32 // Contains the data from StoragePartition for use by Worker APIs. |
33 // | 33 // |
34 // StoragePartition meant for the UI so we can't use it directly in many | 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, | 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 | 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, | 37 // thread. Instead of changing the lifetime semantics of StoragePartition, |
38 // we just create a parallel struct here to simplify the APIs of various | 38 // we just create a parallel struct here to simplify the APIs of various |
39 // methods in WorkerServiceImpl. | 39 // methods in WorkerServiceImpl. |
40 // | 40 // |
41 // This class is effectively a struct, but we make it a class because we want to | 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 | 42 // define copy constructors, assignment operators, and an Equals() function for |
43 // it which makes it look awkward as a struct. | 43 // it which makes it look awkward as a struct. |
44 class CONTENT_EXPORT WorkerStoragePartition { | 44 class CONTENT_EXPORT WorkerStoragePartition { |
45 public: | 45 public: |
46 WorkerStoragePartition( | 46 WorkerStoragePartition( |
47 net::URLRequestContextGetter* url_request_context, | 47 net::URLRequestContextGetter* url_request_context, |
48 net::URLRequestContextGetter* media_url_request_context, | 48 net::URLRequestContextGetter* media_url_request_context, |
49 ChromeAppCacheService* appcache_service, | 49 ChromeAppCacheService* appcache_service, |
50 quota::QuotaManager* quota_manager, | 50 storage::QuotaManager* quota_manager, |
51 fileapi::FileSystemContext* filesystem_context, | 51 storage::FileSystemContext* filesystem_context, |
52 webkit_database::DatabaseTracker* database_tracker, | 52 storage::DatabaseTracker* database_tracker, |
53 IndexedDBContextImpl* indexed_db_context, | 53 IndexedDBContextImpl* indexed_db_context, |
54 ServiceWorkerContextWrapper* service_worker_context); | 54 ServiceWorkerContextWrapper* service_worker_context); |
55 ~WorkerStoragePartition(); | 55 ~WorkerStoragePartition(); |
56 | 56 |
57 // Declaring so these don't get inlined which has the unfortunate effect of | 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 | 58 // requiring all including classes to have the full definition of every member |
59 // type. | 59 // type. |
60 WorkerStoragePartition(const WorkerStoragePartition& other); | 60 WorkerStoragePartition(const WorkerStoragePartition& other); |
61 const WorkerStoragePartition& operator=(const WorkerStoragePartition& rhs); | 61 const WorkerStoragePartition& operator=(const WorkerStoragePartition& rhs); |
62 | 62 |
63 bool Equals(const WorkerStoragePartition& other) const; | 63 bool Equals(const WorkerStoragePartition& other) const; |
64 | 64 |
65 net::URLRequestContextGetter* url_request_context() const { | 65 net::URLRequestContextGetter* url_request_context() const { |
66 return url_request_context_.get(); | 66 return url_request_context_.get(); |
67 } | 67 } |
68 | 68 |
69 net::URLRequestContextGetter* media_url_request_context() const { | 69 net::URLRequestContextGetter* media_url_request_context() const { |
70 return media_url_request_context_.get(); | 70 return media_url_request_context_.get(); |
71 } | 71 } |
72 | 72 |
73 ChromeAppCacheService* appcache_service() const { | 73 ChromeAppCacheService* appcache_service() const { |
74 return appcache_service_.get(); | 74 return appcache_service_.get(); |
75 } | 75 } |
76 | 76 |
77 quota::QuotaManager* quota_manager() const { | 77 storage::QuotaManager* quota_manager() const { return quota_manager_.get(); } |
78 return quota_manager_.get(); | |
79 } | |
80 | 78 |
81 fileapi::FileSystemContext* filesystem_context() const { | 79 storage::FileSystemContext* filesystem_context() const { |
82 return filesystem_context_.get(); | 80 return filesystem_context_.get(); |
83 } | 81 } |
84 | 82 |
85 webkit_database::DatabaseTracker* database_tracker() const { | 83 storage::DatabaseTracker* database_tracker() const { |
86 return database_tracker_.get(); | 84 return database_tracker_.get(); |
87 } | 85 } |
88 | 86 |
89 IndexedDBContextImpl* indexed_db_context() const { | 87 IndexedDBContextImpl* indexed_db_context() const { |
90 return indexed_db_context_.get(); | 88 return indexed_db_context_.get(); |
91 } | 89 } |
92 | 90 |
93 ServiceWorkerContextWrapper* service_worker_context() const { | 91 ServiceWorkerContextWrapper* service_worker_context() const { |
94 return service_worker_context_.get(); | 92 return service_worker_context_.get(); |
95 } | 93 } |
96 | 94 |
97 private: | 95 private: |
98 void Copy(const WorkerStoragePartition& other); | 96 void Copy(const WorkerStoragePartition& other); |
99 | 97 |
100 scoped_refptr<net::URLRequestContextGetter> url_request_context_; | 98 scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
101 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; | 99 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; |
102 scoped_refptr<ChromeAppCacheService> appcache_service_; | 100 scoped_refptr<ChromeAppCacheService> appcache_service_; |
103 scoped_refptr<quota::QuotaManager> quota_manager_; | 101 scoped_refptr<storage::QuotaManager> quota_manager_; |
104 scoped_refptr<fileapi::FileSystemContext> filesystem_context_; | 102 scoped_refptr<storage::FileSystemContext> filesystem_context_; |
105 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 103 scoped_refptr<storage::DatabaseTracker> database_tracker_; |
106 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; | 104 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
107 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 105 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
108 }; | 106 }; |
109 | 107 |
110 // WorkerStoragePartitionId can be used to identify each | 108 // WorkerStoragePartitionId can be used to identify each |
111 // WorkerStoragePartitions. We can hold WorkerStoragePartitionId without | 109 // WorkerStoragePartitions. We can hold WorkerStoragePartitionId without |
112 // extending the lifetime of all objects in the WorkerStoragePartition. | 110 // extending the lifetime of all objects in the WorkerStoragePartition. |
113 // That means that holding a WorkerStoragePartitionId doesn't mean the | 111 // That means that holding a WorkerStoragePartitionId doesn't mean the |
114 // corresponding partition and its members are kept alive. | 112 // corresponding partition and its members are kept alive. |
115 class CONTENT_EXPORT WorkerStoragePartitionId { | 113 class CONTENT_EXPORT WorkerStoragePartitionId { |
116 public: | 114 public: |
117 explicit WorkerStoragePartitionId(const WorkerStoragePartition& partition); | 115 explicit WorkerStoragePartitionId(const WorkerStoragePartition& partition); |
118 ~WorkerStoragePartitionId(); | 116 ~WorkerStoragePartitionId(); |
119 bool Equals(const WorkerStoragePartitionId& other) const; | 117 bool Equals(const WorkerStoragePartitionId& other) const; |
120 | 118 |
121 private: | 119 private: |
122 net::URLRequestContextGetter* url_request_context_; | 120 net::URLRequestContextGetter* url_request_context_; |
123 net::URLRequestContextGetter* media_url_request_context_; | 121 net::URLRequestContextGetter* media_url_request_context_; |
124 ChromeAppCacheService* appcache_service_; | 122 ChromeAppCacheService* appcache_service_; |
125 quota::QuotaManager* quota_manager_; | 123 storage::QuotaManager* quota_manager_; |
126 fileapi::FileSystemContext* filesystem_context_; | 124 storage::FileSystemContext* filesystem_context_; |
127 webkit_database::DatabaseTracker* database_tracker_; | 125 storage::DatabaseTracker* database_tracker_; |
128 IndexedDBContextImpl* indexed_db_context_; | 126 IndexedDBContextImpl* indexed_db_context_; |
129 ServiceWorkerContextWrapper* service_worker_context_; | 127 ServiceWorkerContextWrapper* service_worker_context_; |
130 }; | 128 }; |
131 | 129 |
132 } // namespace content | 130 } // namespace content |
133 | 131 |
134 #endif // CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ | 132 #endif // CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ |
OLD | NEW |