| OLD | NEW |
| 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 Loading... |
| 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 BrowserThread::PostTask( | 200 if (unfinished_work) { |
| 201 BrowserThread::DB, | 201 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 202 FROM_HERE, | 202 base::Bind(&PrecacheDatabase::SaveUnfinishedWork, |
| 203 base::Bind(&PrecacheDatabase::SaveUnfinishedWork, | 203 precache_database_->GetWeakPtr(), |
| 204 precache_database_->GetWeakPtr(), | 204 base::Passed(&unfinished_work))); |
| 205 base::Passed(&unfinished_work))); | 205 } |
| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 this)); | 328 this)); |
| 329 precache_fetcher_->Start(); | 329 precache_fetcher_->Start(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void PrecacheManager::OnHostsReceivedThenDone( | 332 void PrecacheManager::OnHostsReceivedThenDone( |
| 333 const history::TopHostsList& host_counts) { | 333 const history::TopHostsList& host_counts) { |
| 334 OnDone(); | 334 OnDone(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace precache | 337 } // namespace precache |
| OLD | NEW |