OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/net/network_change_notifier_chromeos.h" | 5 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 void OnNetworkChange() { | 47 void OnNetworkChange() { |
48 InvalidateConfig(); | 48 InvalidateConfig(); |
49 InvalidateHosts(); | 49 InvalidateHosts(); |
50 ReadNow(); | 50 ReadNow(); |
51 } | 51 } |
52 }; | 52 }; |
53 | 53 |
54 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() | 54 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() |
55 : has_active_network_(false), | 55 : NetworkChangeNotifier(NetworkChangeCalculatorParamsChromeos()), |
| 56 has_active_network_(false), |
56 connection_state_(chromeos::STATE_UNKNOWN), | 57 connection_state_(chromeos::STATE_UNKNOWN), |
57 connection_type_(CONNECTION_NONE), | 58 connection_type_(CONNECTION_NONE), |
58 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 59 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
59 BrowserThread::PostDelayedTask( | 60 BrowserThread::PostDelayedTask( |
60 BrowserThread::UI, FROM_HERE, | 61 BrowserThread::UI, FROM_HERE, |
61 base::Bind( | 62 base::Bind( |
62 &NetworkChangeNotifierChromeos::UpdateInitialState, this), | 63 &NetworkChangeNotifierChromeos::UpdateInitialState, this), |
63 base::TimeDelta::FromMilliseconds(kInitialNotificationCheckDelayMS)); | 64 base::TimeDelta::FromMilliseconds(kInitialNotificationCheckDelayMS)); |
64 } | 65 } |
65 | 66 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 return CONNECTION_4G; | 327 return CONNECTION_4G; |
327 } | 328 } |
328 case chromeos::TYPE_BLUETOOTH: | 329 case chromeos::TYPE_BLUETOOTH: |
329 case chromeos::TYPE_VPN: | 330 case chromeos::TYPE_VPN: |
330 case chromeos::TYPE_UNKNOWN: | 331 case chromeos::TYPE_UNKNOWN: |
331 break; | 332 break; |
332 } | 333 } |
333 return net::NetworkChangeNotifier::CONNECTION_UNKNOWN; | 334 return net::NetworkChangeNotifier::CONNECTION_UNKNOWN; |
334 } | 335 } |
335 | 336 |
| 337 // static |
| 338 net::NetworkChangeNotifier::NetworkChangeCalculatorParams |
| 339 NetworkChangeNotifierChromeos::NetworkChangeCalculatorParamsChromeos() { |
| 340 NetworkChangeCalculatorParams params; |
| 341 // Delay values arrived at by simple experimentation and adjusted so as to |
| 342 // produce a single signal when switching between network connections. |
| 343 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); |
| 344 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); |
| 345 params.connection_type_offline_delay_ = base::TimeDelta::FromMilliseconds(0); |
| 346 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(0); |
| 347 return params; |
| 348 } |
| 349 |
336 } // namespace chromeos | 350 } // namespace chromeos |
OLD | NEW |