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

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/MediaSource.cpp

Issue 2583093002: Reduce SuspendableObjects (Closed)
Patch Set: Created 4 years 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 DEFINE_STATIC_LOCAL(const AtomicString, closed, ("closed")); 100 DEFINE_STATIC_LOCAL(const AtomicString, closed, ("closed"));
101 return closed; 101 return closed;
102 } 102 }
103 103
104 const AtomicString& MediaSource::endedKeyword() { 104 const AtomicString& MediaSource::endedKeyword() {
105 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("ended")); 105 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("ended"));
106 return ended; 106 return ended;
107 } 107 }
108 108
109 MediaSource* MediaSource::create(ExecutionContext* context) { 109 MediaSource* MediaSource::create(ExecutionContext* context) {
110 MediaSource* mediaSource = new MediaSource(context); 110 return new MediaSource(context);
111 mediaSource->suspendIfNeeded();
112 return mediaSource;
113 } 111 }
114 112
115 MediaSource::MediaSource(ExecutionContext* context) 113 MediaSource::MediaSource(ExecutionContext* context)
116 : SuspendableObject(context), 114 : ContextLifecycleObserver(context),
117 m_readyState(closedKeyword()), 115 m_readyState(closedKeyword()),
118 m_asyncEventQueue(GenericEventQueue::create(this)), 116 m_asyncEventQueue(GenericEventQueue::create(this)),
119 m_attachedElement(nullptr), 117 m_attachedElement(nullptr),
120 m_sourceBuffers(SourceBufferList::create(getExecutionContext(), 118 m_sourceBuffers(SourceBufferList::create(getExecutionContext(),
121 m_asyncEventQueue.get())), 119 m_asyncEventQueue.get())),
122 m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), 120 m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(),
123 m_asyncEventQueue.get())), 121 m_asyncEventQueue.get())),
124 m_liveSeekableRange(TimeRanges::create()), 122 m_liveSeekableRange(TimeRanges::create()),
125 m_addedToRegistryCounter(0) { 123 m_addedToRegistryCounter(0) {
126 BLINK_MSLOG << __func__ << " this=" << this; 124 BLINK_MSLOG << __func__ << " this=" << this;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 BLINK_MSLOG << __func__ << "(" << type << ") -> " 310 BLINK_MSLOG << __func__ << "(" << type << ") -> "
313 << (result ? "true" : "false"); 311 << (result ? "true" : "false");
314 return result; 312 return result;
315 } 313 }
316 314
317 const AtomicString& MediaSource::interfaceName() const { 315 const AtomicString& MediaSource::interfaceName() const {
318 return EventTargetNames::MediaSource; 316 return EventTargetNames::MediaSource;
319 } 317 }
320 318
321 ExecutionContext* MediaSource::getExecutionContext() const { 319 ExecutionContext* MediaSource::getExecutionContext() const {
322 return SuspendableObject::getExecutionContext(); 320 return ContextLifecycleObserver::getExecutionContext();
323 } 321 }
324 322
325 DEFINE_TRACE(MediaSource) { 323 DEFINE_TRACE(MediaSource) {
326 visitor->trace(m_asyncEventQueue); 324 visitor->trace(m_asyncEventQueue);
327 visitor->trace(m_attachedElement); 325 visitor->trace(m_attachedElement);
328 visitor->trace(m_sourceBuffers); 326 visitor->trace(m_sourceBuffers);
329 visitor->trace(m_activeSourceBuffers); 327 visitor->trace(m_activeSourceBuffers);
330 visitor->trace(m_liveSeekableRange); 328 visitor->trace(m_liveSeekableRange);
331 EventTargetWithInlineData::trace(visitor); 329 EventTargetWithInlineData::trace(visitor);
332 SuspendableObject::trace(visitor); 330 ContextLifecycleObserver::trace(visitor);
333 } 331 }
334 332
335 void MediaSource::setWebMediaSourceAndOpen( 333 void MediaSource::setWebMediaSourceAndOpen(
336 std::unique_ptr<WebMediaSource> webMediaSource) { 334 std::unique_ptr<WebMediaSource> webMediaSource) {
337 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); 335 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this);
338 DCHECK(webMediaSource); 336 DCHECK(webMediaSource);
339 DCHECK(!m_webMediaSource); 337 DCHECK(!m_webMediaSource);
340 DCHECK(m_attachedElement); 338 DCHECK(m_attachedElement);
341 m_webMediaSource = std::move(webMediaSource); 339 m_webMediaSource = std::move(webMediaSource);
342 setReadyState(openKeyword()); 340 setReadyState(openKeyword());
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 event->setTarget(this); 812 event->setTarget(this);
815 813
816 m_asyncEventQueue->enqueueEvent(event); 814 m_asyncEventQueue->enqueueEvent(event);
817 } 815 }
818 816
819 URLRegistry& MediaSource::registry() const { 817 URLRegistry& MediaSource::registry() const {
820 return MediaSourceRegistry::registry(); 818 return MediaSourceRegistry::registry();
821 } 819 }
822 820
823 } // namespace blink 821 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698