Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/mediasource/SourceBufferTrackBaseSupplement.h" | |
| 6 | |
| 7 #include "core/html/track/TrackBase.h" | |
| 8 #include "modules/mediasource/SourceBuffer.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 static const char* SupplementName = "SourceBufferTrackBaseSupplement"; | |
| 13 | |
| 14 SourceBufferTrackBaseSupplement::SourceBufferTrackBaseSupplement(TrackBase& trac kBase) | |
| 15 { | |
| 16 provideTo(trackBase, SupplementName, this); | |
| 17 } | |
| 18 | |
| 19 // static | |
| 20 SourceBufferTrackBaseSupplement& SourceBufferTrackBaseSupplement::from(TrackBase & track) | |
| 21 { | |
| 22 SourceBufferTrackBaseSupplement* supplement = static_cast<SourceBufferTrackB aseSupplement*>(Supplement<TrackBase>::from(track, SupplementName)); | |
| 23 if (!supplement) { | |
| 24 supplement = new SourceBufferTrackBaseSupplement(track); | |
| 25 } | |
| 26 return *supplement; | |
| 27 } | |
| 28 | |
| 29 // static | |
| 30 SourceBuffer* SourceBufferTrackBaseSupplement::sourceBuffer(TrackBase& track) | |
| 31 { | |
| 32 // We could use SourceBufferTrackBaseSupplement::from(track).m_sourceBuffer here, but the 'from' method always creates a new supplement if an | |
| 33 // existing one is not found, so using 'from' here would result in supplemen t being created even for tracks that never have non-null .sourceBuffer | |
| 34 // property (i.e. tracks created by HTMLMediaElement and not SourceBuffer). | |
| 35 SourceBufferTrackBaseSupplement* supplement = static_cast<SourceBufferTrackB aseSupplement*>(Supplement<TrackBase>::from(track, SupplementName)); | |
|
philipj_slow
2016/04/07 08:59:35
You're only doing this in one place, but CSSSelect
servolk
2016/04/07 17:03:55
Ah, ok, thanks for pointing that out. If just wasn
| |
| 36 if (supplement) | |
| 37 return supplement->m_sourceBuffer; | |
| 38 return nullptr; | |
| 39 } | |
| 40 | |
| 41 void SourceBufferTrackBaseSupplement::setSourceBuffer(SourceBuffer* sourceBuffer ) | |
| 42 { | |
| 43 m_sourceBuffer = sourceBuffer; | |
| 44 } | |
| 45 | |
| 46 DEFINE_TRACE(SourceBufferTrackBaseSupplement) | |
| 47 { | |
| 48 visitor->trace(m_sourceBuffer); | |
| 49 Supplement<TrackBase>::trace(visitor); | |
| 50 } | |
| 51 | |
| 52 } // namespace blink | |
| 53 | |
| OLD | NEW |