| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "components/history/core/browser/history_service.h" | 18 #include "components/history/core/browser/history_service.h" |
| 19 #include "components/precache/core/precache_database.h" | 19 #include "components/precache/core/precache_database.h" |
| 20 #include "components/precache/core/precache_switches.h" | 20 #include "components/precache/core/precache_switches.h" |
| 21 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 22 #include "components/sync_driver/sync_service.h" | 22 #include "components/sync_driver/sync_service.h" |
| 23 #include "components/variations/variations_associated_data.h" | 23 #include "components/variations/variations_associated_data.h" |
| 24 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/storage_partition.h" | |
| 27 #include "net/base/network_change_notifier.h" | 26 #include "net/base/network_change_notifier.h" |
| 28 | 27 |
| 29 using content::BrowserThread; | 28 using content::BrowserThread; |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 const char kPrecacheFieldTrialName[] = "Precache"; | 32 const char kPrecacheFieldTrialName[] = "Precache"; |
| 34 const char kPrecacheFieldTrialEnabledGroup[] = "Enabled"; | 33 const char kPrecacheFieldTrialEnabledGroup[] = "Enabled"; |
| 35 const char kPrecacheFieldTrialControlGroup[] = "Control"; | 34 const char kPrecacheFieldTrialControlGroup[] = "Control"; |
| 36 const char kConfigURLParam[] = "config_url"; | 35 const char kConfigURLParam[] = "config_url"; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // Don't start precaching if it was canceled while waiting for the list of | 272 // Don't start precaching if it was canceled while waiting for the list of |
| 274 // hosts. | 273 // hosts. |
| 275 return; | 274 return; |
| 276 } | 275 } |
| 277 | 276 |
| 278 std::vector<std::string> hosts; | 277 std::vector<std::string> hosts; |
| 279 for (const auto& host_count : host_counts) | 278 for (const auto& host_count : host_counts) |
| 280 hosts.push_back(host_count.first); | 279 hosts.push_back(host_count.first); |
| 281 | 280 |
| 282 // Start precaching. | 281 // Start precaching. |
| 283 precache_fetcher_.reset(new PrecacheFetcher( | 282 precache_fetcher_.reset( |
| 284 hosts, | 283 new PrecacheFetcher(hosts, browser_context_->GetRequestContext(), |
| 285 content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> | 284 GURL(variations::GetVariationParamValue( |
| 286 GetURLRequestContext(), | 285 kPrecacheFieldTrialName, kConfigURLParam)), |
| 287 GURL(variations::GetVariationParamValue( | 286 variations::GetVariationParamValue( |
| 288 kPrecacheFieldTrialName, kConfigURLParam)), | 287 kPrecacheFieldTrialName, kManifestURLPrefixParam), |
| 289 variations::GetVariationParamValue( | 288 this)); |
| 290 kPrecacheFieldTrialName, kManifestURLPrefixParam), | |
| 291 this)); | |
| 292 precache_fetcher_->Start(); | 289 precache_fetcher_->Start(); |
| 293 } | 290 } |
| 294 | 291 |
| 295 void PrecacheManager::OnHostsReceivedThenDone( | 292 void PrecacheManager::OnHostsReceivedThenDone( |
| 296 const history::TopHostsList& host_counts) { | 293 const history::TopHostsList& host_counts) { |
| 297 OnDone(); | 294 OnDone(); |
| 298 } | 295 } |
| 299 | 296 |
| 300 } // namespace precache | 297 } // namespace precache |
| OLD | NEW |