prediction_options.h revision 6e8cce623b6e4fe0c9e4af605d675dd9d0338c38
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.
4
5#ifndef CHROME_BROWSER_NET_PREDICTION_OPTIONS_H_
6#define CHROME_BROWSER_NET_PREDICTION_OPTIONS_H_
7
8namespace user_prefs {
9class PrefRegistrySyncable;
10}
11
12class PrefService;
13class ProfileIOData;
14
15namespace chrome_browser_net {
16
17// Enum describing when to allow network predictions based on connection type.
18// The numerical value is stored in the prefs file, therefore the same enum
19// with the same order must be used by the platform-dependent components.
20// TODO(bnc): implement as per crbug.com/334602.
21// NETWORK_PREDICTION_UNSET means that the old preferences,
22// kNetworkPredictionEnabled and kAllowPrerender, should be observed.
23enum NetworkPredictionOptions {
24  NETWORK_PREDICTION_ALWAYS,
25  NETWORK_PREDICTION_WIFI_ONLY,
26  NETWORK_PREDICTION_NEVER,
27  NETWORK_PREDICTION_UNSET,
28};
29
30void RegisterPredictionOptionsProfilePrefs(
31    user_prefs::PrefRegistrySyncable* registry);
32
33// Migrate prefs::kNetworkPredictionEnabled user setting (if exists) to
34// prefs::kNetworkPredictionOptions (if does not have user setting).
35void MigrateNetworkPredictionUserPrefs(PrefService* pref_service);
36
37// The following two global functions determine whether prefetching
38// and prerendering are enabled, based on preferences and network type.
39
40// To be executed on the IO thread only.
41bool CanPrefetchAndPrerenderIO(ProfileIOData* profile_io_data);
42
43// To be executed on the UI thread only.
44bool CanPrefetchAndPrerenderUI(PrefService* prefs);
45
46// TODO(bnc): remove the following function as soon as Android Chrome is
47// modified to use CanPrefetchAndPrerenderUI instead.
48bool CanPredictNetworkActionsUI(PrefService* prefs);
49
50// The following two global functions determine whether TCP preconnect
51// and DNS preresolution are enabled, based on preferences.
52
53// To be executed on the IO thread only.
54bool CanPreresolveAndPreconnectIO(ProfileIOData* profile_io_data);
55
56// To be executed on the UI thread only.
57bool CanPreresolveAndPreconnectUI(PrefService* prefs);
58
59}  // namespace chrome_browser_net
60
61#endif  // CHROME_BROWSER_NET_PREDICTION_OPTIONS_H_
62