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

Unified Diff: chrome/browser/net/sdch_dictionary_fetcher.cc

Issue 321283002: Clear SDCH information on "Clear browsing data" path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak. Created 6 years, 6 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
Index: chrome/browser/net/sdch_dictionary_fetcher.cc
diff --git a/chrome/browser/net/sdch_dictionary_fetcher.cc b/chrome/browser/net/sdch_dictionary_fetcher.cc
index 1130fe336242b5b5c666a2ae433771e1b98d3bd4..0a838bd37fa9adb86be501707f81888b9f30e66b 100644
--- a/chrome/browser/net/sdch_dictionary_fetcher.cc
+++ b/chrome/browser/net/sdch_dictionary_fetcher.cc
@@ -49,6 +49,16 @@ void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
ScheduleDelayedRun();
}
+void SdchDictionaryFetcher::Cancel() {
+ DCHECK(CalledOnValidThread());
+
+ while (!fetch_queue_.empty())
jar (doing other things) 2014/06/17 17:03:27 nit: If you're now counting on scoped_ref_ptr<>, w
Randy Smith (Not in Mondays) 2014/06/17 18:33:11 So http://www.cplusplus.com/reference/queue/queue/
+ fetch_queue_.pop();
+ attempted_load_.clear();
+ weak_factory_.InvalidateWeakPtrs();
+ current_fetch_.reset(NULL);
+}
+
void SdchDictionaryFetcher::ScheduleDelayedRun() {
if (fetch_queue_.empty() || current_fetch_.get() || task_is_pending_)
return;
@@ -64,6 +74,10 @@ void SdchDictionaryFetcher::StartFetching() {
DCHECK(task_is_pending_);
task_is_pending_ = false;
+ // Handle losing the race against Cancel().
+ if (fetch_queue_.empty())
+ return;
+
DCHECK(context_.get());
current_fetch_.reset(net::URLFetcher::Create(
fetch_queue_.front(), net::URLFetcher::GET, this));

Powered by Google App Engine
This is Rietveld 408576698