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/async_resource_handler.h" | 5 #include "content/browser/renderer_host/async_resource_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
14 #include "content/browser/debugger/devtools_netlog_observer.h" | 14 #include "content/browser/debugger/devtools_netlog_observer.h" |
15 #include "content/browser/host_zoom_map_impl.h" | 15 #include "content/browser/host_zoom_map_impl.h" |
16 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
18 #include "content/browser/renderer_host/resource_message_filter.h" | 18 #include "content/browser/renderer_host/resource_message_filter.h" |
| 19 #include "content/browser/resource_context_impl.h" |
19 #include "content/common/resource_messages.h" | 20 #include "content/common/resource_messages.h" |
20 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
21 #include "content/public/browser/global_request_id.h" | 22 #include "content/public/browser/global_request_id.h" |
22 #include "content/public/browser/resource_context.h" | |
23 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 23 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
24 #include "content/public/common/resource_response.h" | 24 #include "content/public/common/resource_response.h" |
25 #include "net/base/io_buffer.h" | 25 #include "net/base/io_buffer.h" |
26 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
27 #include "net/base/net_log.h" | 27 #include "net/base/net_log.h" |
28 #include "webkit/glue/resource_loader_bridge.h" | 28 #include "webkit/glue/resource_loader_bridge.h" |
29 | 29 |
30 using base::TimeTicks; | 30 using base::TimeTicks; |
31 using content::GlobalRequestID; | 31 using content::GlobalRequestID; |
| 32 using content::HostZoomMap; |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 // When reading, we don't know if we are going to get EOF (0 bytes read), so | 36 // When reading, we don't know if we are going to get EOF (0 bytes read), so |
36 // we typically have a buffer that we allocated but did not use. We keep | 37 // we typically have a buffer that we allocated but did not use. We keep |
37 // this buffer around for the next read as a small optimization. | 38 // this buffer around for the next read as a small optimization. |
38 SharedIOBuffer* g_spare_read_buffer = NULL; | 39 SharedIOBuffer* g_spare_read_buffer = NULL; |
39 | 40 |
40 // The initial size of the shared memory buffer. (32 kilobytes). | 41 // The initial size of the shared memory buffer. (32 kilobytes). |
41 const int kInitialReadBufSize = 32768; | 42 const int kInitialReadBufSize = 32768; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // or of having to layout the new content twice. | 128 // or of having to layout the new content twice. |
128 net::URLRequest* request = rdh_->GetURLRequest( | 129 net::URLRequest* request = rdh_->GetURLRequest( |
129 GlobalRequestID(filter_->child_id(), request_id)); | 130 GlobalRequestID(filter_->child_id(), request_id)); |
130 | 131 |
131 if (rdh_->delegate()) | 132 if (rdh_->delegate()) |
132 rdh_->delegate()->OnResponseStarted(request, response, filter_); | 133 rdh_->delegate()->OnResponseStarted(request, response, filter_); |
133 | 134 |
134 DevToolsNetLogObserver::PopulateResponseInfo(request, response); | 135 DevToolsNetLogObserver::PopulateResponseInfo(request, response); |
135 | 136 |
136 content::ResourceContext* resource_context = filter_->resource_context(); | 137 content::ResourceContext* resource_context = filter_->resource_context(); |
137 content::HostZoomMap* host_zoom_map = resource_context->GetHostZoomMap(); | 138 content::HostZoomMap* host_zoom_map = |
| 139 content::GetHostZoomMapForResourceContext(resource_context); |
138 | 140 |
139 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); | 141 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); |
140 if (info->resource_type() == ResourceType::MAIN_FRAME && host_zoom_map) { | 142 if (info->resource_type() == ResourceType::MAIN_FRAME && host_zoom_map) { |
141 GURL request_url(request->url()); | 143 GURL request_url(request->url()); |
142 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( | 144 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( |
143 info->route_id(), | 145 info->route_id(), |
144 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( | 146 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( |
145 request_url)))); | 147 request_url)))); |
146 } | 148 } |
147 | 149 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 278 |
277 // static | 279 // static |
278 void AsyncResourceHandler::GlobalCleanup() { | 280 void AsyncResourceHandler::GlobalCleanup() { |
279 if (g_spare_read_buffer) { | 281 if (g_spare_read_buffer) { |
280 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). | 282 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). |
281 SharedIOBuffer* tmp = g_spare_read_buffer; | 283 SharedIOBuffer* tmp = g_spare_read_buffer; |
282 g_spare_read_buffer = NULL; | 284 g_spare_read_buffer = NULL; |
283 tmp->Release(); | 285 tmp->Release(); |
284 } | 286 } |
285 } | 287 } |
OLD | NEW |