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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 | 99 |
| 100 MediaSource::MediaSource(ExecutionContext* context) | 100 MediaSource::MediaSource(ExecutionContext* context) |
| 101 : ActiveScriptWrappable(this) | 101 : ActiveScriptWrappable(this) |
| 102 , ActiveDOMObject(context) | 102 , ActiveDOMObject(context) |
| 103 , m_readyState(closedKeyword()) | 103 , m_readyState(closedKeyword()) |
| 104 , m_asyncEventQueue(GenericEventQueue::create(this)) | 104 , m_asyncEventQueue(GenericEventQueue::create(this)) |
| 105 , m_attachedElement(nullptr) | 105 , m_attachedElement(nullptr) |
| 106 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve ntQueue.get())) | 106 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve ntQueue.get())) |
| 107 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as yncEventQueue.get())) | 107 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as yncEventQueue.get())) |
| 108 , m_liveSeekableRange(TimeRanges::create()) | 108 , m_liveSeekableRange(TimeRanges::create()) |
| 109 , m_isAddedToRegistry(false) | 109 , m_addedToRegistryCounter(0) |
| 110 { | 110 { |
| 111 MSLOG << __FUNCTION__ << " this=" << this; | 111 MSLOG << __FUNCTION__ << " this=" << this; |
| 112 } | 112 } |
| 113 | 113 |
| 114 MediaSource::~MediaSource() | 114 MediaSource::~MediaSource() |
| 115 { | 115 { |
| 116 MSLOG << __FUNCTION__ << " this=" << this; | 116 MSLOG << __FUNCTION__ << " this=" << this; |
| 117 DCHECK(isClosed()); | 117 DCHECK(isClosed()); |
| 118 } | 118 } |
| 119 | 119 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); | 295 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); |
| 296 DCHECK(webMediaSource); | 296 DCHECK(webMediaSource); |
| 297 DCHECK(!m_webMediaSource); | 297 DCHECK(!m_webMediaSource); |
| 298 DCHECK(m_attachedElement); | 298 DCHECK(m_attachedElement); |
| 299 m_webMediaSource = std::move(webMediaSource); | 299 m_webMediaSource = std::move(webMediaSource); |
| 300 setReadyState(openKeyword()); | 300 setReadyState(openKeyword()); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void MediaSource::addedToRegistry() | 303 void MediaSource::addedToRegistry() |
| 304 { | 304 { |
| 305 DCHECK(!m_isAddedToRegistry); | 305 ++m_addedToRegistryCounter; |
|
wolenetz
2016/07/11 18:03:17
A web app would have to work really hard to overfl
servolk
2016/07/11 18:13:25
Done.
| |
| 306 m_isAddedToRegistry = true; | |
| 307 } | 306 } |
| 308 | 307 |
| 309 void MediaSource::removedFromRegistry() | 308 void MediaSource::removedFromRegistry() |
| 310 { | 309 { |
| 311 DCHECK(m_isAddedToRegistry); | 310 DCHECK_GT(m_addedToRegistryCounter, 0); |
| 312 m_isAddedToRegistry = false; | 311 --m_addedToRegistryCounter; |
| 313 } | 312 } |
| 314 | 313 |
| 315 double MediaSource::duration() const | 314 double MediaSource::duration() const |
| 316 { | 315 { |
| 317 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration(); | 316 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration(); |
| 318 } | 317 } |
| 319 | 318 |
| 320 TimeRanges* MediaSource::buffered() const | 319 TimeRanges* MediaSource::buffered() const |
| 321 { | 320 { |
| 322 // Implements MediaSource algorithm for HTMLMediaElement.buffered. | 321 // Implements MediaSource algorithm for HTMLMediaElement.buffered. |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 return; | 640 return; |
| 642 | 641 |
| 643 setReadyState(openKeyword()); | 642 setReadyState(openKeyword()); |
| 644 m_webMediaSource->unmarkEndOfStream(); | 643 m_webMediaSource->unmarkEndOfStream(); |
| 645 } | 644 } |
| 646 | 645 |
| 647 bool MediaSource::hasPendingActivity() const | 646 bool MediaSource::hasPendingActivity() const |
| 648 { | 647 { |
| 649 return m_attachedElement || m_webMediaSource | 648 return m_attachedElement || m_webMediaSource |
| 650 || m_asyncEventQueue->hasPendingEvents() | 649 || m_asyncEventQueue->hasPendingEvents() |
| 651 || m_isAddedToRegistry; | 650 || m_addedToRegistryCounter > 0; |
| 652 } | 651 } |
| 653 | 652 |
| 654 void MediaSource::stop() | 653 void MediaSource::stop() |
| 655 { | 654 { |
| 656 m_asyncEventQueue->close(); | 655 m_asyncEventQueue->close(); |
| 657 if (!isClosed()) | 656 if (!isClosed()) |
| 658 setReadyState(closedKeyword()); | 657 setReadyState(closedKeyword()); |
| 659 m_webMediaSource.reset(); | 658 m_webMediaSource.reset(); |
| 660 } | 659 } |
| 661 | 660 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 | 695 |
| 697 m_asyncEventQueue->enqueueEvent(event); | 696 m_asyncEventQueue->enqueueEvent(event); |
| 698 } | 697 } |
| 699 | 698 |
| 700 URLRegistry& MediaSource::registry() const | 699 URLRegistry& MediaSource::registry() const |
| 701 { | 700 { |
| 702 return MediaSourceRegistry::registry(); | 701 return MediaSourceRegistry::registry(); |
| 703 } | 702 } |
| 704 | 703 |
| 705 } // namespace blink | 704 } // namespace blink |
| OLD | NEW |