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

Unified Diff: webkit/tools/test_shell/simple_resource_loader_bridge.cc

Issue 18390: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
« no previous file with comments | « net/url_request/url_request_unittest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/tools/test_shell/simple_resource_loader_bridge.cc
===================================================================
--- webkit/tools/test_shell/simple_resource_loader_bridge.cc (revision 8565)
+++ webkit/tools/test_shell/simple_resource_loader_bridge.cc (working copy)
@@ -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 @@
public base::RefCountedThreadSafe<RequestProxy> {
public:
// Takes ownership of the params.
- RequestProxy() {
+ RequestProxy() : buf_(new net::IOBuffer(kDataSize)) {
}
virtual ~RequestProxy() {
@@ -155,7 +156,7 @@
// 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 @@
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 @@
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 @@
}
virtual void OnReceivedData(int bytes_read) {
- result_->data.append(buf_, bytes_read);
+ result_->data.append(buf_->data(), bytes_read);
AsyncReadData(); // read more (may recurse)
}
« no previous file with comments | « net/url_request/url_request_unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698