Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1917)

Unified Diff: net/quic/chromium/quic_stream_factory.cc

Issue 2794963002: Check callback is run in QuicStreamFactory::Job (Closed)
Patch Set: Address comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/chromium/quic_stream_factory.cc
diff --git a/net/quic/chromium/quic_stream_factory.cc b/net/quic/chromium/quic_stream_factory.cc
index f7e7fcd9cd46d0b8e4a815f7611b8061c67014a3..88650c7bd7971796e2041e768ad86720bc51cca0 100644
--- a/net/quic/chromium/quic_stream_factory.cc
+++ b/net/quic/chromium/quic_stream_factory.cc
@@ -8,6 +8,7 @@
#include <tuple>
#include <utility>
+#include "base/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h"
@@ -279,7 +280,7 @@ class QuicStreamFactory::CertVerifierJob {
UMA_HISTOGRAM_TIMES("Net.QuicSession.CertVerifierJob.CompleteTime",
base::TimeTicks::Now() - start_time_);
if (!callback_.is_null())
- callback_.Run(OK);
+ base::ResetAndReturn(&callback_).Run(OK);
}
const QuicServerId& server_id() const { return server_id_; }
@@ -412,6 +413,8 @@ QuicStreamFactory::Job::Job(QuicStreamFactory* factory,
weak_factory_(this) {}
QuicStreamFactory::Job::~Job() {
+ DCHECK(callback_.is_null());
+
// If disk cache has a pending WaitForDataReadyCallback, cancel that callback.
if (server_info_)
server_info_->ResetWaitForDataReadyCallback();
@@ -466,9 +469,8 @@ int QuicStreamFactory::Job::DoLoop(int rv) {
void QuicStreamFactory::Job::OnIOComplete(int rv) {
rv = DoLoop(rv);
- if (rv != ERR_IO_PENDING && !callback_.is_null()) {
- callback_.Run(rv);
- }
+ if (rv != ERR_IO_PENDING && !callback_.is_null())
+ base::ResetAndReturn(&callback_).Run(rv);
}
void QuicStreamFactory::Job::RunAuxilaryJob() {
@@ -704,7 +706,7 @@ void QuicStreamRequest::SetSession(QuicChromiumClientSession* session) {
void QuicStreamRequest::OnRequestComplete(int rv) {
factory_ = nullptr;
- callback_.Run(rv);
+ base::ResetAndReturn(&callback_).Run(rv);
}
base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const {
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698