diff options
author | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-07 04:27:53 +0000 |
---|---|---|
committer | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-07 04:27:53 +0000 |
commit | 3bc2379e208bd30629e2a881c5121636c5216ebc (patch) | |
tree | 3605dfdb1898f3656a1897bacf21f89453a1e72f | |
parent | b36d9baa98e397fd194716a6041083ed989524c8 (diff) | |
download | chromium_src-3bc2379e208bd30629e2a881c5121636c5216ebc.zip chromium_src-3bc2379e208bd30629e2a881c5121636c5216ebc.tar.gz chromium_src-3bc2379e208bd30629e2a881c5121636c5216ebc.tar.bz2 |
AddRef() / Release() while URLRequest is alive in OCSPRequestSession
To make sure OCSPRequestSession is avlie while URLRequest is running,
AddRef() in StartURLRequest() and Release() in OnReadCompleted().
BUG=28526,28769
TEST=none
Review URL: http://codereview.chromium.org/449009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33950 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/ocsp/nss_ocsp.cc | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc index e48edc10..3f4daee 100644 --- a/net/ocsp/nss_ocsp.cc +++ b/net/ocsp/nss_ocsp.cc @@ -128,11 +128,7 @@ class OCSPRequestSession void Cancel() { // IO thread may set |io_loop_| to NULL, so protect by |lock_|. AutoLock autolock(lock_); - if (io_loop_) { - io_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &OCSPRequestSession::CancelURLRequest)); - } + CancelLocked(); } bool Finished() const { @@ -152,7 +148,7 @@ class OCSPRequestSession if (timeout < base::TimeDelta()) { LOG(INFO) << "OCSP Timed out"; if (!finished_) - Cancel(); + CancelLocked(); break; } } @@ -225,6 +221,7 @@ class OCSPRequestSession io_loop_ = NULL; } cv_.Signal(); + Release(); // Balanced with StartURLRequest(). } } @@ -234,11 +231,7 @@ class OCSPRequestSession AutoLock autolock(lock_); io_loop_ = NULL; } - if (request_) { - request_->Cancel(); - delete request_; - request_ = NULL; - } + CancelURLRequest(); } private: @@ -250,6 +243,14 @@ class OCSPRequestSession io_loop_->RemoveDestructionObserver(this); } + void CancelLocked() { + if (io_loop_) { + io_loop_->PostTask( + FROM_HERE, + NewRunnableMethod(this, &OCSPRequestSession::CancelURLRequest)); + } + } + void StartURLRequest() { DCHECK_EQ(MessageLoopForIO::current(), io_loop_); DCHECK(!request_); @@ -279,6 +280,7 @@ class OCSPRequestSession request_->SetExtraRequestHeaders(extra_request_headers_); request_->Start(); + AddRef(); // Release after |request_| deleted. } void CancelURLRequest() { @@ -288,6 +290,13 @@ class OCSPRequestSession request_->Cancel(); delete request_; request_ = NULL; + { + AutoLock autolock(lock_); + finished_ = true; + io_loop_ = NULL; + } + cv_.Signal(); + Release(); // Balanced with StartURLRequest(). } } |