Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / prefetch / prefetch.cc
blobc38147fd3ddd15a71f990a3a3c904dd2c12ca3c1
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
3 // found in the LICENSE file.
5 #include "chrome/browser/prefetch/prefetch.h"
7 #include <string>
9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h"
11 #include "chrome/browser/net/prediction_options.h"
12 #include "chrome/browser/prefetch/prefetch_field_trial.h"
13 #include "chrome/browser/profiles/profile_io_data.h"
14 #include "net/base/network_change_notifier.h"
16 namespace prefetch {
18 bool IsPrefetchEnabled(content::ResourceContext* resource_context) {
19 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
21 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
22 DCHECK(io_data);
24 // TODO(bnc): Remove this condition once the new
25 // predictive preference is used on all platforms. See crbug.com/334602.
26 if (io_data->network_prediction_options()->GetValue() ==
27 chrome_browser_net::NETWORK_PREDICTION_UNSET &&
28 net::NetworkChangeNotifier::IsConnectionCellular(
29 net::NetworkChangeNotifier::GetConnectionType())) {
30 return false;
33 return chrome_browser_net::CanPrefetchAndPrerenderIO(io_data) &&
34 !DisableForFieldTrial();
37 } // namespace prefetch