Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1310)

Side by Side Diff: chrome/browser/renderer_host/async_resource_handler.cc

Issue 460108: Implement ResourceQueue, an object that makes it easy to delay starting (Closed)
Patch Set: nitfixing Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/logging.h" 7 #include "base/logging.h"
8 #include "base/process.h" 8 #include "base/process.h"
9 #include "base/shared_memory.h" 9 #include "base/shared_memory.h"
10 #include "chrome/browser/net/chrome_url_request_context.h" 10 #include "chrome/browser/net/chrome_url_request_context.h"
11 #include "chrome/browser/renderer_host/global_request_id.h"
11 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" 12 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
12 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
13 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
14 15
15 namespace { 16 namespace {
16 17
17 // When reading, we don't know if we are going to get EOF (0 bytes read), so 18 // When reading, we don't know if we are going to get EOF (0 bytes read), so
18 // we typically have a buffer that we allocated but did not use. We keep 19 // we typically have a buffer that we allocated but did not use. We keep
19 // this buffer around for the next read as a small optimization. 20 // this buffer around for the next read as a small optimization.
20 SharedIOBuffer* g_spare_read_buffer = NULL; 21 SharedIOBuffer* g_spare_read_buffer = NULL;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 99 }
99 100
100 bool AsyncResourceHandler::OnResponseStarted(int request_id, 101 bool AsyncResourceHandler::OnResponseStarted(int request_id,
101 ResourceResponse* response) { 102 ResourceResponse* response) {
102 // For changes to the main frame, inform the renderer of the new URL's zoom 103 // For changes to the main frame, inform the renderer of the new URL's zoom
103 // level before the request actually commits. This way the renderer will be 104 // level before the request actually commits. This way the renderer will be
104 // able to set the zoom level precisely at the time the request commits, 105 // able to set the zoom level precisely at the time the request commits,
105 // avoiding the possibility of zooming the old content or of having to layout 106 // avoiding the possibility of zooming the old content or of having to layout
106 // the new content twice. 107 // the new content twice.
107 URLRequest* request = rdh_->GetURLRequest( 108 URLRequest* request = rdh_->GetURLRequest(
108 ResourceDispatcherHost::GlobalRequestID(process_id_, request_id)); 109 GlobalRequestID(process_id_, request_id));
109 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); 110 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request);
110 if (info->resource_type() == ResourceType::MAIN_FRAME) { 111 if (info->resource_type() == ResourceType::MAIN_FRAME) {
111 std::string host(request->url().host()); 112 std::string host(request->url().host());
112 ChromeURLRequestContext* context = 113 ChromeURLRequestContext* context =
113 static_cast<ChromeURLRequestContext*>(request->context()); 114 static_cast<ChromeURLRequestContext*>(request->context());
114 if (!host.empty() && context) { 115 if (!host.empty() && context) {
115 receiver_->Send(new ViewMsg_SetZoomLevelForLoadingHost(info->route_id(), 116 receiver_->Send(new ViewMsg_SetZoomLevelForLoadingHost(info->route_id(),
116 host, context->host_zoom_map()->GetZoomLevel(host))); 117 host, context->host_zoom_map()->GetZoomLevel(host)));
117 } 118 }
118 } 119 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 210
210 // static 211 // static
211 void AsyncResourceHandler::GlobalCleanup() { 212 void AsyncResourceHandler::GlobalCleanup() {
212 if (g_spare_read_buffer) { 213 if (g_spare_read_buffer) {
213 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). 214 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer().
214 SharedIOBuffer* tmp = g_spare_read_buffer; 215 SharedIOBuffer* tmp = g_spare_read_buffer;
215 g_spare_read_buffer = NULL; 216 g_spare_read_buffer = NULL;
216 tmp->Release(); 217 tmp->Release();
217 } 218 }
218 } 219 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/user_script_listener.cc ('k') | chrome/browser/renderer_host/cross_site_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698