Commit 4acf4fc8 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Use WeakPtr for MarkProxiesAsBad callback

This was causing a crash if the throttle was destroyed before the
callback was called.

Bug: 914436
Change-Id: Id52e41c2f42fe29116a2b877311cc1d9405b5116
Reviewed-on: https://chromium-review.googlesource.com/c/1374159Reviewed-by: default avatarrajendrant <rajendrant@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616003}
parent 34d7a515
...@@ -146,7 +146,7 @@ void DataReductionProxyURLLoaderThrottle::MarkProxiesAsBad( ...@@ -146,7 +146,7 @@ void DataReductionProxyURLLoaderThrottle::MarkProxiesAsBad(
auto callback = base::BindOnce( auto callback = base::BindOnce(
&DataReductionProxyURLLoaderThrottle::OnMarkProxiesAsBadComplete, &DataReductionProxyURLLoaderThrottle::OnMarkProxiesAsBadComplete,
base::Unretained(this)); weak_factory_.GetWeakPtr());
waiting_for_mark_proxies_ = true; waiting_for_mark_proxies_ = true;
manager_->MarkProxiesAsBad(bypass_duration, proxy_list, std::move(callback)); manager_->MarkProxiesAsBad(bypass_duration, proxy_list, std::move(callback));
......
...@@ -78,6 +78,8 @@ class DataReductionProxyURLLoaderThrottle : public content::URLLoaderThrottle { ...@@ -78,6 +78,8 @@ class DataReductionProxyURLLoaderThrottle : public content::URLLoaderThrottle {
// The final load flags used to complete the request. // The final load flags used to complete the request.
int final_load_flags_ = 0; int final_load_flags_ = 0;
base::WeakPtrFactory<DataReductionProxyURLLoaderThrottle> weak_factory_{this};
}; };
} // namespace data_reduction_proxy } // namespace data_reduction_proxy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment