Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: chrome/browser/net/prediction_options.cc

Issue 1712943002: [Android] Simplify "network predictions" preference to a boolean value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added bug link; rebased Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/net/prediction_options.h" 5 #include "chrome/browser/net/prediction_options.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/profiles/profile_io_data.h" 8 #include "chrome/browser/profiles/profile_io_data.h"
9 #include "chrome/common/pref_names.h" 9 #include "chrome/common/pref_names.h"
10 #include "components/pref_registry/pref_registry_syncable.h" 10 #include "components/pref_registry/pref_registry_syncable.h"
11 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "net/base/network_change_notifier.h" 13 #include "net/base/network_change_notifier.h"
14 14
15 namespace chrome_browser_net { 15 namespace chrome_browser_net {
16 16
17 namespace { 17 namespace {
18 18
19 // Since looking up preferences and current network connection are presumably 19 // Since looking up preferences and current network connection are presumably
20 // both cheap, we do not cache them here. 20 // both cheap, we do not cache them here.
21 NetworkPredictionStatus CanPrefetchAndPrerender( 21 NetworkPredictionStatus CanPrefetchAndPrerender(
22 int network_prediction_options) { 22 int network_prediction_options) {
23 switch (network_prediction_options) { 23 switch (network_prediction_options) {
24 case NETWORK_PREDICTION_ALWAYS: 24 case NETWORK_PREDICTION_ALWAYS:
25 break; 25 case NETWORK_PREDICTION_WIFI_ONLY:
26 case NETWORK_PREDICTION_NEVER:
27 return NetworkPredictionStatus::DISABLED_ALWAYS;
28 default:
29 DCHECK_EQ(NETWORK_PREDICTION_WIFI_ONLY, network_prediction_options);
30 if (net::NetworkChangeNotifier::IsConnectionCellular( 26 if (net::NetworkChangeNotifier::IsConnectionCellular(
31 net::NetworkChangeNotifier::GetConnectionType())) { 27 net::NetworkChangeNotifier::GetConnectionType())) {
32 return NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK; 28 return NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK;
29 } else {
30 return NetworkPredictionStatus::ENABLED;
33 } 31 }
32 default:
33 DCHECK_EQ(NETWORK_PREDICTION_NEVER, network_prediction_options);
34 return NetworkPredictionStatus::DISABLED_ALWAYS;
34 } 35 }
35 return NetworkPredictionStatus::ENABLED;
36 } 36 }
37 37
38 bool CanPreresolveAndPreconnect(int network_prediction_options) { 38 bool CanPreresolveAndPreconnect(int network_prediction_options) {
39 // DNS preresolution and TCP preconnect are performed even on cellular 39 // DNS preresolution and TCP preconnect are performed even on cellular
40 // networks if the user setting is WIFI_ONLY. 40 // networks if the user setting is WIFI_ONLY.
41 return network_prediction_options != NETWORK_PREDICTION_NEVER; 41 return network_prediction_options != NETWORK_PREDICTION_NEVER;
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
(...skipping 28 matching lines...) Expand all
74 } 74 }
75 75
76 bool CanPreresolveAndPreconnectUI(PrefService* prefs) { 76 bool CanPreresolveAndPreconnectUI(PrefService* prefs) {
77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
78 DCHECK(prefs); 78 DCHECK(prefs);
79 return CanPreresolveAndPreconnect( 79 return CanPreresolveAndPreconnect(
80 prefs->GetInteger(prefs::kNetworkPredictionOptions)); 80 prefs->GetInteger(prefs::kNetworkPredictionOptions));
81 } 81 }
82 82
83 } // namespace chrome_browser_net 83 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/prediction_options.h ('k') | chrome/browser/predictors/resource_prefetch_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698