diff --git a/blink/common/loader/throttling_url_loader.cc b/blink/common/loader/throttling_url_loader.cc index 7e9561917c6c4c49fdaad8789540eac941fa0712..84adea4ce470671a5f6ce74c926bc86bf7132414 100644 --- a/blink/common/loader/throttling_url_loader.cc +++ b/blink/common/loader/throttling_url_loader.cc @@ -679,8 +679,12 @@ void ThrottlingURLLoader::OnReceiveResponse( auto* throttle = entry.throttle.get(); bool throttle_deferred = false; base::Time start = base::Time::Now(); + auto weak_ptr = weak_factory_.GetWeakPtr(); throttle->BeforeWillProcessResponse(response_url_, *response_head, &throttle_deferred); + if (!weak_ptr) { + return; + } RecordExecutionTimeHistogram( GetStageNameForHistogram(DEFERRED_BEFORE_RESPONSE), start); if (!HandleThrottleResult(throttle, throttle_deferred, &deferred)) @@ -706,8 +710,12 @@ void ThrottlingURLLoader::OnReceiveResponse( auto* throttle = entry.throttle.get(); bool throttle_deferred = false; base::Time start = base::Time::Now(); + auto weak_ptr = weak_factory_.GetWeakPtr(); throttle->WillProcessResponse(response_url_, response_head.get(), &throttle_deferred); + if (!weak_ptr) { + return; + } RecordExecutionTimeHistogram(GetStageNameForHistogram(DEFERRED_RESPONSE), start); if (!HandleThrottleResult(throttle, throttle_deferred, &deferred)) @@ -855,7 +863,11 @@ void ThrottlingURLLoader::OnComplete( auto* throttle = entry.throttle.get(); bool throttle_deferred = false; base::Time start = base::Time::Now(); + auto weak_ptr = weak_factory_.GetWeakPtr(); throttle->WillOnCompleteWithError(status, &throttle_deferred); + if (!weak_ptr) { + return; + } RecordExecutionTimeHistogram(GetStageNameForHistogram(DEFERRED_COMPLETE), start); if (!HandleThrottleResult(throttle, throttle_deferred, &deferred))