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

Unified Diff: chrome/common/chrome_plugin_unittest.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
Index: chrome/common/chrome_plugin_unittest.cc
===================================================================
--- chrome/common/chrome_plugin_unittest.cc (revision 8565)
+++ chrome/common/chrome_plugin_unittest.cc (working copy)
@@ -11,6 +11,7 @@
#include "chrome/browser/profile.h"
#include "chrome/common/chrome_plugin_lib.h"
#include "chrome/test/chrome_plugin/test_chrome_plugin.h"
+#include "net/base/io_buffer.h"
#include "net/url_request/url_request_test_job.h"
#include "net/url_request/url_request_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,11 +20,13 @@
const wchar_t kDocRoot[] = L"chrome/test/data";
const char kPluginFilename[] = "test_chrome_plugin.dll";
+const int kResponseBufferSize = 4096;
class ChromePluginTest : public testing::Test, public URLRequest::Delegate {
public:
ChromePluginTest()
: request_(NULL),
+ response_buffer_(new net::IOBuffer(kResponseBufferSize)),
plugin_(NULL),
expected_payload_(NULL),
request_context_(new TestURLRequestContext()) {
@@ -75,7 +78,7 @@
// Note: we use URLRequest (instead of URLFetcher) because this allows the
// request to be intercepted.
scoped_ptr<URLRequest> request_;
- char response_buffer_[4096];
+ scoped_refptr<net::IOBuffer> response_buffer_;
std::string response_data_;
ChromePluginLib* plugin_;
@@ -155,7 +158,7 @@
int bytes_read = 0;
if (request_->status().is_success())
- request_->Read(response_buffer_, sizeof(response_buffer_), &bytes_read);
+ request_->Read(response_buffer_, kResponseBufferSize, &bytes_read);
OnReadCompleted(request_.get(), bytes_read);
}
@@ -165,9 +168,8 @@
do {
if (!request_->status().is_success() || bytes_read <= 0)
break;
- response_data_.append(response_buffer_, bytes_read);
- } while (request_->Read(response_buffer_, sizeof(response_buffer_),
- &bytes_read));
+ response_data_.append(response_buffer_->data(), bytes_read);
+ } while (request_->Read(response_buffer_, kResponseBufferSize, &bytes_read));
if (!request_->status().is_io_pending()) {
OnURLRequestComplete();
« no previous file with comments | « chrome/browser/renderer_host/sync_resource_handler.cc ('k') | chrome/common/net/url_request_intercept_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698