OLD | NEW |
1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/resource_message_filter.h" | 5 #include "chrome/browser/renderer_host/resource_message_filter.h" |
6 | 6 |
7 #include "chrome/browser/net/chrome_url_request_context.h" | 7 #include "chrome/browser/net/chrome_url_request_context.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
11 | 11 |
12 | |
13 ResourceMessageFilter::ResourceMessageFilter( | 12 ResourceMessageFilter::ResourceMessageFilter( |
14 int child_id, | 13 int child_id, |
15 ChildProcessInfo::ProcessType process_type, | 14 ChildProcessInfo::ProcessType process_type, |
16 ResourceDispatcherHost* resource_dispatcher_host) | 15 ResourceDispatcherHost* resource_dispatcher_host) |
17 : child_id_(child_id), | 16 : child_id_(child_id), |
18 process_type_(process_type), | 17 process_type_(process_type), |
19 resource_dispatcher_host_(resource_dispatcher_host) { | 18 resource_dispatcher_host_(resource_dispatcher_host) { |
20 } | 19 } |
21 | 20 |
22 ResourceMessageFilter::~ResourceMessageFilter() { | 21 ResourceMessageFilter::~ResourceMessageFilter() { |
23 } | 22 } |
24 | 23 |
25 void ResourceMessageFilter::OnChannelClosing() { | 24 void ResourceMessageFilter::OnChannelClosing() { |
26 BrowserMessageFilter::OnChannelClosing(); | 25 BrowserMessageFilter::OnChannelClosing(); |
27 | 26 |
28 // Unhook us from all pending network requests so they don't get sent to a | 27 // Unhook us from all pending network requests so they don't get sent to a |
29 // deleted object. | 28 // deleted object. |
30 resource_dispatcher_host_->CancelRequestsForProcess(child_id_); | 29 resource_dispatcher_host_->CancelRequestsForProcess(child_id_); |
31 } | 30 } |
32 | 31 |
33 bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message, | 32 bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message, |
34 bool* message_was_ok) { | 33 bool* message_was_ok) { |
35 return resource_dispatcher_host_->OnMessageReceived( | 34 return resource_dispatcher_host_->OnMessageReceived( |
36 message, this, message_was_ok); | 35 message, this, message_was_ok); |
37 } | 36 } |
38 | 37 |
39 ChromeURLRequestContext* ResourceMessageFilter::GetURLRequestContext( | 38 ChromeURLRequestContext* ResourceMessageFilter::GetURLRequestContext( |
40 uint32 request_id, ResourceType::Type resource_type) { | 39 uint32 request_id, ResourceType::Type resource_type) { |
41 URLRequestContext* rv = NULL; | 40 net::URLRequestContext* rv = NULL; |
42 if (url_request_context_override_.get()) { | 41 if (url_request_context_override_.get()) { |
43 rv = url_request_context_override_->GetRequestContext( | 42 rv = url_request_context_override_->GetRequestContext( |
44 request_id, resource_type); | 43 request_id, resource_type); |
45 } | 44 } |
46 | 45 |
47 if (!rv) { | 46 if (!rv) { |
48 URLRequestContextGetter* context_getter = | 47 URLRequestContextGetter* context_getter = |
49 Profile::GetDefaultRequestContext(); | 48 Profile::GetDefaultRequestContext(); |
50 if (context_getter) | 49 if (context_getter) |
51 rv = context_getter->GetURLRequestContext(); | 50 rv = context_getter->GetURLRequestContext(); |
52 } | 51 } |
53 | 52 |
54 return static_cast<ChromeURLRequestContext*>(rv); | 53 return static_cast<ChromeURLRequestContext*>(rv); |
55 } | 54 } |
OLD | NEW |