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

Side by Side Diff: components/precache/content/precache_manager.cc

Issue 2147543002: Revert of PrecacheFetcher::CancelPrecaching should run in the main UI thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/precache/content/precache_manager.h" 5 #include "components/precache/content/precache_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // Do nothing if precaching is not in progress. 190 // Do nothing if precaching is not in progress.
191 return; 191 return;
192 } 192 }
193 is_precaching_ = false; 193 is_precaching_ = false;
194 // If cancellation occurs after StartPrecaching but before OnHostsReceived, 194 // If cancellation occurs after StartPrecaching but before OnHostsReceived,
195 // is_precaching will be true, but the precache_fetcher_ will not yet be 195 // is_precaching will be true, but the precache_fetcher_ will not yet be
196 // constructed. 196 // constructed.
197 if (precache_fetcher_) { 197 if (precache_fetcher_) {
198 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work = 198 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work =
199 precache_fetcher_->CancelPrecaching(); 199 precache_fetcher_->CancelPrecaching();
200 if (unfinished_work) { 200 BrowserThread::PostTask(
201 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 201 BrowserThread::DB,
202 base::Bind(&PrecacheDatabase::SaveUnfinishedWork, 202 FROM_HERE,
203 precache_database_->GetWeakPtr(), 203 base::Bind(&PrecacheDatabase::SaveUnfinishedWork,
204 base::Passed(&unfinished_work))); 204 precache_database_->GetWeakPtr(),
205 } 205 base::Passed(&unfinished_work)));
206 // Destroying the |precache_fetcher_| will cancel any fetch in progress. 206 // Destroying the |precache_fetcher_| will cancel any fetch in progress.
207 precache_fetcher_.reset(); 207 precache_fetcher_.reset();
208 } 208 }
209 precache_completion_callback_.Reset(); 209 precache_completion_callback_.Reset();
210 } 210 }
211 211
212 bool PrecacheManager::IsPrecaching() const { 212 bool PrecacheManager::IsPrecaching() const {
213 DCHECK_CURRENTLY_ON(BrowserThread::UI); 213 DCHECK_CURRENTLY_ON(BrowserThread::UI);
214 return is_precaching_; 214 return is_precaching_;
215 } 215 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 this)); 343 this));
344 precache_fetcher_->Start(); 344 precache_fetcher_->Start();
345 } 345 }
346 346
347 void PrecacheManager::OnHostsReceivedThenDone( 347 void PrecacheManager::OnHostsReceivedThenDone(
348 const history::TopHostsList& host_counts) { 348 const history::TopHostsList& host_counts) {
349 OnDone(); 349 OnDone();
350 } 350 }
351 351
352 } // namespace precache 352 } // namespace precache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698