diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 17:14:27 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 17:14:27 +0000 |
commit | 98c45033eb243d49211df0697fd7b2a699621c24 (patch) | |
tree | 618255ecfa151a1bcea23e645b759eff54cb29eb /chrome/browser/renderer_host/async_resource_handler.cc | |
parent | b36eabf380e2818b8b181f8af4bb4a89aeabe59b (diff) | |
download | chromium_src-98c45033eb243d49211df0697fd7b2a699621c24.zip chromium_src-98c45033eb243d49211df0697fd7b2a699621c24.tar.gz chromium_src-98c45033eb243d49211df0697fd7b2a699621c24.tar.bz2 |
Only double the buffer when AsyncResourceHandler's caller fill the buffer.
This is an update to r29904 and came out of a discussion with Darin.
BUG=http://crbug.com/24493
TEST=NONE
Review URL: http://codereview.chromium.org/335010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30058 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/async_resource_handler.cc')
-rw-r--r-- | chrome/browser/renderer_host/async_resource_handler.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/chrome/browser/renderer_host/async_resource_handler.cc b/chrome/browser/renderer_host/async_resource_handler.cc index da188b6..7e83320 100644 --- a/chrome/browser/renderer_host/async_resource_handler.cc +++ b/chrome/browser/renderer_host/async_resource_handler.cc @@ -18,10 +18,10 @@ namespace { SharedIOBuffer* g_spare_read_buffer = NULL; // The initial size of the shared memory buffer. (32 kilobytes). -const int kReadBufSize = 32768; +const int kInitialReadBufSize = 32768; // The maximum size of the shared memory buffer. (512 kilobytes). -const int kMaxBufSize = 524288; +const int kMaxReadBufSize = 524288; } // namespace @@ -66,7 +66,7 @@ AsyncResourceHandler::AsyncResourceHandler( routing_id_(routing_id), process_handle_(process_handle), rdh_(resource_dispatcher_host), - next_buffer_size_(kReadBufSize) { + next_buffer_size_(kInitialReadBufSize) { } bool AsyncResourceHandler::OnUploadProgress(int request_id, @@ -104,7 +104,7 @@ bool AsyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, CHECK(read_buffer_->data()); *buf = read_buffer_.get(); - *buf_size = read_buffer_.get()->buffer_size(); + *buf_size = read_buffer_->buffer_size(); } else { read_buffer_ = new SharedIOBuffer(next_buffer_size_); if (!read_buffer_->ok()) { @@ -117,8 +117,6 @@ bool AsyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, *buf_size = next_buffer_size_; } - next_buffer_size_ = std::min(next_buffer_size_ * 2, kMaxBufSize); - return true; } @@ -127,6 +125,13 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { return true; DCHECK(read_buffer_.get()); + 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 (!rdh_->WillSendData(process_id_, request_id)) { // We should not send this data now, we have too many pending requests. return true; |