diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-29 00:30:47 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-29 00:30:47 +0000 |
commit | 9dea9e1fea04be579e34c634cb3be1b6654ef506 (patch) | |
tree | 6615f05d4b92199300d63cb5f2203ca7345e2cff /webkit/tools/test_shell | |
parent | d615ad7ae65beddc26c9833b7bfd1d7bdb6f3d7b (diff) | |
download | chromium_src-9dea9e1fea04be579e34c634cb3be1b6654ef506.zip chromium_src-9dea9e1fea04be579e34c634cb3be1b6654ef506.tar.gz chromium_src-9dea9e1fea04be579e34c634cb3be1b6654ef506.tar.bz2 |
Change URLRequest to use a ref-counted buffer for actual IO.
This will re-land http://codereview.chromium.org/18390
BUG=5325
Review URL: http://codereview.chromium.org/19004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8847 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r-- | webkit/tools/test_shell/simple_resource_loader_bridge.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 2f66f75..e5b1aff 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -37,6 +37,7 @@ #include "base/thread.h" #include "base/waitable_event.h" #include "net/base/cookie_monster.h" +#include "net/base/io_buffer.h" #include "net/base/net_util.h" #include "net/base/upload_data.h" #include "net/url_request/url_request.h" @@ -104,7 +105,7 @@ class RequestProxy : public URLRequest::Delegate, public base::RefCountedThreadSafe<RequestProxy> { public: // Takes ownership of the params. - RequestProxy() { + RequestProxy() : buf_(new net::IOBuffer(kDataSize)) { } virtual ~RequestProxy() { @@ -155,7 +156,7 @@ class RequestProxy : public URLRequest::Delegate, // Make a local copy of buf_, since AsyncReadData reuses it. scoped_array<char> buf_copy(new char[bytes_read]); - memcpy(buf_copy.get(), buf_, bytes_read); + memcpy(buf_copy.get(), buf_->data(), bytes_read); // Continue reading more data into buf_ // Note: Doing this before notifying our peer ensures our load events get @@ -211,7 +212,7 @@ class RequestProxy : public URLRequest::Delegate, if (request_->status().is_success()) { int bytes_read; - if (request_->Read(buf_, sizeof(buf_), &bytes_read) && bytes_read) { + if (request_->Read(buf_, kDataSize, &bytes_read) && bytes_read) { OnReceivedData(bytes_read); } else if (!request_->status().is_io_pending()) { Done(); @@ -296,7 +297,7 @@ class RequestProxy : public URLRequest::Delegate, static const int kDataSize = 16*1024; // read buffer for async IO - char buf_[kDataSize]; + scoped_refptr<net::IOBuffer> buf_; MessageLoop* owner_loop_; @@ -333,7 +334,7 @@ class SyncRequestProxy : public RequestProxy { } virtual void OnReceivedData(int bytes_read) { - result_->data.append(buf_, bytes_read); + result_->data.append(buf_->data(), bytes_read); AsyncReadData(); // read more (may recurse) } |