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

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

Issue 363953002: Oilpan: have the media element safely close its MediaSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tidy clearing of m_attachedElement Created 6 years, 5 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 | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/SourceBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 { 91 {
92 MediaSource* mediaSource(adoptRefCountedGarbageCollected(new MediaSource(con text))); 92 MediaSource* mediaSource(adoptRefCountedGarbageCollected(new MediaSource(con text)));
93 mediaSource->suspendIfNeeded(); 93 mediaSource->suspendIfNeeded();
94 return mediaSource; 94 return mediaSource;
95 } 95 }
96 96
97 MediaSource::MediaSource(ExecutionContext* context) 97 MediaSource::MediaSource(ExecutionContext* context)
98 : ActiveDOMObject(context) 98 : ActiveDOMObject(context)
99 , m_readyState(closedKeyword()) 99 , m_readyState(closedKeyword())
100 , m_asyncEventQueue(GenericEventQueue::create(this)) 100 , m_asyncEventQueue(GenericEventQueue::create(this))
101 , m_attachedElement(0) 101 , m_attachedElement(nullptr)
102 , m_sourceBuffers(SourceBufferList::create(executionContext(), m_asyncEventQ ueue.get())) 102 , m_sourceBuffers(SourceBufferList::create(executionContext(), m_asyncEventQ ueue.get()))
103 , m_activeSourceBuffers(SourceBufferList::create(executionContext(), m_async EventQueue.get())) 103 , m_activeSourceBuffers(SourceBufferList::create(executionContext(), m_async EventQueue.get()))
104 { 104 {
105 WTF_LOG(Media, "MediaSource::MediaSource %p", this); 105 WTF_LOG(Media, "MediaSource::MediaSource %p", this);
106 ScriptWrappable::init(this); 106 ScriptWrappable::init(this);
107 } 107 }
108 108
109 MediaSource::~MediaSource() 109 MediaSource::~MediaSource()
110 { 110 {
111 WTF_LOG(Media, "MediaSource::~MediaSource %p", this); 111 WTF_LOG(Media, "MediaSource::~MediaSource %p", this);
112 #if !ENABLE(OILPAN)
112 ASSERT(isClosed()); 113 ASSERT(isClosed());
114 #endif
113 } 115 }
114 116
115 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState) 117 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState)
116 { 118 {
117 WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), t his); 119 WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), t his);
118 120
119 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 121 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
120 // 1. If type is an empty string then throw an InvalidAccessError exception 122 // 1. If type is an empty string then throw an InvalidAccessError exception
121 // and abort these steps. 123 // and abort these steps.
122 if (type.isEmpty()) { 124 if (type.isEmpty()) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 const AtomicString& MediaSource::interfaceName() const 252 const AtomicString& MediaSource::interfaceName() const
251 { 253 {
252 return EventTargetNames::MediaSource; 254 return EventTargetNames::MediaSource;
253 } 255 }
254 256
255 ExecutionContext* MediaSource::executionContext() const 257 ExecutionContext* MediaSource::executionContext() const
256 { 258 {
257 return ActiveDOMObject::executionContext(); 259 return ActiveDOMObject::executionContext();
258 } 260 }
259 261
262 void MediaSource::clearWeakMembers(Visitor* visitor)
263 {
264 #if ENABLE(OILPAN)
265 // Oilpan: If the MediaSource survived, but its attached media
266 // element did not, signal the element that it can safely
267 // notify its MediaSource during finalization by calling close().
268 if (m_attachedElement && !visitor->isAlive(m_attachedElement)) {
269 m_attachedElement->setCloseMediaSourceWhenFinalizing();
270 m_attachedElement.clear();
271 }
272 #endif
273 }
274
260 void MediaSource::trace(Visitor* visitor) 275 void MediaSource::trace(Visitor* visitor)
261 { 276 {
262 #if ENABLE(OILPAN) 277 #if ENABLE(OILPAN)
263 visitor->trace(m_asyncEventQueue); 278 visitor->trace(m_asyncEventQueue);
264 #endif 279 #endif
265 visitor->trace(m_sourceBuffers); 280 visitor->trace(m_sourceBuffers);
266 visitor->trace(m_activeSourceBuffers); 281 visitor->trace(m_activeSourceBuffers);
282 visitor->registerWeakMembers<MediaSource, &MediaSource::clearWeakMembers>(th is);
267 EventTargetWithInlineData::trace(visitor); 283 EventTargetWithInlineData::trace(visitor);
268 } 284 }
269 285
270 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce) 286 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce)
271 { 287 {
272 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); 288 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this);
273 ASSERT(webMediaSource); 289 ASSERT(webMediaSource);
274 ASSERT(!m_webMediaSource); 290 ASSERT(!m_webMediaSource);
275 ASSERT(m_attachedElement); 291 ASSERT(m_attachedElement);
276 m_webMediaSource = webMediaSource; 292 m_webMediaSource = webMediaSource;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 412
397 void MediaSource::setReadyState(const AtomicString& state) 413 void MediaSource::setReadyState(const AtomicString& state)
398 { 414 {
399 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); 415 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword());
400 416
401 AtomicString oldState = readyState(); 417 AtomicString oldState = readyState();
402 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); 418 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data());
403 419
404 if (state == closedKeyword()) { 420 if (state == closedKeyword()) {
405 m_webMediaSource.clear(); 421 m_webMediaSource.clear();
406 m_attachedElement = 0; 422 m_attachedElement.clear();
407 } 423 }
408 424
409 if (oldState == state) 425 if (oldState == state)
410 return; 426 return;
411 427
412 m_readyState = state; 428 m_readyState = state;
413 429
414 onReadyStateChange(oldState, state); 430 onReadyStateChange(oldState, state);
415 } 431 }
416 432
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 556
541 m_asyncEventQueue->enqueueEvent(event.release()); 557 m_asyncEventQueue->enqueueEvent(event.release());
542 } 558 }
543 559
544 URLRegistry& MediaSource::registry() const 560 URLRegistry& MediaSource::registry() const
545 { 561 {
546 return MediaSourceRegistry::registry(); 562 return MediaSourceRegistry::registry();
547 } 563 }
548 564
549 } // namespace WebCore 565 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/SourceBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698