Chromium Code Reviews| Index: Source/modules/presentation/PresentationAvailability.h |
| diff --git a/Source/modules/presentation/PresentationAvailability.h b/Source/modules/presentation/PresentationAvailability.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e0b9e727f1b455b70daa805e39960deecaa100cc |
| --- /dev/null |
| +++ b/Source/modules/presentation/PresentationAvailability.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PresentationAvailability_h |
| +#define PresentationAvailability_h |
| + |
| +#include "core/dom/ActiveDOMObject.h" |
| +#include "core/events/EventTarget.h" |
| +#include "public/platform/modules/presentation/WebPresentationAvailabilityObserver.h" |
| + |
| +namespace blink { |
| + |
| +class ExecutionContext; |
| +class ScriptPromiseResolver; |
| + |
| +// Expose whether a device is available. |
|
whywhat
2015/07/02 22:32:37
nit: Expand the comment? Also, we call devices/dis
mlamouri (slow - plz ping)
2015/07/03 13:58:26
Done.
|
| +class PresentationAvailability final |
| + : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationAvailability> |
| + , public ActiveDOMObject |
|
whywhat
2015/07/02 22:32:37
Does it have to be ActiveDOMObject? It's not part
mlamouri (slow - plz ping)
2015/07/03 13:58:26
ActiveDOMObject are actually objects associated to
|
| + , public WebPresentationAvailabilityObserver { |
| + REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PresentationAvailability); |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); |
| + DEFINE_WRAPPERTYPEINFO(); |
| +public: |
| + static PresentationAvailability* take(ScriptPromiseResolver*, bool); |
| + |
| + static PresentationAvailability* create(ExecutionContext*, bool); |
| + ~PresentationAvailability() override; |
| + |
| + // EventTarget implementation. |
| + const AtomicString& interfaceName() const override; |
| + ExecutionContext* executionContext() const override; |
| + |
| + // WebPresentationAvailabilityObserver implementation. |
| + void availabilityChanged(bool) override; |
| + |
| + // ActiveDOMObject implementation. |
| + bool hasPendingActivity() const override; |
| + void suspend() override; |
| + void resume() override; |
| + void stop() override; |
| + |
| + bool value() const; |
| + |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| +private: |
| + PresentationAvailability(ExecutionContext*, bool); |
| + |
| + void startListening(); |
| + void stopListening(); |
| + |
| + bool m_value; |
| + bool m_listening; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // PresentationAvailability_h |