1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 2116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 3116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// found in the LICENSE file. 4116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifndef CHROME_BROWSER_NET_PREDICTION_OPTIONS_H_ 6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define CHROME_BROWSER_NET_PREDICTION_OPTIONS_H_ 7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 8116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace user_prefs { 9116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PrefRegistrySyncable; 10116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} 11116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 12116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PrefService; 13116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass ProfileIOData; 14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 15116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace chrome_browser_net { 16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 17116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Enum describing when to allow network predictions based on connection type. 18116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// The numerical value is stored in the prefs file, therefore the same enum 19116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// with the same order must be used by the platform-dependent components. 20116680a4aac90f2aa7413d9095a592090648e557Ben Murdochenum NetworkPredictionOptions { 21116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch NETWORK_PREDICTION_ALWAYS, 22116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch NETWORK_PREDICTION_WIFI_ONLY, 23116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch NETWORK_PREDICTION_NEVER, 241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci NETWORK_PREDICTION_DEFAULT = NETWORK_PREDICTION_WIFI_ONLY, 25116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}; 26116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 27116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid RegisterPredictionOptionsProfilePrefs( 28116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch user_prefs::PrefRegistrySyncable* registry); 29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Migrate prefs::kNetworkPredictionEnabled user setting (if exists) to 316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// prefs::kNetworkPredictionOptions (if does not have user setting). 326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)void MigrateNetworkPredictionUserPrefs(PrefService* pref_service); 336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// The following two global functions determine whether prefetching 356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// and prerendering are enabled, based on preferences and network type. 36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// To be executed on the IO thread only. 386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)bool CanPrefetchAndPrerenderIO(ProfileIOData* profile_io_data); 39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// To be executed on the UI thread only. 416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)bool CanPrefetchAndPrerenderUI(PrefService* prefs); 426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// The following two global functions determine whether TCP preconnect 446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// and DNS preresolution are enabled, based on preferences. 456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// To be executed on the IO thread only. 476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)bool CanPreresolveAndPreconnectIO(ProfileIOData* profile_io_data); 486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// To be executed on the UI thread only. 506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)bool CanPreresolveAndPreconnectUI(PrefService* prefs); 516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 52116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} // namespace chrome_browser_net 53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif // CHROME_BROWSER_NET_PREDICTION_OPTIONS_H_ 55