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

Side by Side Diff: third_party/WebKit/Source/platform/network/NetworkStateNotifier.cpp

Issue 2908233002: NetInfo default values (Closed)
Patch Set: ps Created 3 years, 6 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 /* 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DCHECK(IsMainThread()); 152 DCHECK(IsMainThread());
153 ScopedNotifier notifier(*this); 153 ScopedNotifier notifier(*this);
154 { 154 {
155 MutexLocker locker(mutex_); 155 MutexLocker locker(mutex_);
156 has_override_ = true; 156 has_override_ = true;
157 override_.on_line_initialized = true; 157 override_.on_line_initialized = true;
158 override_.on_line = on_line; 158 override_.on_line = on_line;
159 override_.connection_initialized = true; 159 override_.connection_initialized = true;
160 override_.type = type; 160 override_.type = type;
161 override_.max_bandwidth_mbps = max_bandwidth_mbps; 161 override_.max_bandwidth_mbps = max_bandwidth_mbps;
162
163 // Override network quality values when testing.
164 if (!override_.http_rtt.has_value()) {
165 override_.http_rtt = state_.http_rtt.has_value()
166 ? state_.http_rtt
167 : base::TimeDelta::FromSeconds(1);
168 }
169 if (!override_.transport_rtt.has_value()) {
170 override_.transport_rtt = state_.transport_rtt.has_value()
171 ? state_.transport_rtt
172 : base::TimeDelta::FromSeconds(1);
173 }
174 if (!override_.downlink_throughput_mbps.has_value()) {
175 override_.downlink_throughput_mbps = state_.downlink_throughput_mbps;
176 override_.downlink_throughput_mbps =
177 state_.downlink_throughput_mbps.has_value()
178 ? state_.downlink_throughput_mbps
179 : 1.0;
180 }
162 } 181 }
163 } 182 }
164 183
165 void NetworkStateNotifier::ClearOverride() { 184 void NetworkStateNotifier::ClearOverride() {
166 DCHECK(IsMainThread()); 185 DCHECK(IsMainThread());
167 ScopedNotifier notifier(*this); 186 ScopedNotifier notifier(*this);
168 { 187 {
169 MutexLocker locker(mutex_); 188 MutexLocker locker(mutex_);
170 has_override_ = false; 189 has_override_ = false;
171 } 190 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 305
287 list->zeroed_observers.clear(); 306 list->zeroed_observers.clear();
288 307
289 if (list->observers.IsEmpty()) { 308 if (list->observers.IsEmpty()) {
290 MutexLocker locker(mutex_); 309 MutexLocker locker(mutex_);
291 map.erase(task_runner); // deletes list 310 map.erase(task_runner); // deletes list
292 } 311 }
293 } 312 }
294 313
295 } // namespace blink 314 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698