OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef RemotePlayback_h | 5 #ifndef RemotePlayback_h |
6 #define RemotePlayback_h | 6 #define RemotePlayback_h |
7 | 7 |
8 #include "bindings/core/v8/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/TraceWrapperMember.h" | 10 #include "bindings/core/v8/TraceWrapperMember.h" |
11 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
12 #include "core/events/EventTarget.h" | 12 #include "core/events/EventTarget.h" |
13 #include "modules/ModulesExport.h" | 13 #include "modules/ModulesExport.h" |
14 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
15 #include "platform/wtf/Compiler.h" | 15 #include "platform/wtf/Compiler.h" |
16 #include "platform/wtf/Functional.h" | |
16 #include "platform/wtf/text/AtomicString.h" | 17 #include "platform/wtf/text/AtomicString.h" |
17 #include "platform/wtf/text/WTFString.h" | 18 #include "platform/wtf/text/WTFString.h" |
18 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h " | 19 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h " |
19 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" | 20 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" |
20 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" | 21 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" |
21 | 22 |
22 namespace blink { | 23 namespace blink { |
23 | 24 |
24 class HTMLMediaElement; | 25 class HTMLMediaElement; |
25 class RemotePlaybackAvailabilityCallback; | 26 class RemotePlaybackAvailabilityCallback; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 String state() const; | 65 String state() const; |
65 | 66 |
66 // ScriptWrappable implementation. | 67 // ScriptWrappable implementation. |
67 bool HasPendingActivity() const final; | 68 bool HasPendingActivity() const final; |
68 | 69 |
69 DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting); | 70 DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting); |
70 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 71 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
71 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 72 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
72 | 73 |
73 DECLARE_VIRTUAL_TRACE(); | 74 DECLARE_VIRTUAL_TRACE(); |
74 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | |
75 | 75 |
76 private: | 76 private: |
77 friend class MediaControlCastButtonElement; | |
78 friend class MediaControlsMediaEventListener; | |
mlamouri (slow - plz ping)
2017/04/25 12:19:21
Do you need these for PromptInternal() and GetStat
whywhat
2017/04/25 15:45:37
Prompt and State are used by the button.
Watch/Can
| |
77 friend class V8RemotePlayback; | 79 friend class V8RemotePlayback; |
78 friend class RemotePlaybackTest; | 80 friend class RemotePlaybackTest; |
79 | 81 |
82 // Wraps either a WTF::Closure or RemotePlaybackAvailabilityCallback object | |
83 // to be kept in the |availability_callbacks_| map. | |
84 class AvailabilityCallback final | |
85 : public GarbageCollectedFinalized<AvailabilityCallback> { | |
mlamouri (slow - plz ping)
2017/04/25 12:19:21
Do you need to declare the class here? I mean, apa
whywhat
2017/04/25 15:45:37
Would you prefer it to be in a separate header/cpp
whywhat
2017/04/25 22:31:23
It's needed to be in the header since it's used by
| |
86 WTF_MAKE_NONCOPYABLE(AvailabilityCallback); | |
87 | |
88 public: | |
89 explicit AvailabilityCallback(RemotePlaybackAvailabilityCallback*); | |
90 explicit AvailabilityCallback(std::unique_ptr<WTF::Closure>); | |
91 ~AvailabilityCallback() = default; | |
92 | |
93 void Run(RemotePlayback*, bool new_availability); | |
94 | |
95 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | |
96 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
97 | |
98 private: | |
99 // Only one of these members must be set. | |
100 TraceWrapperMember<RemotePlaybackAvailabilityCallback> bindings_cb_; | |
101 std::unique_ptr<WTF::Closure> internal_cb_; | |
102 }; | |
103 | |
80 explicit RemotePlayback(HTMLMediaElement&); | 104 explicit RemotePlayback(HTMLMediaElement&); |
81 | 105 |
106 // The implementation of prompt(). Used by the native remote playback button. | |
107 void PromptInternal(); | |
108 | |
109 // The implementation of watchAvailability() and cancelWatchAvailability(). | |
110 int WatchAvailabilityInternal(AvailabilityCallback*); | |
111 bool CancelWatchAvailabilityInternal(int id); | |
112 | |
113 WebRemotePlaybackState GetState() const { return state_; } | |
114 | |
82 // Calls the specified availability callback with the current availability. | 115 // Calls the specified availability callback with the current availability. |
83 // Need a void() method to post it as a task. | 116 // Need a void() method to post it as a task. |
84 void NotifyInitialAvailability(int callback_id); | 117 void NotifyInitialAvailability(int callback_id); |
85 | 118 |
86 // WebRemotePlaybackClient implementation. | 119 // WebRemotePlaybackClient implementation. |
87 void StateChanged(WebRemotePlaybackState) override; | 120 void StateChanged(WebRemotePlaybackState) override; |
88 void AvailabilityChanged(WebRemotePlaybackAvailability) override; | 121 void AvailabilityChanged(WebRemotePlaybackAvailability) override; |
89 void PromptCancelled() override; | 122 void PromptCancelled() override; |
90 bool RemotePlaybackAvailable() const override; | 123 bool RemotePlaybackAvailable() const override; |
91 | 124 |
92 WebRemotePlaybackState state_; | 125 WebRemotePlaybackState state_; |
93 WebRemotePlaybackAvailability availability_; | 126 WebRemotePlaybackAvailability availability_; |
94 HeapHashMap<int, TraceWrapperMember<RemotePlaybackAvailabilityCallback>> | 127 HeapHashMap<int, Member<AvailabilityCallback>> availability_callbacks_; |
95 availability_callbacks_; | |
96 Member<HTMLMediaElement> media_element_; | 128 Member<HTMLMediaElement> media_element_; |
97 Member<ScriptPromiseResolver> prompt_promise_resolver_; | 129 Member<ScriptPromiseResolver> prompt_promise_resolver_; |
98 }; | 130 }; |
99 | 131 |
100 } // namespace blink | 132 } // namespace blink |
101 | 133 |
102 #endif // RemotePlayback_h | 134 #endif // RemotePlayback_h |
OLD | NEW |