summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-24 02:39:54 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-24 02:39:54 +0000
commite993abfe81feaa374d476828a44942d296bdcc78 (patch)
tree201fffef0ba93ce41afaf2bd6e61e05b61c04028 /net/base
parent0afe80d755b899c188313629ea3f45f0fe5be981 (diff)
downloadchromium_src-e993abfe81feaa374d476828a44942d296bdcc78.zip
chromium_src-e993abfe81feaa374d476828a44942d296bdcc78.tar.gz
chromium_src-e993abfe81feaa374d476828a44942d296bdcc78.tar.bz2
revert r8603
Review URL: http://codereview.chromium.org/18576 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/bzip2_filter_unittest.cc7
-rw-r--r--net/base/completion_callback.h17
-rw-r--r--net/base/filter.cc8
-rw-r--r--net/base/filter.h7
-rw-r--r--net/base/gzip_filter_unittest.cc13
-rw-r--r--net/base/io_buffer.h32
-rw-r--r--net/base/sdch_filter_unittest.cc4
7 files changed, 17 insertions, 71 deletions
diff --git a/net/base/bzip2_filter_unittest.cc b/net/base/bzip2_filter_unittest.cc
index ae80305..e246726 100644
--- a/net/base/bzip2_filter_unittest.cc
+++ b/net/base/bzip2_filter_unittest.cc
@@ -122,7 +122,7 @@ class BZip2FilterUnitTest : public PlatformTest {
break;
encode_data_len = std::min(encode_avail_size,
filter->stream_buffer_size());
- memcpy(filter->stream_buffer()->data(), encode_next, encode_data_len);
+ memcpy(filter->stream_buffer(), encode_next, encode_data_len);
filter->FlushStreamBuffer(encode_data_len);
encode_next += encode_data_len;
encode_avail_size -= encode_data_len;
@@ -162,7 +162,7 @@ class BZip2FilterUnitTest : public PlatformTest {
int source_len,
char* dest,
int* dest_len) {
- memcpy(filter->stream_buffer()->data(), source, source_len);
+ memcpy(filter->stream_buffer(), source, source_len);
filter->FlushStreamBuffer(source_len);
return filter->ReadData(dest, dest_len);
}
@@ -186,8 +186,7 @@ TEST_F(BZip2FilterUnitTest, DecodeBZip2) {
filter_types.push_back(Filter::FILTER_TYPE_BZIP2);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, kDefaultBufferSize));
ASSERT_TRUE(filter.get());
- memcpy(filter->stream_buffer()->data(), bzip2_encode_buffer_,
- bzip2_encode_len_);
+ memcpy(filter->stream_buffer(), bzip2_encode_buffer_, bzip2_encode_len_);
filter->FlushStreamBuffer(bzip2_encode_len_);
char bzip2_decode_buffer[kDefaultBufferSize];
diff --git a/net/base/completion_callback.h b/net/base/completion_callback.h
index f9bb233..4013f71 100644
--- a/net/base/completion_callback.h
+++ b/net/base/completion_callback.h
@@ -6,7 +6,6 @@
#define NET_BASE_COMPLETION_CALLBACK_H__
#include "base/task.h"
-#include "net/base/io_buffer.h"
namespace net {
@@ -42,23 +41,8 @@ class CancelableCompletionCallback :
is_canceled_ = true;
}
- // Attaches the given buffer to this callback so it is valid until the
- // operation completes. TODO(rvargas): This is a temporal fix for bug 5325
- // while I send IOBuffer to the lower layers of code.
- void UseBuffer(net::IOBuffer* buffer) {
- DCHECK(!buffer_.get());
- buffer_ = buffer;
- }
-
- // The callback is not expected anymore so release the buffer.
- void ReleaseBuffer() {
- DCHECK(buffer_.get());
- buffer_ = NULL;
- }
-
virtual void RunWithParams(const Tuple1<int>& params) {
if (is_canceled_) {
- CancelableCompletionCallback<T>::ReleaseBuffer();
base::RefCounted<CancelableCompletionCallback<T> >::Release();
} else {
CompletionCallbackImpl<T>::RunWithParams(params);
@@ -66,7 +50,6 @@ class CancelableCompletionCallback :
}
private:
- scoped_refptr<net::IOBuffer> buffer_;
bool is_canceled_;
};
diff --git a/net/base/filter.cc b/net/base/filter.cc
index 76ee9d9..57a13ef 100644
--- a/net/base/filter.cc
+++ b/net/base/filter.cc
@@ -228,7 +228,7 @@ bool Filter::InitBuffer(int buffer_size) {
if (buffer_size < 0 || stream_buffer())
return false;
- stream_buffer_ = new net::IOBuffer(buffer_size);
+ stream_buffer_.reset(new char[buffer_size]);
if (stream_buffer()) {
stream_buffer_size_ = buffer_size;
@@ -275,9 +275,9 @@ Filter::FilterStatus Filter::ReadData(char* dest_buffer, int* dest_len) {
return next_filter_->ReadData(dest_buffer, dest_len);
if (next_filter_->last_status() == FILTER_NEED_MORE_DATA) {
// Push data into next filter's input.
- net::IOBuffer* next_buffer = next_filter_->stream_buffer();
+ char* next_buffer = next_filter_->stream_buffer();
int next_size = next_filter_->stream_buffer_size();
- last_status_ = ReadFilteredData(next_buffer->data(), &next_size);
+ last_status_ = ReadFilteredData(next_buffer, &next_size);
next_filter_->FlushStreamBuffer(next_size);
switch (last_status_) {
case FILTER_ERROR:
@@ -306,7 +306,7 @@ bool Filter::FlushStreamBuffer(int stream_data_len) {
if (!stream_buffer() || stream_data_len_)
return false;
- next_stream_data_ = stream_buffer()->data();
+ next_stream_data_ = stream_buffer();
stream_data_len_ = stream_data_len;
return true;
}
diff --git a/net/base/filter.h b/net/base/filter.h
index 87ef6fd..71dc438 100644
--- a/net/base/filter.h
+++ b/net/base/filter.h
@@ -35,7 +35,6 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
-#include "net/base/io_buffer.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -92,8 +91,8 @@ class Filter {
// next_filter_, then it obtains data from this specific filter.
FilterStatus ReadData(char* dest_buffer, int* dest_len);
- // Returns a pointer to the stream_buffer_.
- net::IOBuffer* stream_buffer() const { return stream_buffer_.get(); }
+ // Returns a pointer to the beginning of stream_buffer_.
+ char* stream_buffer() const { return stream_buffer_.get(); }
// Returns the maximum size of stream_buffer_ in number of chars.
int stream_buffer_size() const { return stream_buffer_size_; }
@@ -178,7 +177,7 @@ class Filter {
bool was_cached() const { return was_cached_; }
// Buffer to hold the data to be filtered.
- scoped_refptr<net::IOBuffer> stream_buffer_;
+ scoped_array<char> stream_buffer_;
// Maximum size of stream_buffer_ in number of chars.
int stream_buffer_size_;
diff --git a/net/base/gzip_filter_unittest.cc b/net/base/gzip_filter_unittest.cc
index 654ef40..1fe4ee4 100644
--- a/net/base/gzip_filter_unittest.cc
+++ b/net/base/gzip_filter_unittest.cc
@@ -174,7 +174,7 @@ class GZipUnitTest : public PlatformTest {
int encode_data_len;
encode_data_len = std::min(encode_avail_size,
filter->stream_buffer_size());
- memcpy(filter->stream_buffer()->data(), encode_next, encode_data_len);
+ memcpy(filter->stream_buffer(), encode_next, encode_data_len);
filter->FlushStreamBuffer(encode_data_len);
encode_next += encode_data_len;
encode_avail_size -= encode_data_len;
@@ -208,7 +208,7 @@ class GZipUnitTest : public PlatformTest {
// into the buffer.
int DecodeAllWithFilter(Filter* filter, const char* source, int source_len,
char* dest, int* dest_len) {
- memcpy(filter->stream_buffer()->data(), source, source_len);
+ memcpy(filter->stream_buffer(), source, source_len);
filter->FlushStreamBuffer(source_len);
return filter->ReadData(dest, dest_len);
}
@@ -232,8 +232,7 @@ TEST_F(GZipUnitTest, DecodeDeflate) {
filter_types.push_back(Filter::FILTER_TYPE_DEFLATE);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, kDefaultBufferSize));
ASSERT_TRUE(filter.get());
- memcpy(filter->stream_buffer()->data(), deflate_encode_buffer_,
- deflate_encode_len_);
+ memcpy(filter->stream_buffer(), deflate_encode_buffer_, deflate_encode_len_);
filter->FlushStreamBuffer(deflate_encode_len_);
char deflate_decode_buffer[kDefaultBufferSize];
@@ -252,8 +251,7 @@ TEST_F(GZipUnitTest, DecodeGZip) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, kDefaultBufferSize));
ASSERT_TRUE(filter.get());
- memcpy(filter->stream_buffer()->data(), gzip_encode_buffer_,
- gzip_encode_len_);
+ memcpy(filter->stream_buffer(), gzip_encode_buffer_, gzip_encode_len_);
filter->FlushStreamBuffer(gzip_encode_len_);
char gzip_decode_buffer[kDefaultBufferSize];
@@ -277,8 +275,7 @@ TEST_F(GZipUnitTest, DecodeGZipWithMistakenSdch) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, kDefaultBufferSize));
ASSERT_TRUE(filter.get());
- memcpy(filter->stream_buffer()->data(), gzip_encode_buffer_,
- gzip_encode_len_);
+ memcpy(filter->stream_buffer(), gzip_encode_buffer_, gzip_encode_len_);
filter->FlushStreamBuffer(gzip_encode_len_);
char gzip_decode_buffer[kDefaultBufferSize];
diff --git a/net/base/io_buffer.h b/net/base/io_buffer.h
deleted file mode 100644
index b390103..0000000
--- a/net/base/io_buffer.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_BASE_IO_BUFFER_H_
-#define NET_BASE_IO_BUFFER_H_
-
-#include "base/ref_counted.h"
-
-namespace net {
-
-// This is a simple wrapper around a buffer that provides ref counting for
-// easier asynchronous IO handling.
-class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> {
- public:
- explicit IOBuffer(int buffer_size) {
- data_ = new char[buffer_size];
- }
- explicit IOBuffer(char* buffer) : data_(buffer) {}
- virtual ~IOBuffer() {
- delete[] data_;
- }
-
- char* data() { return data_; }
-
- protected:
- char* data_;
-};
-
-} // namespace net
-
-#endif // NET_BASE_IO_BUFFER_H_
diff --git a/net/base/sdch_filter_unittest.cc b/net/base/sdch_filter_unittest.cc
index b5c31c2..21d9aee 100644
--- a/net/base/sdch_filter_unittest.cc
+++ b/net/base/sdch_filter_unittest.cc
@@ -101,7 +101,7 @@ static bool FilterTestData(const std::string& source,
do {
int copy_amount = std::min(input_amount, source.size() - source_index);
if (copy_amount > 0 && status == Filter::FILTER_NEED_MORE_DATA) {
- memcpy(filter->stream_buffer()->data(), source.data() + source_index,
+ memcpy(filter->stream_buffer(), source.data() + source_index,
copy_amount);
filter->FlushStreamBuffer(copy_amount);
source_index += copy_amount;
@@ -152,7 +152,7 @@ TEST_F(SdchFilterTest, BasicBadDictionary) {
// Dictionary hash is 8 characters followed by a null.
std::string dictionary_hash_prefix("123");
- char* input_buffer = filter->stream_buffer()->data();
+ char* input_buffer = filter->stream_buffer();
int input_buffer_size = filter->stream_buffer_size();
EXPECT_EQ(kInputBufferSize, input_buffer_size);