OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/prefetch/prefetch.h" | 5 #include "chrome/browser/prefetch/prefetch.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "chrome/browser/net/prediction_options.h" |
11 #include "chrome/browser/prefetch/prefetch_field_trial.h" | 12 #include "chrome/browser/prefetch/prefetch_field_trial.h" |
12 #include "chrome/browser/profiles/profile_io_data.h" | 13 #include "chrome/browser/profiles/profile_io_data.h" |
13 #include "net/base/network_change_notifier.h" | 14 #include "net/base/network_change_notifier.h" |
14 | 15 |
15 namespace prefetch { | 16 namespace prefetch { |
16 | 17 |
17 bool IsPrefetchEnabled(content::ResourceContext* resource_context) { | 18 bool IsPrefetchEnabled(content::ResourceContext* resource_context) { |
18 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 19 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
19 | 20 |
20 // TODO(jkarlin): Eventually tie this to a new Chrome preference to predict | 21 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
21 // network actions when on cellular connections. See crbug.com/370454. | |
22 if (net::NetworkChangeNotifier::IsConnectionCellular( | |
23 net::NetworkChangeNotifier::GetConnectionType())) | |
24 return false; | |
25 | 22 |
26 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 23 DCHECK(io_data); |
27 if (io_data != NULL && io_data->network_prediction_enabled()->GetValue()) | 24 |
28 return IsPrefetchFieldTrialEnabled(); | 25 return IsPrefetchFieldTrialEnabled() && |
29 return false; | 26 chrome_browser_net::CanPredictNetworkActionsIO(io_data); |
30 } | 27 } |
31 | 28 |
32 } // namespace prefetch | 29 } // namespace prefetch |
OLD | NEW |