| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 base::StartsWith( | 92 base::StartsWith( |
| 93 base::FieldTrialList::FindFullName(kPrecacheFieldTrialName), | 93 base::FieldTrialList::FindFullName(kPrecacheFieldTrialName), |
| 94 kPrecacheFieldTrialControlGroup, base::CompareCase::SENSITIVE); | 94 kPrecacheFieldTrialControlGroup, base::CompareCase::SENSITIVE); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool PrecacheManager::IsPrecachingAllowed() const { | 97 bool PrecacheManager::IsPrecachingAllowed() const { |
| 98 return PrecachingAllowed() == AllowedType::ALLOWED; | 98 return PrecachingAllowed() == AllowedType::ALLOWED; |
| 99 } | 99 } |
| 100 | 100 |
| 101 PrecacheManager::AllowedType PrecacheManager::PrecachingAllowed() const { | 101 PrecacheManager::AllowedType PrecacheManager::PrecachingAllowed() const { |
| 102 if (!(sync_service_ && sync_service_->IsBackendInitialized())) | 102 if (!(sync_service_ && sync_service_->IsEngineInitialized())) |
| 103 return AllowedType::PENDING; | 103 return AllowedType::PENDING; |
| 104 | 104 |
| 105 // SyncService delegates to SyncPrefs, which must be called on the UI thread. | 105 // SyncService delegates to SyncPrefs, which must be called on the UI thread. |
| 106 if (history_service_ && | 106 if (history_service_ && |
| 107 sync_service_->GetActiveDataTypes().Has(syncer::SESSIONS) && | 107 sync_service_->GetActiveDataTypes().Has(syncer::SESSIONS) && |
| 108 !sync_service_->GetEncryptedDataTypes().Has(syncer::SESSIONS)) | 108 !sync_service_->GetEncryptedDataTypes().Has(syncer::SESSIONS)) |
| 109 return AllowedType::ALLOWED; | 109 return AllowedType::ALLOWED; |
| 110 | 110 |
| 111 return AllowedType::DISALLOWED; | 111 return AllowedType::DISALLOWED; |
| 112 } | 112 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Calculate TopHosts solely for metrics purposes. | 175 // Calculate TopHosts solely for metrics purposes. |
| 176 if (needs_top_hosts) { | 176 if (needs_top_hosts) { |
| 177 history_service_->TopHosts( | 177 history_service_->TopHosts( |
| 178 NumTopHosts(), | 178 NumTopHosts(), |
| 179 base::Bind(&PrecacheManager::OnHostsReceivedThenDone, AsWeakPtr())); | 179 base::Bind(&PrecacheManager::OnHostsReceivedThenDone, AsWeakPtr())); |
| 180 } else { | 180 } else { |
| 181 OnDone(); | 181 OnDone(); |
| 182 } | 182 } |
| 183 } else { | 183 } else { |
| 184 if (PrecachingAllowed() != AllowedType::PENDING) { | 184 if (PrecachingAllowed() != AllowedType::PENDING) { |
| 185 // We are not waiting on the sync backend to be initialized. The user | 185 // We are not waiting on the sync engine to be initialized. The user |
| 186 // either is not in the field trial, or does not have sync enabled. | 186 // either is not in the field trial, or does not have sync enabled. |
| 187 // Pretend that precaching started, so that the PrecacheServiceLauncher | 187 // Pretend that precaching started, so that the PrecacheServiceLauncher |
| 188 // doesn't try to start it again. | 188 // doesn't try to start it again. |
| 189 } | 189 } |
| 190 | 190 |
| 191 OnDone(); | 191 OnDone(); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 void PrecacheManager::CancelPrecaching() { | 195 void PrecacheManager::CancelPrecaching() { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 this)); | 355 this)); |
| 356 precache_fetcher_->Start(); | 356 precache_fetcher_->Start(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void PrecacheManager::OnHostsReceivedThenDone( | 359 void PrecacheManager::OnHostsReceivedThenDone( |
| 360 const history::TopHostsList& host_counts) { | 360 const history::TopHostsList& host_counts) { |
| 361 OnDone(); | 361 OnDone(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 } // namespace precache | 364 } // namespace precache |
| OLD | NEW |