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

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

Issue 437077: Remember zoom on a per-host basis.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profile.cc ('k') | chrome/browser/renderer_host/resource_message_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 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"
11 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
10 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
11 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
12 14
13 namespace { 15 namespace {
14 16
15 // When reading, we don't know if we are going to get EOF (0 bytes read), so 17 // When reading, we don't know if we are going to get EOF (0 bytes read), so
16 // we typically have a buffer that we allocated but did not use. We keep 18 // we typically have a buffer that we allocated but did not use. We keep
17 // this buffer around for the next read as a small optimization. 19 // this buffer around for the next read as a small optimization.
18 SharedIOBuffer* g_spare_read_buffer = NULL; 20 SharedIOBuffer* g_spare_read_buffer = NULL;
19 21
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const GURL& new_url, 92 const GURL& new_url,
91 ResourceResponse* response, 93 ResourceResponse* response,
92 bool* defer) { 94 bool* defer) {
93 *defer = true; 95 *defer = true;
94 return receiver_->Send(new ViewMsg_Resource_ReceivedRedirect( 96 return receiver_->Send(new ViewMsg_Resource_ReceivedRedirect(
95 routing_id_, request_id, new_url, response->response_head)); 97 routing_id_, request_id, new_url, response->response_head));
96 } 98 }
97 99
98 bool AsyncResourceHandler::OnResponseStarted(int request_id, 100 bool AsyncResourceHandler::OnResponseStarted(int request_id,
99 ResourceResponse* response) { 101 ResourceResponse* response) {
102 // 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 // 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 // the new content twice.
107 URLRequest* request = rdh_->GetURLRequest(
108 ResourceDispatcherHost::GlobalRequestID(process_id_, request_id));
109 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request);
110 if (info->resource_type() == ResourceType::MAIN_FRAME) {
111 std::string host(request->url().host());
112 ChromeURLRequestContext* context =
113 static_cast<ChromeURLRequestContext*>(request->context());
114 if (!host.empty() && context) {
115 receiver_->Send(new ViewMsg_SetZoomLevelForLoadingHost(info->route_id(),
116 host, context->host_zoom_map()->GetZoomLevel(host)));
117 }
118 }
119
100 receiver_->Send(new ViewMsg_Resource_ReceivedResponse( 120 receiver_->Send(new ViewMsg_Resource_ReceivedResponse(
101 routing_id_, request_id, response->response_head)); 121 routing_id_, request_id, response->response_head));
102 return true; 122 return true;
103 } 123 }
104 124
105 bool AsyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, 125 bool AsyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
106 int* buf_size, int min_size) { 126 int* buf_size, int min_size) {
107 DCHECK(min_size == -1); 127 DCHECK(min_size == -1);
108 128
109 if (g_spare_read_buffer) { 129 if (g_spare_read_buffer) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 209
190 // static 210 // static
191 void AsyncResourceHandler::GlobalCleanup() { 211 void AsyncResourceHandler::GlobalCleanup() {
192 if (g_spare_read_buffer) { 212 if (g_spare_read_buffer) {
193 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). 213 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer().
194 SharedIOBuffer* tmp = g_spare_read_buffer; 214 SharedIOBuffer* tmp = g_spare_read_buffer;
195 g_spare_read_buffer = NULL; 215 g_spare_read_buffer = NULL;
196 tmp->Release(); 216 tmp->Release();
197 } 217 }
198 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/profile.cc ('k') | chrome/browser/renderer_host/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698