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

Side by Side Diff: net/base/io_buffer.h

Issue 20099: Fix a memory leak on the async resource handler. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/renderer_host/async_resource_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_IO_BUFFER_H_ 5 #ifndef NET_BASE_IO_BUFFER_H_
6 #define NET_BASE_IO_BUFFER_H_ 6 #define NET_BASE_IO_BUFFER_H_
7 7
8 #include "base/logging.h"
8 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
9 10
10 namespace net { 11 namespace net {
11 12
12 // This is a simple wrapper around a buffer that provides ref counting for 13 // This is a simple wrapper around a buffer that provides ref counting for
13 // easier asynchronous IO handling. 14 // easier asynchronous IO handling.
14 class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> { 15 class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> {
15 public: 16 public:
17 IOBuffer() : data_(NULL) {}
16 explicit IOBuffer(int buffer_size) { 18 explicit IOBuffer(int buffer_size) {
19 DCHECK(buffer_size);
17 data_ = new char[buffer_size]; 20 data_ = new char[buffer_size];
18 } 21 }
19 explicit IOBuffer(char* buffer) : data_(buffer) {} 22 explicit IOBuffer(char* buffer) : data_(buffer) {}
20 virtual ~IOBuffer() { 23 virtual ~IOBuffer() {
21 delete[] data_; 24 delete[] data_;
22 } 25 }
23 26
24 char* data() { return data_; } 27 char* data() { return data_; }
25 28
26 protected: 29 protected:
27 char* data_; 30 char* data_;
28 }; 31 };
29 32
30 } // namespace net 33 } // namespace net
31 34
32 #endif // NET_BASE_IO_BUFFER_H_ 35 #endif // NET_BASE_IO_BUFFER_H_
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/async_resource_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698