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

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

Issue 125024: Handle file descriptor exhaustions a little more gracefully. This prevents th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 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 | « base/shared_memory_posix.cc ('k') | no next file » | 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 "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 DCHECK(!my_buffer_.get()); 87 DCHECK(!my_buffer_.get());
88 my_buffer_ = new net::IOBuffer(kMaxBytesToSniff); 88 my_buffer_ = new net::IOBuffer(kMaxBytesToSniff);
89 *buf = my_buffer_.get(); 89 *buf = my_buffer_.get();
90 *buf_size = kMaxBytesToSniff; 90 *buf_size = kMaxBytesToSniff;
91 return true; 91 return true;
92 } 92 }
93 93
94 if (finished_) 94 if (finished_)
95 return false; 95 return false;
96 96
97 bool ret = real_handler_->OnWillRead(request_id, buf, buf_size, min_size); 97 if (!real_handler_->OnWillRead(request_id, buf, buf_size, min_size)) {
98 return false;
99 }
98 read_buffer_ = *buf; 100 read_buffer_ = *buf;
99 read_buffer_size_ = *buf_size; 101 read_buffer_size_ = *buf_size;
100 DCHECK(read_buffer_size_ >= kMaxBytesToSniff * 2); 102 DCHECK(read_buffer_size_ >= kMaxBytesToSniff * 2);
101 bytes_read_ = 0; 103 bytes_read_ = 0;
102 return ret; 104 return true;
103 } 105 }
104 106
105 bool BufferedResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { 107 bool BufferedResourceHandler::OnReadCompleted(int request_id, int* bytes_read) {
106 if (sniff_content_ || should_buffer_) { 108 if (sniff_content_ || should_buffer_) {
107 if (KeepBuffering(*bytes_read)) 109 if (KeepBuffering(*bytes_read))
108 return true; 110 return true;
109 111
110 LOG(INFO) << "Finished buffering " << request_->url().spec(); 112 LOG(INFO) << "Finished buffering " << request_->url().spec();
111 sniff_content_ = should_buffer_ = false; 113 sniff_content_ = should_buffer_ = false;
112 *bytes_read = bytes_read_; 114 *bytes_read = bytes_read_;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 real_handler_ = download_handler; 283 real_handler_ = download_handler;
282 } 284 }
283 return real_handler_->OnResponseStarted(request_id, response_); 285 return real_handler_->OnResponseStarted(request_id, response_);
284 } 286 }
285 287
286 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { 288 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) {
287 const int kRequiredLength = 256; 289 const int kRequiredLength = 256;
288 290
289 return bytes_read >= kRequiredLength; 291 return bytes_read >= kRequiredLength;
290 } 292 }
OLDNEW
« no previous file with comments | « base/shared_memory_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698