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

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/MediaSession.cpp

Issue 2602663002: MediaSession should use ContextClient instead of ContextLifecycleObserver (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « third_party/WebKit/Source/modules/mediasession/MediaSession.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "modules/mediasession/MediaSession.h" 5 #include "modules/mediasession/MediaSession.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/DocumentUserGestureToken.h" 8 #include "core/dom/DocumentUserGestureToken.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/events/Event.h" 10 #include "core/events/Event.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return mojom::blink::MediaSessionPlaybackState::NONE; 86 return mojom::blink::MediaSessionPlaybackState::NONE;
87 if (stateName == "paused") 87 if (stateName == "paused")
88 return mojom::blink::MediaSessionPlaybackState::PAUSED; 88 return mojom::blink::MediaSessionPlaybackState::PAUSED;
89 DCHECK_EQ(stateName, "playing"); 89 DCHECK_EQ(stateName, "playing");
90 return mojom::blink::MediaSessionPlaybackState::PLAYING; 90 return mojom::blink::MediaSessionPlaybackState::PLAYING;
91 } 91 }
92 92
93 } // anonymous namespace 93 } // anonymous namespace
94 94
95 MediaSession::MediaSession(ExecutionContext* executionContext) 95 MediaSession::MediaSession(ExecutionContext* executionContext)
96 : ContextLifecycleObserver(executionContext), 96 : ContextClient(executionContext),
97 m_playbackState(mojom::blink::MediaSessionPlaybackState::NONE), 97 m_playbackState(mojom::blink::MediaSessionPlaybackState::NONE),
98 m_clientBinding(this) {} 98 m_clientBinding(this) {}
99 99
100 MediaSession* MediaSession::create(ExecutionContext* executionContext) { 100 MediaSession* MediaSession::create(ExecutionContext* executionContext) {
101 return new MediaSession(executionContext); 101 return new MediaSession(executionContext);
102 } 102 }
103 103
104 void MediaSession::dispose() { 104 void MediaSession::dispose() {
105 m_clientBinding.Close(); 105 m_clientBinding.Close();
106 } 106 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 service->SetMetadata(MediaMetadataSanitizer::sanitizeAndConvertToMojo( 139 service->SetMetadata(MediaMetadataSanitizer::sanitizeAndConvertToMojo(
140 m_metadata, getExecutionContext())); 140 m_metadata, getExecutionContext()));
141 } 141 }
142 142
143 const WTF::AtomicString& MediaSession::interfaceName() const { 143 const WTF::AtomicString& MediaSession::interfaceName() const {
144 return EventTargetNames::MediaSession; 144 return EventTargetNames::MediaSession;
145 } 145 }
146 146
147 ExecutionContext* MediaSession::getExecutionContext() const { 147 ExecutionContext* MediaSession::getExecutionContext() const {
148 return ContextLifecycleObserver::getExecutionContext(); 148 return ContextClient::getExecutionContext();
149 } 149 }
150 150
151 mojom::blink::MediaSessionService* MediaSession::getService() { 151 mojom::blink::MediaSessionService* MediaSession::getService() {
152 if (m_service) 152 if (m_service)
153 return m_service.get(); 153 return m_service.get();
154 if (!getExecutionContext()) 154 if (!getExecutionContext())
155 return nullptr; 155 return nullptr;
156 156
157 DCHECK(getExecutionContext()->isDocument()) 157 DCHECK(getExecutionContext()->isDocument())
158 << "MediaSession::getService() is only available from a frame"; 158 << "MediaSession::getService() is only available from a frame";
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 DCHECK(getExecutionContext()->isDocument()); 200 DCHECK(getExecutionContext()->isDocument());
201 Document* document = toDocument(getExecutionContext()); 201 Document* document = toDocument(getExecutionContext());
202 UserGestureIndicator gestureIndicator( 202 UserGestureIndicator gestureIndicator(
203 DocumentUserGestureToken::create(document)); 203 DocumentUserGestureToken::create(document));
204 dispatchEvent(Event::create(mojomActionToEventName(action))); 204 dispatchEvent(Event::create(mojomActionToEventName(action)));
205 } 205 }
206 206
207 DEFINE_TRACE(MediaSession) { 207 DEFINE_TRACE(MediaSession) {
208 visitor->trace(m_metadata); 208 visitor->trace(m_metadata);
209 EventTargetWithInlineData::trace(visitor); 209 EventTargetWithInlineData::trace(visitor);
210 ContextLifecycleObserver::trace(visitor); 210 ContextClient::trace(visitor);
211 } 211 }
212 212
213 } // namespace blink 213 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/mediasession/MediaSession.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698