diff options
author | jnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 08:07:10 +0000 |
---|---|---|
committer | jnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 08:07:10 +0000 |
commit | f627ecffef16a6d63d7aed676fbeb56b8cdb1264 (patch) | |
tree | a49f3b9aee3d946bdbd341dbc0dcaad25ebb02c8 /net | |
parent | 64ade15d206bf1daa45d2e816d358ed1996d3554 (diff) | |
download | chromium_src-f627ecffef16a6d63d7aed676fbeb56b8cdb1264.zip chromium_src-f627ecffef16a6d63d7aed676fbeb56b8cdb1264.tar.gz chromium_src-f627ecffef16a6d63d7aed676fbeb56b8cdb1264.tar.bz2 |
Cleanup the URLRequestContext after finishing communication with test sserver spawner.
URLRequestContext was a Ref-Countable before, I used to track it by using scoped_refptr<> wrapper, so when the relevant URLRequest is gone, the corresponding URLRequestContext gets destroyed at same time on same thread.
But after change crrev.com/136497, URLRequestContext is no longer Ref-Countable, so it is not gone with the associated URLRequest, we have to manually reset it. Some net tests on Android were failed due to the DCHECK of freeing URLRequestContext on another thread.
Also invalidate the weak pointers on the IO thread when the request gets completed.
BUG=None
TEST=net test based tests on Android should pass.
Review URL: https://chromiumcodereview.appspot.com/10456013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139493 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/test/spawner_communicator.cc | 7 | ||||
-rw-r--r-- | net/test/spawner_communicator.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/net/test/spawner_communicator.cc b/net/test/spawner_communicator.cc index 308d080..af20887 100644 --- a/net/test/spawner_communicator.cc +++ b/net/test/spawner_communicator.cc @@ -126,7 +126,10 @@ void SpawnerCommunicator::StartIOThread() { void SpawnerCommunicator::Shutdown() { DCHECK_NE(MessageLoop::current(), io_thread_.message_loop()); DCHECK(is_running_); + // The request and its context should be created and destroyed only on the + // IO thread. DCHECK(!cur_request_.get()); + DCHECK(!context_.get()); io_thread_.Stop(); allowed_port_.reset(); } @@ -239,6 +242,10 @@ void SpawnerCommunicator::OnSpawnerCommandCompleted(URLRequest* request) { // Clear current request to indicate the completion of sending a command // to spawner server and getting the result. cur_request_.reset(); + context_.reset(); + // Invalidate the weak pointers on the IO thread. + weak_factory_.InvalidateWeakPtrs(); + // Wakeup the caller in user thread. event_.Signal(); } diff --git a/net/test/spawner_communicator.h b/net/test/spawner_communicator.h index 061324d..44a68a1 100644 --- a/net/test/spawner_communicator.h +++ b/net/test/spawner_communicator.h @@ -135,6 +135,7 @@ class SpawnerCommunicator : public net::URLRequest::Delegate { // outstanding tasks when |this| is deleted. base::WeakPtrFactory<SpawnerCommunicator> weak_factory_; + // Request context used by |cur_request_|. scoped_ptr<URLRequestContext> context_; // The current (in progress) request, or NULL. |