| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 { | 71 { |
| 72 ASSERT(isMainThread()); | 72 ASSERT(isMainThread()); |
| 73 | 73 |
| 74 MutexLocker locker(m_mutex); | 74 MutexLocker locker(m_mutex); |
| 75 if (m_type == type) | 75 if (m_type == type) |
| 76 return; | 76 return; |
| 77 m_type = type; | 77 m_type = type; |
| 78 | 78 |
| 79 for (const auto& entry : m_observers) { | 79 for (const auto& entry : m_observers) { |
| 80 ExecutionContext* context = entry.key; | 80 ExecutionContext* context = entry.key; |
| 81 context->postTask(FROM_HERE, createCrossThreadTask(&NetworkStateNotifier
::notifyObserversOnContext, this, AllowCrossThreadAccess(context), type)); | 81 context->postTask(createCrossThreadTask(&NetworkStateNotifier::notifyObs
erversOnContext, this, AllowCrossThreadAccess(context), type)); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void NetworkStateNotifier::addObserver(NetworkStateObserver* observer, Execution
Context* context) | 85 void NetworkStateNotifier::addObserver(NetworkStateObserver* observer, Execution
Context* context) |
| 86 { | 86 { |
| 87 ASSERT(context->isContextThread()); | 87 ASSERT(context->isContextThread()); |
| 88 ASSERT(observer); | 88 ASSERT(observer); |
| 89 | 89 |
| 90 MutexLocker locker(m_mutex); | 90 MutexLocker locker(m_mutex); |
| 91 ObserverListMap::AddResult result = m_observers.add(context, nullptr); | 91 ObserverListMap::AddResult result = m_observers.add(context, nullptr); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 list->zeroedObservers.clear(); | 173 list->zeroedObservers.clear(); |
| 174 | 174 |
| 175 if (list->observers.isEmpty()) { | 175 if (list->observers.isEmpty()) { |
| 176 MutexLocker locker(m_mutex); | 176 MutexLocker locker(m_mutex); |
| 177 m_observers.remove(context); // deletes list | 177 m_observers.remove(context); // deletes list |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |