summaryrefslogtreecommitdiffstats
path: root/chrome/common/chrome_plugin_unittest.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-29 00:30:47 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-29 00:30:47 +0000
commit9dea9e1fea04be579e34c634cb3be1b6654ef506 (patch)
tree6615f05d4b92199300d63cb5f2203ca7345e2cff /chrome/common/chrome_plugin_unittest.cc
parentd615ad7ae65beddc26c9833b7bfd1d7bdb6f3d7b (diff)
downloadchromium_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 'chrome/common/chrome_plugin_unittest.cc')
-rw-r--r--chrome/common/chrome_plugin_unittest.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/chrome/common/chrome_plugin_unittest.cc b/chrome/common/chrome_plugin_unittest.cc
index bf901b3..d7c581f 100644
--- a/chrome/common/chrome_plugin_unittest.cc
+++ b/chrome/common/chrome_plugin_unittest.cc
@@ -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 @@ namespace {
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 @@ class ChromePluginTest : public testing::Test, public URLRequest::Delegate {
// 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 @@ void ChromePluginTest::OnResponseStarted(URLRequest* request) {
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 @@ void ChromePluginTest::OnReadCompleted(URLRequest* request, int bytes_read) {
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();