Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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(). | |
|
haraken
2014/07/03 09:46:05
Also let's add a comment that m_attachedElement is
sof
2014/07/03 09:49:00
Oh, I'm sorry - I merely forgot to follow up on yo
| |
| 268 if (m_attachedElement && !visitor->isAlive(m_attachedElement)) | |
| 269 m_attachedElement->setCloseMediaSourceWhenFinalizing(); | |
| 270 #endif | |
| 271 } | |
| 272 | |
| 260 void MediaSource::trace(Visitor* visitor) | 273 void MediaSource::trace(Visitor* visitor) |
| 261 { | 274 { |
| 262 #if ENABLE(OILPAN) | 275 #if ENABLE(OILPAN) |
| 263 visitor->trace(m_asyncEventQueue); | 276 visitor->trace(m_asyncEventQueue); |
| 264 #endif | 277 #endif |
| 265 visitor->trace(m_sourceBuffers); | 278 visitor->trace(m_sourceBuffers); |
| 266 visitor->trace(m_activeSourceBuffers); | 279 visitor->trace(m_activeSourceBuffers); |
| 280 visitor->registerWeakMembers<MediaSource, &MediaSource::clearWeakMembers>(th is); | |
| 267 EventTargetWithInlineData::trace(visitor); | 281 EventTargetWithInlineData::trace(visitor); |
| 268 } | 282 } |
| 269 | 283 |
| 270 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce) | 284 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce) |
| 271 { | 285 { |
| 272 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); | 286 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); |
| 273 ASSERT(webMediaSource); | 287 ASSERT(webMediaSource); |
| 274 ASSERT(!m_webMediaSource); | 288 ASSERT(!m_webMediaSource); |
| 275 ASSERT(m_attachedElement); | 289 ASSERT(m_attachedElement); |
| 276 m_webMediaSource = webMediaSource; | 290 m_webMediaSource = webMediaSource; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 | 410 |
| 397 void MediaSource::setReadyState(const AtomicString& state) | 411 void MediaSource::setReadyState(const AtomicString& state) |
| 398 { | 412 { |
| 399 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); | 413 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); |
| 400 | 414 |
| 401 AtomicString oldState = readyState(); | 415 AtomicString oldState = readyState(); |
| 402 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); | 416 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); |
| 403 | 417 |
| 404 if (state == closedKeyword()) { | 418 if (state == closedKeyword()) { |
| 405 m_webMediaSource.clear(); | 419 m_webMediaSource.clear(); |
| 406 m_attachedElement = 0; | 420 m_attachedElement = nullptr; |
| 407 } | 421 } |
| 408 | 422 |
| 409 if (oldState == state) | 423 if (oldState == state) |
| 410 return; | 424 return; |
| 411 | 425 |
| 412 m_readyState = state; | 426 m_readyState = state; |
| 413 | 427 |
| 414 onReadyStateChange(oldState, state); | 428 onReadyStateChange(oldState, state); |
| 415 } | 429 } |
| 416 | 430 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 | 554 |
| 541 m_asyncEventQueue->enqueueEvent(event.release()); | 555 m_asyncEventQueue->enqueueEvent(event.release()); |
| 542 } | 556 } |
| 543 | 557 |
| 544 URLRegistry& MediaSource::registry() const | 558 URLRegistry& MediaSource::registry() const |
| 545 { | 559 { |
| 546 return MediaSourceRegistry::registry(); | 560 return MediaSourceRegistry::registry(); |
| 547 } | 561 } |
| 548 | 562 |
| 549 } // namespace WebCore | 563 } // namespace WebCore |
| OLD | NEW |