OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/sync_resource_handler.h" | 5 #include "content/browser/renderer_host/sync_resource_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/debugger/devtools_netlog_observer.h" | 8 #include "content/browser/debugger/devtools_netlog_observer.h" |
9 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 9 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
10 #include "content/browser/renderer_host/resource_message_filter.h" | 10 #include "content/browser/renderer_host/resource_message_filter.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 uint64 position, | 40 uint64 position, |
41 uint64 size) { | 41 uint64 size) { |
42 return true; | 42 return true; |
43 } | 43 } |
44 | 44 |
45 bool SyncResourceHandler::OnRequestRedirected( | 45 bool SyncResourceHandler::OnRequestRedirected( |
46 int request_id, | 46 int request_id, |
47 const GURL& new_url, | 47 const GURL& new_url, |
48 ResourceResponse* response, | 48 ResourceResponse* response, |
49 bool* defer) { | 49 bool* defer) { |
50 if (rdh_->delegate()) | 50 if (rdh_->delegate()) { |
51 rdh_->delegate()->OnRequestRedirected(request_, response); | 51 rdh_->delegate()->OnRequestRedirected(request_, filter_->resource_context(), |
| 52 response); |
| 53 } |
52 | 54 |
53 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); | 55 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); |
54 // TODO(darin): It would be much better if this could live in WebCore, but | 56 // TODO(darin): It would be much better if this could live in WebCore, but |
55 // doing so requires API changes at all levels. Similar code exists in | 57 // doing so requires API changes at all levels. Similar code exists in |
56 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-( | 58 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-( |
57 if (new_url.GetOrigin() != result_.final_url.GetOrigin()) { | 59 if (new_url.GetOrigin() != result_.final_url.GetOrigin()) { |
58 LOG(ERROR) << "Cross origin redirect denied"; | 60 LOG(ERROR) << "Cross origin redirect denied"; |
59 return false; | 61 return false; |
60 } | 62 } |
61 result_.final_url = new_url; | 63 result_.final_url = new_url; |
62 return true; | 64 return true; |
63 } | 65 } |
64 | 66 |
65 bool SyncResourceHandler::OnResponseStarted( | 67 bool SyncResourceHandler::OnResponseStarted( |
66 int request_id, | 68 int request_id, |
67 ResourceResponse* response, | 69 ResourceResponse* response, |
68 bool* defer) { | 70 bool* defer) { |
69 if (rdh_->delegate()) | 71 if (rdh_->delegate()) { |
70 rdh_->delegate()->OnResponseStarted(request_, response, filter_); | 72 rdh_->delegate()->OnResponseStarted(request_, filter_->resource_context(), |
| 73 response, filter_); |
| 74 } |
71 | 75 |
72 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); | 76 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); |
73 | 77 |
74 // We don't care about copying the status here. | 78 // We don't care about copying the status here. |
75 result_.headers = response->head.headers; | 79 result_.headers = response->head.headers; |
76 result_.mime_type = response->head.mime_type; | 80 result_.mime_type = response->head.mime_type; |
77 result_.charset = response->head.charset; | 81 result_.charset = response->head.charset; |
78 result_.download_file_path = response->head.download_file_path; | 82 result_.download_file_path = response->head.download_file_path; |
79 result_.request_time = response->head.request_time; | 83 result_.request_time = response->head.request_time; |
80 result_.response_time = response->head.response_time; | 84 result_.response_time = response->head.response_time; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 result_.encoded_data_length = | 120 result_.encoded_data_length = |
117 DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_); | 121 DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_); |
118 | 122 |
119 ResourceHostMsg_SyncLoad::WriteReplyParams(result_message_, result_); | 123 ResourceHostMsg_SyncLoad::WriteReplyParams(result_message_, result_); |
120 filter_->Send(result_message_); | 124 filter_->Send(result_message_); |
121 result_message_ = NULL; | 125 result_message_ = NULL; |
122 return true; | 126 return true; |
123 } | 127 } |
124 | 128 |
125 } // namespace content | 129 } // namespace content |
OLD | NEW |