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

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

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months 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/net/url_fixer_upper.cc ('k') | chrome/browser/renderer_host/render_view_host.cc » ('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) 2006-2008 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/buffered_resource_handler.h" 5 #include "chrome/browser/renderer_host/buffered_resource_handler.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/mime_sniffer.h" 9 #include "net/base/mime_sniffer.h"
10 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" 10 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
12 #include "chrome/common/url_constants.h"
12 #include "net/base/mime_sniffer.h" 13 #include "net/base/mime_sniffer.h"
13 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
14 #include "net/http/http_response_headers.h" 15 #include "net/http/http_response_headers.h"
15 16
16 namespace { 17 namespace {
17 18
18 const int kMaxBytesToSniff = 512; 19 const int kMaxBytesToSniff = 512;
19 20
20 void RecordSnifferMetrics(bool sniffing_blocked, 21 void RecordSnifferMetrics(bool sniffing_blocked,
21 bool we_would_like_to_sniff, 22 bool we_would_like_to_sniff,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 LOG(INFO) << "To buffer: " << request_->url().spec(); 158 LOG(INFO) << "To buffer: " << request_->url().spec();
158 return true; 159 return true;
159 } 160 }
160 return false; 161 return false;
161 } 162 }
162 163
163 bool BufferedResourceHandler::ShouldBuffer(const GURL& url, 164 bool BufferedResourceHandler::ShouldBuffer(const GURL& url,
164 const std::string& mime_type) { 165 const std::string& mime_type) {
165 // We are willing to buffer for HTTP and HTTPS. 166 // We are willing to buffer for HTTP and HTTPS.
166 bool sniffable_scheme = url.is_empty() || 167 bool sniffable_scheme = url.is_empty() ||
167 url.SchemeIs("http") || 168 url.SchemeIs(chrome::kHttpScheme) ||
168 url.SchemeIs("https"); 169 url.SchemeIs(chrome::kHttpsScheme);
169 if (!sniffable_scheme) 170 if (!sniffable_scheme)
170 return false; 171 return false;
171 172
172 // Today, the only reason to buffer the request is to fix the doctype decoding 173 // Today, the only reason to buffer the request is to fix the doctype decoding
173 // performed by webkit: if there is not enough data it will go to quirks mode. 174 // performed by webkit: if there is not enough data it will go to quirks mode.
174 // We only expect the doctype check to apply to html documents. 175 // We only expect the doctype check to apply to html documents.
175 return mime_type == "text/html"; 176 return mime_type == "text/html";
176 } 177 }
177 178
178 bool BufferedResourceHandler::KeepBuffering(int bytes_read) { 179 bool BufferedResourceHandler::KeepBuffering(int bytes_read) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 real_handler_ = download_handler; 277 real_handler_ = download_handler;
277 } 278 }
278 return real_handler_->OnResponseStarted(request_id, response_); 279 return real_handler_->OnResponseStarted(request_id, response_);
279 } 280 }
280 281
281 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { 282 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) {
282 const int kRequiredLength = 256; 283 const int kRequiredLength = 256;
283 284
284 return bytes_read >= kRequiredLength; 285 return bytes_read >= kRequiredLength;
285 } 286 }
OLDNEW
« no previous file with comments | « chrome/browser/net/url_fixer_upper.cc ('k') | chrome/browser/renderer_host/render_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698