| 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 #include "chrome/browser/renderer_host/async_resource_handler.h" | 5 #include "chrome/browser/renderer_host/async_resource_handler.h" |
| 6 | 6 |
| 7 #include "base/hash_tables.h" | 7 #include "base/hash_tables.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/debugger/devtools_netlog_observer.h" |
| 12 #include "chrome/browser/net/chrome_url_request_context.h" | 13 #include "chrome/browser/net/chrome_url_request_context.h" |
| 13 #include "chrome/browser/net/load_timing_observer.h" | 14 #include "chrome/browser/net/load_timing_observer.h" |
| 14 #include "chrome/browser/renderer_host/global_request_id.h" | 15 #include "chrome/browser/renderer_host/global_request_id.h" |
| 15 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" | 16 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 16 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
| 17 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 18 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
| 19 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
| 20 #include "webkit/glue/resource_loader_bridge.h" | 21 #include "webkit/glue/resource_loader_bridge.h" |
| 21 | 22 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 98 } |
| 98 | 99 |
| 99 bool AsyncResourceHandler::OnRequestRedirected(int request_id, | 100 bool AsyncResourceHandler::OnRequestRedirected(int request_id, |
| 100 const GURL& new_url, | 101 const GURL& new_url, |
| 101 ResourceResponse* response, | 102 ResourceResponse* response, |
| 102 bool* defer) { | 103 bool* defer) { |
| 103 *defer = true; | 104 *defer = true; |
| 104 URLRequest* request = rdh_->GetURLRequest( | 105 URLRequest* request = rdh_->GetURLRequest( |
| 105 GlobalRequestID(process_id_, request_id)); | 106 GlobalRequestID(process_id_, request_id)); |
| 106 LoadTimingObserver::PopulateTimingInfo(request, response); | 107 LoadTimingObserver::PopulateTimingInfo(request, response); |
| 108 DevToolsNetLogObserver::PopulateResponseInfo(request, response); |
| 107 return receiver_->Send(new ViewMsg_Resource_ReceivedRedirect( | 109 return receiver_->Send(new ViewMsg_Resource_ReceivedRedirect( |
| 108 routing_id_, request_id, new_url, response->response_head)); | 110 routing_id_, request_id, new_url, response->response_head)); |
| 109 } | 111 } |
| 110 | 112 |
| 111 bool AsyncResourceHandler::OnResponseStarted(int request_id, | 113 bool AsyncResourceHandler::OnResponseStarted(int request_id, |
| 112 ResourceResponse* response) { | 114 ResourceResponse* response) { |
| 113 // For changes to the main frame, inform the renderer of the new URL's | 115 // For changes to the main frame, inform the renderer of the new URL's |
| 114 // per-host settings before the request actually commits. This way the | 116 // per-host settings before the request actually commits. This way the |
| 115 // renderer will be able to set these precisely at the time the | 117 // renderer will be able to set these precisely at the time the |
| 116 // request commits, avoiding the possibility of e.g. zooming the old content | 118 // request commits, avoiding the possibility of e.g. zooming the old content |
| 117 // or of having to layout the new content twice. | 119 // or of having to layout the new content twice. |
| 118 URLRequest* request = rdh_->GetURLRequest( | 120 URLRequest* request = rdh_->GetURLRequest( |
| 119 GlobalRequestID(process_id_, request_id)); | 121 GlobalRequestID(process_id_, request_id)); |
| 122 |
| 120 LoadTimingObserver::PopulateTimingInfo(request, response); | 123 LoadTimingObserver::PopulateTimingInfo(request, response); |
| 124 DevToolsNetLogObserver::PopulateResponseInfo(request, response); |
| 121 | 125 |
| 122 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); | 126 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); |
| 123 if (info->resource_type() == ResourceType::MAIN_FRAME) { | 127 if (info->resource_type() == ResourceType::MAIN_FRAME) { |
| 124 GURL request_url(request->url()); | 128 GURL request_url(request->url()); |
| 125 ChromeURLRequestContext* context = | 129 ChromeURLRequestContext* context = |
| 126 static_cast<ChromeURLRequestContext*>(request->context()); | 130 static_cast<ChromeURLRequestContext*>(request->context()); |
| 127 if (context) { | 131 if (context) { |
| 128 receiver_->Send(new ViewMsg_SetContentSettingsForLoadingURL( | 132 receiver_->Send(new ViewMsg_SetContentSettingsForLoadingURL( |
| 129 info->route_id(), request_url, | 133 info->route_id(), request_url, |
| 130 context->host_content_settings_map()->GetContentSettings( | 134 context->host_content_settings_map()->GetContentSettings( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 255 |
| 252 // static | 256 // static |
| 253 void AsyncResourceHandler::GlobalCleanup() { | 257 void AsyncResourceHandler::GlobalCleanup() { |
| 254 if (g_spare_read_buffer) { | 258 if (g_spare_read_buffer) { |
| 255 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). | 259 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). |
| 256 SharedIOBuffer* tmp = g_spare_read_buffer; | 260 SharedIOBuffer* tmp = g_spare_read_buffer; |
| 257 g_spare_read_buffer = NULL; | 261 g_spare_read_buffer = NULL; |
| 258 tmp->Release(); | 262 tmp->Release(); |
| 259 } | 263 } |
| 260 } | 264 } |
| OLD | NEW |