| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/remoteplayback/RemotePlaybackAvailability.h" | |
| 6 | |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 8 #include "core/dom/Document.h" | |
| 9 #include "core/events/Event.h" | |
| 10 #include "modules/EventTargetModulesNames.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 // static | |
| 15 RemotePlaybackAvailability* RemotePlaybackAvailability::take( | |
| 16 ScriptPromiseResolver* resolver, | |
| 17 bool value) { | |
| 18 return new RemotePlaybackAvailability(resolver->getExecutionContext(), value); | |
| 19 } | |
| 20 | |
| 21 RemotePlaybackAvailability::RemotePlaybackAvailability( | |
| 22 ExecutionContext* executionContext, | |
| 23 bool value) | |
| 24 : ActiveScriptWrappable(this), | |
| 25 ContextLifecycleObserver(executionContext), | |
| 26 m_value(value) { | |
| 27 ASSERT(executionContext->isDocument()); | |
| 28 } | |
| 29 | |
| 30 RemotePlaybackAvailability::~RemotePlaybackAvailability() = default; | |
| 31 | |
| 32 const AtomicString& RemotePlaybackAvailability::interfaceName() const { | |
| 33 return EventTargetNames::RemotePlaybackAvailability; | |
| 34 } | |
| 35 | |
| 36 ExecutionContext* RemotePlaybackAvailability::getExecutionContext() const { | |
| 37 return ContextLifecycleObserver::getExecutionContext(); | |
| 38 } | |
| 39 | |
| 40 void RemotePlaybackAvailability::availabilityChanged(bool value) { | |
| 41 if (m_value == value) | |
| 42 return; | |
| 43 | |
| 44 m_value = value; | |
| 45 dispatchEvent(Event::create(EventTypeNames::change)); | |
| 46 } | |
| 47 | |
| 48 bool RemotePlaybackAvailability::value() const { | |
| 49 return m_value; | |
| 50 } | |
| 51 | |
| 52 bool RemotePlaybackAvailability::hasPendingActivity() const { | |
| 53 return hasEventListeners(); | |
| 54 } | |
| 55 | |
| 56 DEFINE_TRACE(RemotePlaybackAvailability) { | |
| 57 EventTargetWithInlineData::trace(visitor); | |
| 58 ContextLifecycleObserver::trace(visitor); | |
| 59 } | |
| 60 | |
| 61 } // namespace blink | |
| OLD | NEW |