diff options
author | mmenke <mmenke@chromium.org> | 2015-04-21 11:39:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-21 18:39:34 +0000 |
commit | faa00d0fd448d3b9361b629b79840bc5afb0ae53 (patch) | |
tree | 4ff4803edce7442f3746c1ceb8ea1477326de83d | |
parent | 9f23f386369f508a517b56a39168fe37ca3d3396 (diff) | |
download | chromium_src-faa00d0fd448d3b9361b629b79840bc5afb0ae53.zip chromium_src-faa00d0fd448d3b9361b629b79840bc5afb0ae53.tar.gz chromium_src-faa00d0fd448d3b9361b629b79840bc5afb0ae53.tar.bz2 |
Cronet: Fix IOBufferWithByteBuffer.
It was inheriting from IOBuffer, which automatically deletes its data_
pointer on destruction. Switched to WrappedIOBuffer, which does not.
It's weird to a parent class to have a behavior its child class does
not. Ideally, we'd fix IOBuffer, but given the number of consumers,
seems more effort than it's worth.
BUG=479206
Review URL: https://codereview.chromium.org/1099923002
Cr-Commit-Position: refs/heads/master@{#326080}
-rw-r--r-- | components/cronet/android/cronet_url_request_adapter.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/components/cronet/android/cronet_url_request_adapter.cc b/components/cronet/android/cronet_url_request_adapter.cc index 64713bf..cec7756 100644 --- a/components/cronet/android/cronet_url_request_adapter.cc +++ b/components/cronet/android/cronet_url_request_adapter.cc @@ -52,9 +52,11 @@ static jlong CreateRequestAdapter(JNIEnv* env, return reinterpret_cast<jlong>(adapter); } -// IOBuffer subclass for a buffer owned by a Java ByteBuffer. Keeps the -// ByteBuffer alive until destroyed. -class CronetURLRequestAdapter::IOBufferWithByteBuffer : public net::IOBuffer { +// net::WrappedIOBuffer subclass for a buffer owned by a Java ByteBuffer. Keeps +// the ByteBuffer alive until destroyed. Uses WrappedIOBuffer because data() is +// owned by the embedder. +class CronetURLRequestAdapter::IOBufferWithByteBuffer + : public net::WrappedIOBuffer { public: // Creates a buffer wrapping the Java ByteBuffer |jbyte_buffer|. |data| points // to the memory backed by the ByteBuffer, and position is the location to @@ -64,7 +66,7 @@ class CronetURLRequestAdapter::IOBufferWithByteBuffer : public net::IOBuffer { jobject jbyte_buffer, void* data, int position) - : net::IOBuffer(static_cast<char*>(data) + position), + : net::WrappedIOBuffer(static_cast<char*>(data) + position), initial_position_(position) { DCHECK(data); DCHECK_EQ(env->GetDirectBufferAddress(jbyte_buffer), data); |