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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 MutexLocker locker(m_mutex); | 129 MutexLocker locker(m_mutex); |
130 m_initialized = true; | 130 m_initialized = true; |
131 | 131 |
132 if (m_type == type && m_maxBandwidthMbps == maxBandwidthMbps) | 132 if (m_type == type && m_maxBandwidthMbps == maxBandwidthMbps) |
133 return; | 133 return; |
134 m_type = type; | 134 m_type = type; |
135 m_maxBandwidthMbps = maxBandwidthMbps; | 135 m_maxBandwidthMbps = maxBandwidthMbps; |
136 | 136 |
137 for (const auto& entry : m_observers) { | 137 for (const auto& entry : m_observers) { |
138 ExecutionContext* context = entry.key; | 138 ExecutionContext* context = entry.key; |
139 context->postTask(BLINK_FROM_HERE, createCrossThreadTask(&NetworkStateNo
tifier::notifyObserversOfConnectionChangeOnContext, AllowCrossThreadAccess(this)
, type, maxBandwidthMbps)); | 139 context->postTask(BLINK_FROM_HERE, createCrossThreadTask(&NetworkStateNo
tifier::notifyObserversOfConnectionChangeOnContext, crossThreadUnretained(this),
type, maxBandwidthMbps)); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 void NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext(WebConnect
ionType type, double maxBandwidthMbps, ExecutionContext* context) | 143 void NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext(WebConnect
ionType type, double maxBandwidthMbps, ExecutionContext* context) |
144 { | 144 { |
145 ObserverList* observerList = lockAndFindObserverList(context); | 145 ObserverList* observerList = lockAndFindObserverList(context); |
146 | 146 |
147 // The context could have been removed before the notification task got to r
un. | 147 // The context could have been removed before the notification task got to r
un. |
148 if (!observerList) | 148 if (!observerList) |
149 return; | 149 return; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 list->zeroedObservers.clear(); | 184 list->zeroedObservers.clear(); |
185 | 185 |
186 if (list->observers.isEmpty()) { | 186 if (list->observers.isEmpty()) { |
187 MutexLocker locker(m_mutex); | 187 MutexLocker locker(m_mutex); |
188 m_observers.remove(context); // deletes list | 188 m_observers.remove(context); // deletes list |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 } // namespace blink | 192 } // namespace blink |
OLD | NEW |