| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 { | 101 { |
| 102 } | 102 } |
| 103 bool iterating; | 103 bool iterating; |
| 104 Vector<NetworkStateObserver*> observers; | 104 Vector<NetworkStateObserver*> observers; |
| 105 Vector<size_t> zeroedObservers; // Indices in observers that are 0. | 105 Vector<size_t> zeroedObservers; // Indices in observers that are 0. |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 void setWebConnectionImpl(WebConnectionType, double maxBandwidthMbps); | 108 void setWebConnectionImpl(WebConnectionType, double maxBandwidthMbps); |
| 109 void setMaxBandwidthImpl(double maxBandwidthMbps); | 109 void setMaxBandwidthImpl(double maxBandwidthMbps); |
| 110 | 110 |
| 111 using ObserverListMap = WillBePersistentHeapHashMap<RawPtrWillBeWeakMember<E
xecutionContext>, OwnPtr<ObserverList>>; | 111 // The ObserverListMap is cross-thread accessed, adding/removing Observers r
unning |
| 112 // within an ExecutionContext. Kept off-heap to ease cross-thread allocation
and use; |
| 113 // the observers are (already) responsible for explicitly unregistering whil
e finalizing. |
| 114 using ObserverListMap = HashMap<RawPtrWillBeUntracedMember<ExecutionContext>
, OwnPtr<ObserverList>>; |
| 112 | 115 |
| 113 void notifyObserversOfConnectionChangeOnContext(WebConnectionType, double ma
xBandwidthMbps, ExecutionContext*); | 116 void notifyObserversOfConnectionChangeOnContext(WebConnectionType, double ma
xBandwidthMbps, ExecutionContext*); |
| 114 | 117 |
| 115 ObserverList* lockAndFindObserverList(ExecutionContext*); | 118 ObserverList* lockAndFindObserverList(ExecutionContext*); |
| 116 | 119 |
| 117 // Removed observers are nulled out in the list in case the list is being | 120 // Removed observers are nulled out in the list in case the list is being |
| 118 // iterated over. Once done iterating, call this to clean up nulled | 121 // iterated over. Once done iterating, call this to clean up nulled |
| 119 // observers. | 122 // observers. |
| 120 void collectZeroedObservers(ObserverList*, ExecutionContext*); | 123 void collectZeroedObservers(ObserverList*, ExecutionContext*); |
| 121 | 124 |
| 122 mutable Mutex m_mutex; | 125 mutable Mutex m_mutex; |
| 123 bool m_isOnLine; | 126 bool m_isOnLine; |
| 124 WebConnectionType m_type; | 127 WebConnectionType m_type; |
| 125 double m_maxBandwidthMbps; | 128 double m_maxBandwidthMbps; |
| 126 ObserverListMap m_observers; | 129 ObserverListMap m_observers; |
| 127 bool m_testUpdatesOnly; | 130 bool m_testUpdatesOnly; |
| 128 }; | 131 }; |
| 129 | 132 |
| 130 CORE_EXPORT NetworkStateNotifier& networkStateNotifier(); | 133 CORE_EXPORT NetworkStateNotifier& networkStateNotifier(); |
| 131 | 134 |
| 132 } // namespace blink | 135 } // namespace blink |
| 133 | 136 |
| 134 #endif // NetworkStateNotifier_h | 137 #endif // NetworkStateNotifier_h |
| OLD | NEW |