Use base::MakeRefCounted instead of new to alloc net::IOBuffer instances.

This CL only handles a difficult case in //net. 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: I9925444170fcb8ab3740c1a1223c10c5d4060775
Reviewed-on: https://chromium-review.googlesource.com/1215465
Reviewed-by: Bence Béky <[email protected]>
Commit-Queue: Victor Costan <[email protected]>
Cr-Commit-Position: refs/heads/master@{#590268}
diff --git a/net/spdy/spdy_buffer.h b/net/spdy/spdy_buffer.h
index 2a2d168..edcf79a 100644
--- a/net/spdy/spdy_buffer.h
+++ b/net/spdy/spdy_buffer.h
@@ -84,7 +84,7 @@
   // This is used with Socket::Write(), which takes an IOBuffer* that
   // may be written to even after the socket itself is destroyed. (See
   // http://crbug.com/249725 .)
-  IOBuffer* GetIOBufferForRemainingData();
+  scoped_refptr<IOBuffer> GetIOBufferForRemainingData();
 
   // Returns the estimate of dynamically allocated memory in bytes.
   size_t EstimateMemoryUsage() const;