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

Unified Diff: content/browser/renderer_host/async_resource_handler.cc

Issue 10578055: Rewrite guts of ResourceLoader and BufferedResourceHandler to suck less. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/async_resource_handler.cc
===================================================================
--- content/browser/renderer_host/async_resource_handler.cc (revision 144275)
+++ content/browser/renderer_host/async_resource_handler.cc (working copy)
@@ -120,15 +120,8 @@
}
void AsyncResourceHandler::OnDataReceivedACK() {
- // If the pending data count was higher than the max, resume the request.
- if (--pending_data_count_ == kMaxPendingDataMessages) {
- // Decrement the pending data count one more time because we also
- // incremented it before deferring the request.
- --pending_data_count_;
-
- // Resume the request.
+ if (pending_data_count_-- == kMaxPendingDataMessages)
ResumeIfDeferred();
- }
}
bool AsyncResourceHandler::OnUploadProgress(int request_id,
@@ -234,23 +227,20 @@
return true;
}
-bool AsyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read,
+bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read,
bool* defer) {
- if (!*bytes_read)
+ if (!bytes_read)
return true;
DCHECK(read_buffer_.get());
- if (read_buffer_->buffer_size() == *bytes_read) {
+ if (read_buffer_->buffer_size() == bytes_read) {
// The network layer has saturated our buffer. Next time, we should give it
// a bigger buffer for it to fill, to minimize the number of round trips we
// do with the renderer process.
next_buffer_size_ = std::min(next_buffer_size_ * 2, kMaxReadBufSize);
}
- if (!WillSendData(defer)) {
- // We should not send this data now, we have too many pending requests.
- return true;
- }
+ WillSendData(defer);
base::SharedMemoryHandle handle;
if (!read_buffer_->shared_memory()->GiveToProcess(
@@ -271,7 +261,7 @@
int encoded_data_length =
DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_);
filter_->Send(new ResourceMsg_DataReceived(
- routing_id_, request_id, handle, *bytes_read, encoded_data_length));
+ routing_id_, request_id, handle, bytes_read, encoded_data_length));
return true;
}
@@ -322,16 +312,13 @@
}
}
-bool AsyncResourceHandler::WillSendData(bool* defer) {
- if (++pending_data_count_ > kMaxPendingDataMessages) {
+void AsyncResourceHandler::WillSendData(bool* defer) {
+ if (++pending_data_count_ >= kMaxPendingDataMessages) {
// We reached the max number of data messages that can be sent to
// the renderer for a given request. Pause the request and wait for
// the renderer to start processing them before resuming it.
*defer = did_defer_ = true;
- return false;
}
-
- return true;
}
void AsyncResourceHandler::ResumeIfDeferred() {
« no previous file with comments | « content/browser/renderer_host/async_resource_handler.h ('k') | content/browser/renderer_host/buffered_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698