Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.h

Issue 2890633003: [Blink,RemotePlayback] Use PresentationController for availability (Closed)
Patch Set: Limited to Blink only, rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/events/EventTarget.h" 10 #include "core/events/EventTarget.h"
11 #include "modules/ModulesExport.h" 11 #include "modules/ModulesExport.h"
12 #include "platform/bindings/ActiveScriptWrappable.h" 12 #include "platform/bindings/ActiveScriptWrappable.h"
13 #include "platform/bindings/TraceWrapperMember.h" 13 #include "platform/bindings/TraceWrapperMember.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/text/AtomicString.h" 16 #include "platform/wtf/text/AtomicString.h"
17 #include "platform/wtf/text/WTFString.h" 17 #include "platform/wtf/text/WTFString.h"
18 #include "public/platform/WebURL.h"
19 #include "public/platform/WebVector.h"
20 #include "public/platform/modules/presentation/WebPresentationAvailabilityObserv er.h"
18 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h " 21 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h "
19 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" 22 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h"
20 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" 23 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h"
21 24
22 namespace blink { 25 namespace blink {
23 26
24 class AvailabilityCallbackWrapper; 27 class AvailabilityCallbackWrapper;
25 class HTMLMediaElement; 28 class HTMLMediaElement;
26 class RemotePlaybackAvailabilityCallback; 29 class RemotePlaybackAvailabilityCallback;
27 class ScriptPromiseResolver; 30 class ScriptPromiseResolver;
28 class ScriptState; 31 class ScriptState;
29 32
30 class MODULES_EXPORT RemotePlayback final 33 class MODULES_EXPORT RemotePlayback final
31 : public EventTargetWithInlineData, 34 : public EventTargetWithInlineData,
32 public ActiveScriptWrappable<RemotePlayback>, 35 public ActiveScriptWrappable<RemotePlayback>,
33 NON_EXPORTED_BASE(public WebRemotePlaybackClient) { 36 NON_EXPORTED_BASE(public WebRemotePlaybackClient),
37 public WebPresentationAvailabilityObserver {
34 DEFINE_WRAPPERTYPEINFO(); 38 DEFINE_WRAPPERTYPEINFO();
35 USING_GARBAGE_COLLECTED_MIXIN(RemotePlayback); 39 USING_GARBAGE_COLLECTED_MIXIN(RemotePlayback);
36 40
37 public: 41 public:
38 static RemotePlayback* Create(HTMLMediaElement&); 42 static RemotePlayback* Create(HTMLMediaElement&);
39 43
40 // Notifies this object that disableRemotePlayback attribute was set on the 44 // Notifies this object that disableRemotePlayback attribute was set on the
41 // corresponding media element. 45 // corresponding media element.
42 void RemotePlaybackDisabled(); 46 void RemotePlaybackDisabled();
43 47
(...skipping 22 matching lines...) Expand all
66 70
67 // The implementation of prompt(). Used by the native remote playback button. 71 // The implementation of prompt(). Used by the native remote playback button.
68 void PromptInternal(); 72 void PromptInternal();
69 73
70 // The implementation of watchAvailability() and cancelWatchAvailability(). 74 // The implementation of watchAvailability() and cancelWatchAvailability().
71 int WatchAvailabilityInternal(AvailabilityCallbackWrapper*); 75 int WatchAvailabilityInternal(AvailabilityCallbackWrapper*);
72 bool CancelWatchAvailabilityInternal(int id); 76 bool CancelWatchAvailabilityInternal(int id);
73 77
74 WebRemotePlaybackState GetState() const { return state_; } 78 WebRemotePlaybackState GetState() const { return state_; }
75 79
80 // WebPresentationAvailabilityObserver implementation.
81 void AvailabilityChanged(bool) override;
82 const WebVector<WebURL>& Urls() const override;
mark a. foltz 2017/05/31 21:16:41 Can this method have a more specific name?
83
76 // WebRemotePlaybackClient implementation. 84 // WebRemotePlaybackClient implementation.
77 void StateChanged(WebRemotePlaybackState) override; 85 void StateChanged(WebRemotePlaybackState) override;
78 void AvailabilityChanged(WebRemotePlaybackAvailability) override; 86 void AvailabilityChanged(WebRemotePlaybackAvailability) override;
79 void PromptCancelled() override; 87 void PromptCancelled() override;
80 bool RemotePlaybackAvailable() const override; 88 bool RemotePlaybackAvailable() const override;
89 void SourceChanged(const WebURL&) override;
81 90
82 // ScriptWrappable implementation. 91 // ScriptWrappable implementation.
83 bool HasPendingActivity() const final; 92 bool HasPendingActivity() const final;
84 93
85 DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting); 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting);
86 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect);
87 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect);
88 97
89 DECLARE_VIRTUAL_TRACE(); 98 DECLARE_VIRTUAL_TRACE();
90 DECLARE_VIRTUAL_TRACE_WRAPPERS(); 99 DECLARE_VIRTUAL_TRACE_WRAPPERS();
91 100
92 private: 101 private:
93 friend class V8RemotePlayback; 102 friend class V8RemotePlayback;
94 friend class RemotePlaybackTest; 103 friend class RemotePlaybackTest;
95 friend class MediaControlsImplTest; 104 friend class MediaControlsImplTest;
96 105
97 explicit RemotePlayback(HTMLMediaElement&); 106 explicit RemotePlayback(HTMLMediaElement&);
98 107
99 // Calls the specified availability callback with the current availability. 108 // Calls the specified availability callback with the current availability.
100 // Need a void() method to post it as a task. 109 // Need a void() method to post it as a task.
101 void NotifyInitialAvailability(int callback_id); 110 void NotifyInitialAvailability(int callback_id);
102 111
112 // Starts or stops listening if there're both
113 // registered availability callbacks and a valid source set.
114 void UpdateListeningState();
115
116 // Fills |availability_urls_| with the info about the given source.
117 // TODO(avayvod): support extra info fetched by the video stack and multiple
118 // sources.
119 void UpdateAvailabilityUrls(const WebURL& source);
120
103 WebRemotePlaybackState state_; 121 WebRemotePlaybackState state_;
104 WebRemotePlaybackAvailability availability_; 122 WebRemotePlaybackAvailability availability_;
105 HeapHashMap<int, TraceWrapperMember<AvailabilityCallbackWrapper>> 123 HeapHashMap<int, TraceWrapperMember<AvailabilityCallbackWrapper>>
106 availability_callbacks_; 124 availability_callbacks_;
107 Member<HTMLMediaElement> media_element_; 125 Member<HTMLMediaElement> media_element_;
108 Member<ScriptPromiseResolver> prompt_promise_resolver_; 126 Member<ScriptPromiseResolver> prompt_promise_resolver_;
127 WebVector<WebURL> availability_urls_;
mark a. foltz 2017/05/31 21:16:41 Only one element here seems to be used at any one
128 bool is_listening_;
109 }; 129 };
110 130
111 } // namespace blink 131 } // namespace blink
112 132
113 #endif // RemotePlayback_h 133 #endif // RemotePlayback_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698