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 //////////////////////////////////////////////////////////////////////////////// | 5 //////////////////////////////////////////////////////////////////////////////// |
6 // Threading considerations: | 6 // Threading considerations: |
7 // | 7 // |
8 // This class is designed to meet various threading guarantees starting from the | 8 // This class is designed to meet various threading guarantees starting from the |
9 // ones imposed by NetworkChangeNotifier: | 9 // ones imposed by NetworkChangeNotifier: |
10 // - The notifier can be constructed on any thread. | 10 // - The notifier can be constructed on any thread. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); | 78 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); |
79 } | 79 } |
80 | 80 |
81 // static | 81 // static |
82 bool NetworkChangeNotifierAndroid::Register(JNIEnv* env) { | 82 bool NetworkChangeNotifierAndroid::Register(JNIEnv* env) { |
83 return NetworkChangeNotifierDelegateAndroid::Register(env); | 83 return NetworkChangeNotifierDelegateAndroid::Register(env); |
84 } | 84 } |
85 | 85 |
86 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid( | 86 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid( |
87 NetworkChangeNotifierDelegateAndroid* delegate) | 87 NetworkChangeNotifierDelegateAndroid* delegate) |
88 : delegate_(delegate) { | 88 : NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()), |
| 89 delegate_(delegate) { |
89 SetConnectionType(NetworkChangeNotifier::CONNECTION_UNKNOWN); | 90 SetConnectionType(NetworkChangeNotifier::CONNECTION_UNKNOWN); |
90 delegate_->AddObserver(this); | 91 delegate_->AddObserver(this); |
91 } | 92 } |
92 | 93 |
| 94 // static |
| 95 NetworkChangeNotifier::NetworkChangeCalculatorParams |
| 96 NetworkChangeNotifierAndroid::NetworkChangeCalculatorParamsAndroid() { |
| 97 NetworkChangeCalculatorParams params; |
| 98 // IPAddressChanged is produced immediately prior to ConnectionTypeChanged |
| 99 // so delay IPAddressChanged so they get merged with the following |
| 100 // ConnectionTypeChanged signal. |
| 101 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); |
| 102 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); |
| 103 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); |
| 104 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); |
| 105 return params; |
| 106 } |
| 107 |
93 void NetworkChangeNotifierAndroid::SetConnectionType( | 108 void NetworkChangeNotifierAndroid::SetConnectionType( |
94 ConnectionType new_connection_type) { | 109 ConnectionType new_connection_type) { |
95 base::AutoLock auto_lock(connection_type_lock_); | 110 base::AutoLock auto_lock(connection_type_lock_); |
96 connection_type_ = new_connection_type; | 111 connection_type_ = new_connection_type; |
97 } | 112 } |
98 | 113 |
99 } // namespace net | 114 } // namespace net |
OLD | NEW |