Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 PassRefPtr<WebTaskRunner> task_runner) { | 139 PassRefPtr<WebTaskRunner> task_runner) { |
| 140 RemoveObserver(connection_observers_, observer, std::move(task_runner)); | 140 RemoveObserver(connection_observers_, observer, std::move(task_runner)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void NetworkStateNotifier::RemoveOnLineObserver( | 143 void NetworkStateNotifier::RemoveOnLineObserver( |
| 144 NetworkStateObserver* observer, | 144 NetworkStateObserver* observer, |
| 145 PassRefPtr<WebTaskRunner> task_runner) { | 145 PassRefPtr<WebTaskRunner> task_runner) { |
| 146 RemoveObserver(on_line_state_observers_, observer, std::move(task_runner)); | 146 RemoveObserver(on_line_state_observers_, observer, std::move(task_runner)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void NetworkStateNotifier::SetOverride(bool on_line, | 149 void NetworkStateNotifier::SetNetworkConnectionInfoOverride( |
| 150 WebConnectionType type, | 150 bool on_line, |
| 151 double max_bandwidth_mbps) { | 151 WebConnectionType type, |
| 152 double max_bandwidth_mbps) { | |
| 152 DCHECK(IsMainThread()); | 153 DCHECK(IsMainThread()); |
| 153 ScopedNotifier notifier(*this); | 154 ScopedNotifier notifier(*this); |
| 154 { | 155 { |
| 155 MutexLocker locker(mutex_); | 156 MutexLocker locker(mutex_); |
| 156 has_override_ = true; | 157 has_override_ = true; |
| 157 override_.on_line_initialized = true; | 158 override_.on_line_initialized = true; |
| 158 override_.on_line = on_line; | 159 override_.on_line = on_line; |
| 159 override_.connection_initialized = true; | 160 override_.connection_initialized = true; |
| 160 override_.type = type; | 161 override_.type = type; |
| 161 override_.max_bandwidth_mbps = max_bandwidth_mbps; | 162 override_.max_bandwidth_mbps = max_bandwidth_mbps; |
| 162 } | 163 } |
| 163 } | 164 } |
| 164 | 165 |
| 166 void NetworkStateNotifier::SetNetworkQualityInfoOverride( | |
|
dcheng
2017/05/27 08:47:47
I think the layering here may not be quite right:
tbansal1
2017/05/28 04:32:16
I think the problem here is that on actual test de
dcheng
2017/05/29 08:06:14
The browser-side network change/quality notifier s
kinuko
2017/05/30 02:38:22
By the way existing SetOverride is also used for d
tbansal1
2017/05/30 21:57:20
filed https://crbug.com/727911 for changing the va
| |
| 167 WebEffectiveConnectionType effective_type, | |
| 168 unsigned long transport_rtt_msec, | |
| 169 double downlink_throughput_mbps) { | |
| 170 DCHECK(IsMainThread()); | |
| 171 ScopedNotifier notifier(*this); | |
| 172 { | |
| 173 MutexLocker locker(mutex_); | |
| 174 has_override_ = true; | |
| 175 override_.on_line_initialized = true; | |
| 176 override_.connection_initialized = true; | |
| 177 override_.effective_type = effective_type; | |
| 178 override_.transport_rtt = | |
| 179 base::TimeDelta::FromMilliseconds(transport_rtt_msec); | |
| 180 override_.downlink_throughput_mbps = base::nullopt; | |
| 181 if (downlink_throughput_mbps >= 0) | |
| 182 override_.downlink_throughput_mbps = downlink_throughput_mbps; | |
| 183 } | |
| 184 } | |
| 185 | |
| 165 void NetworkStateNotifier::ClearOverride() { | 186 void NetworkStateNotifier::ClearOverride() { |
| 166 DCHECK(IsMainThread()); | 187 DCHECK(IsMainThread()); |
| 167 ScopedNotifier notifier(*this); | 188 ScopedNotifier notifier(*this); |
| 168 { | 189 { |
| 169 MutexLocker locker(mutex_); | 190 MutexLocker locker(mutex_); |
| 170 has_override_ = false; | 191 has_override_ = false; |
| 171 } | 192 } |
| 172 } | 193 } |
| 173 | 194 |
| 174 void NetworkStateNotifier::NotifyObservers(ObserverListMap& map, | 195 void NetworkStateNotifier::NotifyObservers(ObserverListMap& map, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 | 307 |
| 287 list->zeroed_observers.clear(); | 308 list->zeroed_observers.clear(); |
| 288 | 309 |
| 289 if (list->observers.IsEmpty()) { | 310 if (list->observers.IsEmpty()) { |
| 290 MutexLocker locker(mutex_); | 311 MutexLocker locker(mutex_); |
| 291 map.erase(task_runner); // deletes list | 312 map.erase(task_runner); // deletes list |
| 292 } | 313 } |
| 293 } | 314 } |
| 294 | 315 |
| 295 } // namespace blink | 316 } // namespace blink |
| OLD | NEW |