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" |
26 #include "net/base/network_change_notifier.h" | 27 #include "net/base/network_change_notifier.h" |
27 | 28 |
28 using content::BrowserThread; | 29 using content::BrowserThread; |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 const char kPrecacheFieldTrialName[] = "Precache"; | 33 const char kPrecacheFieldTrialName[] = "Precache"; |
33 const char kPrecacheFieldTrialEnabledGroup[] = "Enabled"; | 34 const char kPrecacheFieldTrialEnabledGroup[] = "Enabled"; |
34 const char kPrecacheFieldTrialControlGroup[] = "Control"; | 35 const char kPrecacheFieldTrialControlGroup[] = "Control"; |
35 const char kConfigURLParam[] = "config_url"; | 36 const char kConfigURLParam[] = "config_url"; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // Don't start precaching if it was canceled while waiting for the list of | 273 // Don't start precaching if it was canceled while waiting for the list of |
273 // hosts. | 274 // hosts. |
274 return; | 275 return; |
275 } | 276 } |
276 | 277 |
277 std::vector<std::string> hosts; | 278 std::vector<std::string> hosts; |
278 for (const auto& host_count : host_counts) | 279 for (const auto& host_count : host_counts) |
279 hosts.push_back(host_count.first); | 280 hosts.push_back(host_count.first); |
280 | 281 |
281 // Start precaching. | 282 // Start precaching. |
282 precache_fetcher_.reset( | 283 precache_fetcher_.reset(new PrecacheFetcher( |
283 new PrecacheFetcher(hosts, browser_context_->GetRequestContext(), | 284 hosts, |
284 GURL(variations::GetVariationParamValue( | 285 content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> |
285 kPrecacheFieldTrialName, kConfigURLParam)), | 286 GetURLRequestContext(), |
286 variations::GetVariationParamValue( | 287 GURL(variations::GetVariationParamValue( |
287 kPrecacheFieldTrialName, kManifestURLPrefixParam), | 288 kPrecacheFieldTrialName, kConfigURLParam)), |
288 this)); | 289 variations::GetVariationParamValue( |
| 290 kPrecacheFieldTrialName, kManifestURLPrefixParam), |
| 291 this)); |
289 precache_fetcher_->Start(); | 292 precache_fetcher_->Start(); |
290 } | 293 } |
291 | 294 |
292 void PrecacheManager::OnHostsReceivedThenDone( | 295 void PrecacheManager::OnHostsReceivedThenDone( |
293 const history::TopHostsList& host_counts) { | 296 const history::TopHostsList& host_counts) { |
294 OnDone(); | 297 OnDone(); |
295 } | 298 } |
296 | 299 |
297 } // namespace precache | 300 } // namespace precache |
OLD | NEW |