OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/browser/resource_context.h" | 5 #include "content/browser/resource_context.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/plugin_process_host.h" | 8 #include "content/browser/plugin_process_host.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "webkit/database/database_tracker.h" | 10 #include "webkit/database/database_tracker.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 ResourceContext::ResourceContext() | |
15 : host_resolver_(NULL), | |
16 request_context_(NULL), | |
17 appcache_service_(NULL), | |
18 database_tracker_(NULL), | |
19 file_system_context_(NULL), | |
20 blob_storage_context_(NULL), | |
21 quota_manager_(NULL), | |
22 host_zoom_map_(NULL), | |
23 media_observer_(NULL), | |
24 media_stream_manager_(NULL), | |
25 audio_manager_(NULL) { | |
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
27 } | |
28 | |
29 ResourceContext::~ResourceContext() { | 14 ResourceContext::~ResourceContext() { |
30 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 15 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
31 // Band-aid for http://crbug.com/94704 until we change plug-in channel | 16 // Band-aid for http://crbug.com/94704 until we change plug-in channel |
32 // requests to be owned by the ResourceContext. | 17 // requests to be owned by the ResourceContext. |
33 PluginProcessHost::CancelPendingRequestsForResourceContext(this); | 18 PluginProcessHost::CancelPendingRequestsForResourceContext(this); |
34 } | 19 } |
35 } | 20 } |
36 | 21 |
37 void* ResourceContext::GetUserData(const void* key) const { | |
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
39 EnsureInitialized(); | |
40 UserDataMap::const_iterator found = user_data_.find(key); | |
41 if (found != user_data_.end()) | |
42 return found->second; | |
43 return NULL; | |
44 } | |
45 | |
46 void ResourceContext::SetUserData(const void* key, void* data) { | |
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
48 user_data_[key] = data; | |
49 } | |
50 | |
51 net::HostResolver* ResourceContext::host_resolver() const { | |
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
53 EnsureInitialized(); | |
54 return host_resolver_; | |
55 } | |
56 | |
57 void ResourceContext::set_host_resolver( | |
58 net::HostResolver* host_resolver) { | |
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
60 host_resolver_ = host_resolver; | |
61 } | |
62 | |
63 net::URLRequestContext* ResourceContext::request_context() const { | |
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
65 EnsureInitialized(); | |
66 return request_context_; | |
67 } | |
68 | |
69 void ResourceContext::set_request_context( | |
70 net::URLRequestContext* request_context) { | |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
72 request_context_ = request_context; | |
73 } | |
74 | |
75 ChromeAppCacheService* ResourceContext::appcache_service() const { | |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
77 EnsureInitialized(); | |
78 return appcache_service_; | |
79 } | |
80 | |
81 void ResourceContext::set_appcache_service( | |
82 ChromeAppCacheService* appcache_service) { | |
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
84 appcache_service_ = appcache_service; | |
85 } | |
86 | |
87 webkit_database::DatabaseTracker* ResourceContext::database_tracker() const { | |
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
89 EnsureInitialized(); | |
90 return database_tracker_; | |
91 } | |
92 | |
93 void ResourceContext::set_database_tracker( | |
94 webkit_database::DatabaseTracker* database_tracker) { | |
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
96 database_tracker_ = database_tracker; | |
97 } | |
98 | |
99 fileapi::FileSystemContext* ResourceContext::file_system_context() const { | |
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
101 EnsureInitialized(); | |
102 return file_system_context_; | |
103 } | |
104 | |
105 void ResourceContext::set_file_system_context( | |
106 fileapi::FileSystemContext* context) { | |
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
108 file_system_context_ = context; | |
109 } | |
110 | |
111 ChromeBlobStorageContext* ResourceContext::blob_storage_context() const { | |
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
113 EnsureInitialized(); | |
114 return blob_storage_context_; | |
115 } | |
116 | |
117 void ResourceContext::set_blob_storage_context( | |
118 ChromeBlobStorageContext* context) { | |
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
120 blob_storage_context_ = context; | |
121 } | |
122 | |
123 quota::QuotaManager* ResourceContext::quota_manager() const { | |
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
125 EnsureInitialized(); | |
126 return quota_manager_; | |
127 } | |
128 | |
129 void ResourceContext::set_quota_manager( | |
130 quota::QuotaManager* quota_manager) { | |
131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
132 quota_manager_ = quota_manager; | |
133 } | |
134 | |
135 HostZoomMap* ResourceContext::host_zoom_map() const { | |
136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
137 EnsureInitialized(); | |
138 return host_zoom_map_; | |
139 } | |
140 | |
141 void ResourceContext::set_host_zoom_map(HostZoomMap* host_zoom_map) { | |
142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
143 host_zoom_map_ = host_zoom_map; | |
144 } | |
145 | |
146 MediaObserver* ResourceContext::media_observer() const { | |
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
148 EnsureInitialized(); | |
149 return media_observer_; | |
150 } | |
151 | |
152 void ResourceContext::set_media_observer(MediaObserver* media_observer) { | |
153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
154 media_observer_ = media_observer; | |
155 } | |
156 | |
157 media_stream::MediaStreamManager* | |
158 ResourceContext::media_stream_manager() const { | |
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
160 EnsureInitialized(); | |
161 return media_stream_manager_; | |
162 } | |
163 | |
164 void ResourceContext::set_media_stream_manager( | |
165 media_stream::MediaStreamManager* media_stream_manager) { | |
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
167 media_stream_manager_ = media_stream_manager; | |
168 } | |
169 | |
170 AudioManager* ResourceContext::audio_manager() const { | |
171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
172 EnsureInitialized(); | |
173 return audio_manager_; | |
174 } | |
175 | |
176 void ResourceContext::set_audio_manager(AudioManager* audio_manager) { | |
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
178 audio_manager_ = audio_manager; | |
179 } | |
180 | |
181 } // namespace content | 22 } // namespace content |
OLD | NEW |