Use base::MakeRefCounted instead of new to alloc net::IOBuffer instances.
This CL only handles a difficult case in //jingle. The easy cases were tackled by mechanical CLs, such as https://crrev.com/c/1188959 for //net. Parallel CLs will tackle other difficult cases. ability to reason about instance ownership locally, creating instances via base::MakeRefCounted makes it possible to use 1-based ref-counting in the future (see base/memory/ref_counted.h). net: :IOBuffer is (thread-safe) ref-counted. Asides from improving the Change-Id: I06317e9410389b226fbe7818c8d7138d5bb79050 Reviewed-on: https://chromium-review.googlesource.com/1215464 Reviewed-by: Nicolas Zea <zea@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#590075}
This commit is contained in:

committed by
Commit Bot

parent
dc46b63fa2
commit
473cd281d1
@ -64,9 +64,9 @@ static const uint8_t kSslServerHello[] = {
|
||||
0x00 // null compression
|
||||
};
|
||||
|
||||
net::DrainableIOBuffer* NewDrainableIOBufferWithSize(int size) {
|
||||
return new net::DrainableIOBuffer(base::MakeRefCounted<net::IOBuffer>(size),
|
||||
size);
|
||||
scoped_refptr<net::DrainableIOBuffer> NewDrainableIOBufferWithSize(int size) {
|
||||
return base::MakeRefCounted<net::DrainableIOBuffer>(
|
||||
base::MakeRefCounted<net::IOBuffer>(size), size);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user