| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 observerList->zeroedObservers.append(index); | 97 observerList->zeroedObservers.append(index); |
| 98 } | 98 } |
| 99 | 99 |
| 100 if (!observerList->iterating && !observerList->zeroedObservers.isEmpty()) | 100 if (!observerList->iterating && !observerList->zeroedObservers.isEmpty()) |
| 101 collectZeroedObservers(observerList, context); | 101 collectZeroedObservers(observerList, context); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void NetworkStateNotifier::setTestUpdatesOnly(bool updatesOnly) | 104 void NetworkStateNotifier::setTestUpdatesOnly(bool updatesOnly) |
| 105 { | 105 { |
| 106 ASSERT(isMainThread()); | 106 ASSERT(isMainThread()); |
| 107 MutexLocker locker(m_mutex); |
| 108 |
| 109 // Reset state to default when entering or leaving test mode. |
| 110 if (updatesOnly != m_testUpdatesOnly) { |
| 111 m_isOnLine = true; |
| 112 m_type = WebConnectionTypeOther; |
| 113 m_maxBandwidthMbps = std::numeric_limits<double>::infinity(); |
| 114 } |
| 115 |
| 107 m_testUpdatesOnly = updatesOnly; | 116 m_testUpdatesOnly = updatesOnly; |
| 108 } | 117 } |
| 109 | 118 |
| 110 void NetworkStateNotifier::setWebConnectionForTest(WebConnectionType type, doubl
e maxBandwidthMbps) | 119 void NetworkStateNotifier::setWebConnectionForTest(WebConnectionType type, doubl
e maxBandwidthMbps) |
| 111 { | 120 { |
| 112 ASSERT(isMainThread()); | 121 ASSERT(isMainThread()); |
| 113 ASSERT(m_testUpdatesOnly); | 122 ASSERT(m_testUpdatesOnly); |
| 114 setWebConnectionImpl(type, maxBandwidthMbps); | 123 setWebConnectionImpl(type, maxBandwidthMbps); |
| 115 } | 124 } |
| 116 | 125 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 182 |
| 174 list->zeroedObservers.clear(); | 183 list->zeroedObservers.clear(); |
| 175 | 184 |
| 176 if (list->observers.isEmpty()) { | 185 if (list->observers.isEmpty()) { |
| 177 MutexLocker locker(m_mutex); | 186 MutexLocker locker(m_mutex); |
| 178 m_observers.remove(context); // deletes list | 187 m_observers.remove(context); // deletes list |
| 179 } | 188 } |
| 180 } | 189 } |
| 181 | 190 |
| 182 } // namespace blink | 191 } // namespace blink |
| OLD | NEW |