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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 void NetworkStateNotifier::addObserver(NetworkStateObserver* observer, | 87 void NetworkStateNotifier::addObserver(NetworkStateObserver* observer, |
88 ExecutionContext* context) { | 88 ExecutionContext* context) { |
89 ASSERT(context->isContextThread()); | 89 ASSERT(context->isContextThread()); |
90 ASSERT(observer); | 90 ASSERT(observer); |
91 | 91 |
92 MutexLocker locker(m_mutex); | 92 MutexLocker locker(m_mutex); |
93 ObserverListMap::AddResult result = m_observers.add(context, nullptr); | 93 ObserverListMap::AddResult result = m_observers.add(context, nullptr); |
94 if (result.isNewEntry) | 94 if (result.isNewEntry) |
95 result.storedValue->value = wrapUnique(new ObserverList); | 95 result.storedValue->value = WTF::wrapUnique(new ObserverList); |
96 | 96 |
97 ASSERT(result.storedValue->value->observers.find(observer) == kNotFound); | 97 ASSERT(result.storedValue->value->observers.find(observer) == kNotFound); |
98 result.storedValue->value->observers.append(observer); | 98 result.storedValue->value->observers.append(observer); |
99 } | 99 } |
100 | 100 |
101 void NetworkStateNotifier::removeObserver(NetworkStateObserver* observer, | 101 void NetworkStateNotifier::removeObserver(NetworkStateObserver* observer, |
102 ExecutionContext* context) { | 102 ExecutionContext* context) { |
103 ASSERT(context->isContextThread()); | 103 ASSERT(context->isContextThread()); |
104 ASSERT(observer); | 104 ASSERT(observer); |
105 | 105 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 list->zeroedObservers.clear(); | 203 list->zeroedObservers.clear(); |
204 | 204 |
205 if (list->observers.isEmpty()) { | 205 if (list->observers.isEmpty()) { |
206 MutexLocker locker(m_mutex); | 206 MutexLocker locker(m_mutex); |
207 m_observers.remove(context); // deletes list | 207 m_observers.remove(context); // deletes list |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 } // namespace blink | 211 } // namespace blink |
OLD | NEW |