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

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

Issue 2133143003: Allow multiple URL.createObjectURL invocations for MediaSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 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 | « third_party/WebKit/Source/modules/mediasource/MediaSource.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 /* 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
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
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;
306 m_isAddedToRegistry = true; 306 // Ensure there's no counter overflow.
307 CHECK_GT(m_addedToRegistryCounter, 0);
307 } 308 }
308 309
309 void MediaSource::removedFromRegistry() 310 void MediaSource::removedFromRegistry()
310 { 311 {
311 DCHECK(m_isAddedToRegistry); 312 DCHECK_GT(m_addedToRegistryCounter, 0);
312 m_isAddedToRegistry = false; 313 --m_addedToRegistryCounter;
313 } 314 }
314 315
315 double MediaSource::duration() const 316 double MediaSource::duration() const
316 { 317 {
317 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration(); 318 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration();
318 } 319 }
319 320
320 TimeRanges* MediaSource::buffered() const 321 TimeRanges* MediaSource::buffered() const
321 { 322 {
322 // Implements MediaSource algorithm for HTMLMediaElement.buffered. 323 // Implements MediaSource algorithm for HTMLMediaElement.buffered.
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 return; 642 return;
642 643
643 setReadyState(openKeyword()); 644 setReadyState(openKeyword());
644 m_webMediaSource->unmarkEndOfStream(); 645 m_webMediaSource->unmarkEndOfStream();
645 } 646 }
646 647
647 bool MediaSource::hasPendingActivity() const 648 bool MediaSource::hasPendingActivity() const
648 { 649 {
649 return m_attachedElement || m_webMediaSource 650 return m_attachedElement || m_webMediaSource
650 || m_asyncEventQueue->hasPendingEvents() 651 || m_asyncEventQueue->hasPendingEvents()
651 || m_isAddedToRegistry; 652 || m_addedToRegistryCounter > 0;
652 } 653 }
653 654
654 void MediaSource::stop() 655 void MediaSource::stop()
655 { 656 {
656 m_asyncEventQueue->close(); 657 m_asyncEventQueue->close();
657 if (!isClosed()) 658 if (!isClosed())
658 setReadyState(closedKeyword()); 659 setReadyState(closedKeyword());
659 m_webMediaSource.reset(); 660 m_webMediaSource.reset();
660 } 661 }
661 662
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 697
697 m_asyncEventQueue->enqueueEvent(event); 698 m_asyncEventQueue->enqueueEvent(event);
698 } 699 }
699 700
700 URLRegistry& MediaSource::registry() const 701 URLRegistry& MediaSource::registry() const
701 { 702 {
702 return MediaSourceRegistry::registry(); 703 return MediaSourceRegistry::registry();
703 } 704 }
704 705
705 } // namespace blink 706 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/mediasource/MediaSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698