| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/logging/log_event_dispatcher.h" | 5 #include "media/cast/logging/log_event_dispatcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // CastEnvironment's MAIN thread, block until the unsubscribe task | 78 // CastEnvironment's MAIN thread, block until the unsubscribe task |
| 79 // completes. | 79 // completes. |
| 80 struct Helper { | 80 struct Helper { |
| 81 static void UnsubscribeAndSignal(const scoped_refptr<Impl>& impl, | 81 static void UnsubscribeAndSignal(const scoped_refptr<Impl>& impl, |
| 82 RawEventSubscriber* subscriber, | 82 RawEventSubscriber* subscriber, |
| 83 base::WaitableEvent* done) { | 83 base::WaitableEvent* done) { |
| 84 impl->Unsubscribe(subscriber); | 84 impl->Unsubscribe(subscriber); |
| 85 done->Signal(); | 85 done->Signal(); |
| 86 } | 86 } |
| 87 }; | 87 }; |
| 88 base::WaitableEvent done(true, false); | 88 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::MANUAL, |
| 89 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 89 CHECK(env_->PostTask( | 90 CHECK(env_->PostTask( |
| 90 CastEnvironment::MAIN, FROM_HERE, | 91 CastEnvironment::MAIN, FROM_HERE, |
| 91 base::Bind(&Helper::UnsubscribeAndSignal, impl_, subscriber, &done))); | 92 base::Bind(&Helper::UnsubscribeAndSignal, impl_, subscriber, &done))); |
| 92 done.Wait(); | 93 done.Wait(); |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 | 96 |
| 96 LogEventDispatcher::Impl::Impl() {} | 97 LogEventDispatcher::Impl::Impl() {} |
| 97 | 98 |
| 98 LogEventDispatcher::Impl::~Impl() { | 99 LogEventDispatcher::Impl::~Impl() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 131 |
| 131 void LogEventDispatcher::Impl::Unsubscribe(RawEventSubscriber* subscriber) { | 132 void LogEventDispatcher::Impl::Unsubscribe(RawEventSubscriber* subscriber) { |
| 132 const auto it = | 133 const auto it = |
| 133 std::find(subscribers_.begin(), subscribers_.end(), subscriber); | 134 std::find(subscribers_.begin(), subscribers_.end(), subscriber); |
| 134 DCHECK(it != subscribers_.end()); | 135 DCHECK(it != subscribers_.end()); |
| 135 subscribers_.erase(it); | 136 subscribers_.erase(it); |
| 136 } | 137 } |
| 137 | 138 |
| 138 } // namespace cast | 139 } // namespace cast |
| 139 } // namespace media | 140 } // namespace media |
| OLD | NEW |