OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "chrome/browser/renderer_host/audio_renderer_host.h" | 50 #include "chrome/browser/renderer_host/audio_renderer_host.h" |
51 #include "chrome/browser/renderer_host/blob_message_filter.h" | 51 #include "chrome/browser/renderer_host/blob_message_filter.h" |
52 #include "chrome/browser/renderer_host/database_message_filter.h" | 52 #include "chrome/browser/renderer_host/database_message_filter.h" |
53 #include "chrome/browser/renderer_host/file_utilities_message_filter.h" | 53 #include "chrome/browser/renderer_host/file_utilities_message_filter.h" |
54 #include "chrome/browser/renderer_host/pepper_file_message_filter.h" | 54 #include "chrome/browser/renderer_host/pepper_file_message_filter.h" |
55 #include "chrome/browser/renderer_host/render_message_filter.h" | 55 #include "chrome/browser/renderer_host/render_message_filter.h" |
56 #include "chrome/browser/renderer_host/render_view_host.h" | 56 #include "chrome/browser/renderer_host/render_view_host.h" |
57 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 57 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
58 #include "chrome/browser/renderer_host/render_widget_helper.h" | 58 #include "chrome/browser/renderer_host/render_widget_helper.h" |
59 #include "chrome/browser/renderer_host/render_widget_host.h" | 59 #include "chrome/browser/renderer_host/render_widget_host.h" |
60 #include "chrome/browser/renderer_host/resource_message_filter.h" | |
60 #include "chrome/browser/renderer_host/socket_stream_dispatcher_host.h" | 61 #include "chrome/browser/renderer_host/socket_stream_dispatcher_host.h" |
61 #include "chrome/browser/renderer_host/web_cache_manager.h" | 62 #include "chrome/browser/renderer_host/web_cache_manager.h" |
62 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 63 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
63 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h" | 64 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h" |
64 #include "chrome/browser/speech/speech_input_dispatcher_host.h" | 65 #include "chrome/browser/speech/speech_input_dispatcher_host.h" |
65 #include "chrome/browser/spellcheck_host.h" | 66 #include "chrome/browser/spellcheck_host.h" |
66 #include "chrome/browser/metrics/user_metrics.h" | 67 #include "chrome/browser/metrics/user_metrics.h" |
67 #include "chrome/browser/visitedlink/visitedlink_master.h" | 68 #include "chrome/browser/visitedlink/visitedlink_master.h" |
68 #include "chrome/common/chrome_paths.h" | 69 #include "chrome/common/chrome_paths.h" |
69 #include "chrome/common/chrome_switches.h" | 70 #include "chrome/common/chrome_switches.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 // Go ahead and send whatever we already have buffered up. | 214 // Go ahead and send whatever we already have buffered up. |
214 Update(sender); | 215 Update(sender); |
215 } | 216 } |
216 | 217 |
217 private: | 218 private: |
218 bool reset_needed_; | 219 bool reset_needed_; |
219 bool has_receiver_; | 220 bool has_receiver_; |
220 VisitedLinkCommon::Fingerprints pending_; | 221 VisitedLinkCommon::Fingerprints pending_; |
221 }; | 222 }; |
222 | 223 |
224 namespace { | |
brettw
2010/12/15 21:31:10
Usually we'd put anonymous namespace first. In thi
jam
2010/12/15 21:41:04
I had tried that, but those classes are forward de
| |
225 | |
226 // Helper class that we pass to ResourceMessageFilter so that it can find the | |
227 // right URLRequestContext for a request. | |
228 class RendererURLRequestContextOverride | |
229 : public ResourceMessageFilter::URLRequestContextOverride { | |
230 public: | |
231 explicit RendererURLRequestContextOverride(Profile* profile) | |
232 : request_context_(profile->GetRequestContext()), | |
brettw
2010/12/15 21:31:10
2 more spaces indent.
jam
2010/12/15 21:41:04
Done.
| |
233 media_request_context_(profile->GetRequestContextForMedia()) { | |
234 } | |
235 | |
236 virtual URLRequestContext* GetRequestContext( | |
237 uint32 request_id, ResourceType::Type resource_type) { | |
238 URLRequestContextGetter* request_context = request_context_; | |
239 // If the request has resource type of ResourceType::MEDIA, we use a request | |
240 // context specific to media for handling it because these resources have | |
241 // specific needs for caching. | |
242 if (resource_type == ResourceType::MEDIA) | |
243 request_context = media_request_context_; | |
244 return request_context->GetURLRequestContext(); | |
245 } | |
246 | |
247 private: | |
248 scoped_refptr<URLRequestContextGetter> request_context_; | |
249 scoped_refptr<URLRequestContextGetter> media_request_context_; | |
250 }; | |
251 | |
252 } // namespace | |
253 | |
223 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) | 254 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) |
224 : RenderProcessHost(profile), | 255 : RenderProcessHost(profile), |
225 visible_widgets_(0), | 256 visible_widgets_(0), |
226 backgrounded_(true), | 257 backgrounded_(true), |
227 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( | 258 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( |
228 base::TimeDelta::FromSeconds(5), | 259 base::TimeDelta::FromSeconds(5), |
229 this, &BrowserRenderProcessHost::ClearTransportDIBCache)), | 260 this, &BrowserRenderProcessHost::ClearTransportDIBCache)), |
230 accessibility_enabled_(false), | 261 accessibility_enabled_(false), |
231 extension_process_(false), | 262 extension_process_(false), |
232 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 263 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 this)); | 413 this)); |
383 | 414 |
384 fast_shutdown_started_ = false; | 415 fast_shutdown_started_ = false; |
385 } | 416 } |
386 | 417 |
387 return true; | 418 return true; |
388 } | 419 } |
389 | 420 |
390 void BrowserRenderProcessHost::CreateMessageFilters() { | 421 void BrowserRenderProcessHost::CreateMessageFilters() { |
391 scoped_refptr<RenderMessageFilter> render_message_filter( | 422 scoped_refptr<RenderMessageFilter> render_message_filter( |
392 new RenderMessageFilter(g_browser_process->resource_dispatcher_host(), | 423 new RenderMessageFilter(id(), |
393 id(), | |
394 PluginService::GetInstance(), | 424 PluginService::GetInstance(), |
395 g_browser_process->print_job_manager(), | |
396 profile(), | 425 profile(), |
397 widget_helper_)); | 426 widget_helper_)); |
398 channel_->AddFilter(render_message_filter); | 427 channel_->AddFilter(render_message_filter); |
399 | 428 |
429 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( | |
430 new RendererURLRequestContextOverride(profile())); | |
431 | |
432 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | |
433 id(), ChildProcessInfo::RENDER_PROCESS, | |
434 g_browser_process->resource_dispatcher_host()); | |
435 resource_message_filter->set_url_request_context_override( | |
436 url_request_context_override); | |
437 channel_->AddFilter(resource_message_filter); | |
438 | |
400 channel_->AddFilter(new AudioRendererHost()); | 439 channel_->AddFilter(new AudioRendererHost()); |
401 channel_->AddFilter( | 440 channel_->AddFilter( |
402 new AppCacheDispatcherHost(profile()->GetRequestContext(), id())); | 441 new AppCacheDispatcherHost(profile()->GetRequestContext(), id())); |
403 channel_->AddFilter(new DOMStorageMessageFilter(id(), profile())); | 442 channel_->AddFilter(new DOMStorageMessageFilter(id(), profile())); |
404 channel_->AddFilter(new IndexedDBDispatcherHost(id(), profile())); | 443 channel_->AddFilter(new IndexedDBDispatcherHost(id(), profile())); |
405 channel_->AddFilter( | 444 channel_->AddFilter( |
406 GeolocationDispatcherHost::New( | 445 GeolocationDispatcherHost::New( |
407 id(), profile()->GetGeolocationPermissionContext())); | 446 id(), profile()->GetGeolocationPermissionContext())); |
408 channel_->AddFilter(new PepperFileMessageFilter(id(), profile())); | 447 channel_->AddFilter(new PepperFileMessageFilter(id(), profile())); |
409 channel_->AddFilter(new speech_input::SpeechInputDispatcherHost(id())); | 448 channel_->AddFilter(new speech_input::SpeechInputDispatcherHost(id())); |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1245 IPC::PlatformFileForTransit file; | 1284 IPC::PlatformFileForTransit file; |
1246 #if defined(OS_POSIX) | 1285 #if defined(OS_POSIX) |
1247 file = base::FileDescriptor(model_file, false); | 1286 file = base::FileDescriptor(model_file, false); |
1248 #elif defined(OS_WIN) | 1287 #elif defined(OS_WIN) |
1249 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, | 1288 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, |
1250 false, DUPLICATE_SAME_ACCESS); | 1289 false, DUPLICATE_SAME_ACCESS); |
1251 #endif | 1290 #endif |
1252 Send(new ViewMsg_SetPhishingModel(file)); | 1291 Send(new ViewMsg_SetPhishingModel(file)); |
1253 } | 1292 } |
1254 } | 1293 } |
OLD | NEW |