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

Side by Side Diff: Source/core/html/MediaProvider.cpp

Issue 545933002: Implement HTMLMediaElement::srcObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rewrite where each MediaProvider module register a converter method. Created 6 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h" 32 #include "core/html/MediaProvider.h"
33 33
34 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" 34 #include "wtf/MainThread.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 void CustomElementAsyncImportMicrotaskQueue::enqueue(PassOwnPtrWillBeRawPtr<Cust omElementMicrotaskStep> step) 38 class MediaProviderConverterContainer {
39 public:
40 static MediaProviderConverterContainer& container();
41
42 void registerMediaProviderConverter(RawPtr<MediaProviderConverter>);
43 virtual MediaProvider* convert(const ScriptValue&);
44
45 private:
46 Vector<RawPtr<MediaProviderConverter> > m_converters;
47 };
48
49 MediaProviderConverterContainer& MediaProviderConverterContainer::container()
39 { 50 {
40 m_queue.append(step); 51 ASSERT(isMainThread());
52 DEFINE_STATIC_LOCAL(MediaProviderConverterContainer, instance, ());
53 return instance;
41 } 54 }
42 55
43 void CustomElementAsyncImportMicrotaskQueue::doDispatch() 56 void MediaProviderConverterContainer::registerMediaProviderConverter(RawPtr<Medi aProviderConverter> converter)
44 { 57 {
45 WillBeHeapVector<OwnPtrWillBeMember<CustomElementMicrotaskStep> > remaining; 58 if (m_converters.find(converter) == kNotFound)
59 m_converters.append(converter);
60 }
46 61
47 for (unsigned i = 0; i < m_queue.size(); ++i) { 62 MediaProvider* MediaProviderConverterContainer::convert(const ScriptValue& value )
48 if (CustomElementMicrotaskStep::Processing == m_queue[i]->process()) 63 {
49 remaining.append(m_queue[i].release()); 64 for (Vector<RawPtr<MediaProviderConverter> >::iterator it = m_converters.be gin(); it != m_converters.end(); ++it) {
65 MediaProvider* provider = (*it)->getMediaProvider(value);
66 if (provider)
67 return provider;
50 } 68 }
69 return nullptr;
70 }
51 71
52 m_queue.swap(remaining); 72 MediaProviderConverter::MediaProviderConverter()
73 {
74 MediaProviderConverterContainer::container().registerMediaProviderConverter( this);
75 }
76
77 MediaProvider* MediaProviderConverter::convert(const ScriptValue& value)
78 {
79 return MediaProviderConverterContainer::container().convert(value);
80 }
81
82 MediaProvider::MediaProvider(RawPtr<MediaProviderConverter> converter)
83 {
84 MediaProviderConverterContainer& container = MediaProviderConverterContainer ::container();
85 container.registerMediaProviderConverter(converter);
53 } 86 }
54 87
55 } // namespace blink 88 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698