OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { | 235 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { |
236 const int kRequiredLength = 256; | 236 const int kRequiredLength = 256; |
237 | 237 |
238 return bytes_read >= kRequiredLength; | 238 return bytes_read >= kRequiredLength; |
239 } | 239 } |
240 | 240 |
241 bool BufferedResourceHandler::KeepBuffering(int bytes_read) { | 241 bool BufferedResourceHandler::KeepBuffering(int bytes_read) { |
242 DCHECK(read_buffer_); | 242 DCHECK(read_buffer_); |
243 if (my_buffer_) { | 243 if (my_buffer_) { |
244 // We are using our own buffer to read, update the main buffer. | 244 // We are using our own buffer to read, update the main buffer. |
| 245 // TODO(darin): We should handle the case where read_buffer_size_ is small! |
| 246 // See RedirectToFileResourceHandler::BufIsFull to see how this impairs |
| 247 // downstream ResourceHandler implementations. |
245 CHECK_LT(bytes_read + bytes_read_, read_buffer_size_); | 248 CHECK_LT(bytes_read + bytes_read_, read_buffer_size_); |
246 memcpy(read_buffer_->data() + bytes_read_, my_buffer_->data(), bytes_read); | 249 memcpy(read_buffer_->data() + bytes_read_, my_buffer_->data(), bytes_read); |
247 my_buffer_ = NULL; | 250 my_buffer_ = NULL; |
248 } | 251 } |
249 bytes_read_ += bytes_read; | 252 bytes_read_ += bytes_read; |
250 finished_ = (bytes_read == 0); | 253 finished_ = (bytes_read == 0); |
251 | 254 |
252 if (sniff_content_) { | 255 if (sniff_content_) { |
253 std::string type_hint, new_type; | 256 std::string type_hint, new_type; |
254 request_->GetMimeType(&type_hint); | 257 request_->GetMimeType(&type_hint); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 wait_for_plugins_ = false; | 482 wait_for_plugins_ = false; |
480 if (!request_) | 483 if (!request_) |
481 return; | 484 return; |
482 | 485 |
483 ResourceDispatcherHostRequestInfo* info = | 486 ResourceDispatcherHostRequestInfo* info = |
484 ResourceDispatcherHost::InfoForRequest(request_); | 487 ResourceDispatcherHost::InfoForRequest(request_); |
485 host_->PauseRequest(info->child_id(), info->request_id(), false); | 488 host_->PauseRequest(info->child_id(), info->request_id(), false); |
486 if (!CompleteResponseStarted(info->request_id(), false)) | 489 if (!CompleteResponseStarted(info->request_id(), false)) |
487 host_->CancelRequest(info->child_id(), info->request_id(), false); | 490 host_->CancelRequest(info->child_id(), info->request_id(), false); |
488 } | 491 } |
OLD | NEW |