diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 19:28:13 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 19:28:13 +0000 |
commit | f6c9d56c4b81eb282e591cc079622697ed99b5ed (patch) | |
tree | ac9df136560b7d980a6069c9c3ad6242e9af3c54 /net/base | |
parent | 000e5e50320090d35b164c2bf1ac4c5f3c83a825 (diff) | |
download | chromium_src-f6c9d56c4b81eb282e591cc079622697ed99b5ed.zip chromium_src-f6c9d56c4b81eb282e591cc079622697ed99b5ed.tar.gz chromium_src-f6c9d56c4b81eb282e591cc079622697ed99b5ed.tar.bz2 |
Http Cache: Release all references to buffers before invoking callbacks.
BUG=131272
TEST=net_unittests
Review URL: https://codereview.chromium.org/11854020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/test_completion_callback.cc | 20 | ||||
-rw-r--r-- | net/base/test_completion_callback.h | 15 |
2 files changed, 33 insertions, 2 deletions
diff --git a/net/base/test_completion_callback.cc b/net/base/test_completion_callback.cc index c226478..2ee4c8d 100644 --- a/net/base/test_completion_callback.cc +++ b/net/base/test_completion_callback.cc @@ -8,6 +8,7 @@ #include "base/bind_helpers.h" #include "base/compiler_specific.h" #include "base/message_loop.h" +#include "net/base/io_buffer.h" namespace net { @@ -42,7 +43,8 @@ TestCompletionCallback::TestCompletionCallback() base::Unretained(this)))) { } -TestCompletionCallback::~TestCompletionCallback() {} +TestCompletionCallback::~TestCompletionCallback() { +} TestInt64CompletionCallback::TestInt64CompletionCallback() : ALLOW_THIS_IN_INITIALIZER_LIST(callback_( @@ -50,6 +52,20 @@ TestInt64CompletionCallback::TestInt64CompletionCallback() base::Unretained(this)))) { } -TestInt64CompletionCallback::~TestInt64CompletionCallback() {} +TestInt64CompletionCallback::~TestInt64CompletionCallback() { +} + +ReleaseBufferCompletionCallback::ReleaseBufferCompletionCallback( + IOBuffer* buffer) : buffer_(buffer) { +} + +ReleaseBufferCompletionCallback::~ReleaseBufferCompletionCallback() { +} + +void ReleaseBufferCompletionCallback::SetResult(int result) { + if (!buffer_->HasOneRef()) + result = net::ERR_FAILED; + TestCompletionCallback::SetResult(result); +} } // namespace net diff --git a/net/base/test_completion_callback.h b/net/base/test_completion_callback.h index c886cfb..4a0afe1 100644 --- a/net/base/test_completion_callback.h +++ b/net/base/test_completion_callback.h @@ -24,6 +24,8 @@ namespace net { +class IOBuffer; + namespace internal { class TestCompletionCallbackBaseInternal { @@ -108,6 +110,19 @@ class TestInt64CompletionCallback : public TestInt64CompletionCallbackBase { DISALLOW_COPY_AND_ASSIGN(TestInt64CompletionCallback); }; +// Makes sure that the buffer is not referenced when the callback runs. +class ReleaseBufferCompletionCallback: public TestCompletionCallback { + public: + explicit ReleaseBufferCompletionCallback(IOBuffer* buffer); + virtual ~ReleaseBufferCompletionCallback(); + + private: + virtual void SetResult(int result) OVERRIDE; + + IOBuffer* buffer_; + DISALLOW_COPY_AND_ASSIGN(ReleaseBufferCompletionCallback); +}; + } // namespace net #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ |