summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-11 20:55:54 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-11 20:55:54 +0000
commitbbbb0374bb19b2a09d54d3da26373ba5b5400f0a (patch)
treea0c03543c6a16382f0c2d28f0d3a204637b4d0fa
parent2590ff7e34aa000603660703a0482a22a04db0f6 (diff)
downloadchromium_src-bbbb0374bb19b2a09d54d3da26373ba5b5400f0a.zip
chromium_src-bbbb0374bb19b2a09d54d3da26373ba5b5400f0a.tar.gz
chromium_src-bbbb0374bb19b2a09d54d3da26373ba5b5400f0a.tar.bz2
Minor nits in IO buffer
While doing restructuring work on filters, I read some of the IObuffer code, and it scared me a bit that there was a public constructor taking a data buffer that was then destroyed. After searching around for how this was used, I realized it is only used by the derived class, and thought that making it protected would save other folks from wondering/searching/checking. Since the size type in other constuctory was int rather than size_t, I also added a DCHECK (mostly out of paranoia). r=rvargas Review URL: http://codereview.chromium.org/43086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11479 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/base/io_buffer.cc2
-rw-r--r--net/base/io_buffer.h4
2 files changed, 4 insertions, 2 deletions
diff --git a/net/base/io_buffer.cc b/net/base/io_buffer.cc
index c9b4532..c2401ab 100644
--- a/net/base/io_buffer.cc
+++ b/net/base/io_buffer.cc
@@ -9,7 +9,7 @@
namespace net {
IOBuffer::IOBuffer(int buffer_size) {
- DCHECK(buffer_size);
+ DCHECK(buffer_size > 0);
data_ = new char[buffer_size];
}
diff --git a/net/base/io_buffer.h b/net/base/io_buffer.h
index 48d69d6..122e434 100644
--- a/net/base/io_buffer.h
+++ b/net/base/io_buffer.h
@@ -15,7 +15,6 @@ class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> {
public:
IOBuffer() : data_(NULL) {}
explicit IOBuffer(int buffer_size);
- explicit IOBuffer(char* data) : data_(data) {}
virtual ~IOBuffer() {
delete[] data_;
}
@@ -23,6 +22,9 @@ class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> {
char* data() { return data_; }
protected:
+ // Only allow derived classes to specify data_.
+ // In all other cases, we own data_, and must delete it at destruction time.
+ explicit IOBuffer(char* data) : data_(data) {}
char* data_;
};