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

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: Addressed comments. 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
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
sof 2014/09/18 07:33:17 New files are preferably adorned with a shorter ve
perkj_chrome 2014/09/18 14:47:08 Done.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * 3. Neither the name of Google Inc. nor the names of its contributors
15 * may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "config.h"
32 #include "core/html/MediaProvider.h"
33
34 #include "wtf/HashMap.h"
35 #include "wtf/MainThread.h"
36 #include "wtf/text/StringHash.h"
37
38 namespace blink {
39
40 class MediaProviderConverterContainer {
41 public:
42 static MediaProviderConverterContainer& container();
43
44 void registerMediaProviderConverter(const String& interfaceName, const Media Provider::Converter&);
45 virtual MediaProvider* convert(const ScriptValue&);
46
47 private:
48 HashMap<String, MediaProvider::Converter> m_converters;
49 };
50
51 MediaProviderConverterContainer& MediaProviderConverterContainer::container()
52 {
53 ASSERT(isMainThread());
54 DEFINE_STATIC_LOCAL(MediaProviderConverterContainer, instance, ());
55 return instance;
56 }
57
58 void MediaProviderConverterContainer::registerMediaProviderConverter(const Strin g& interfaceName, const MediaProvider::Converter& converter)
59 {
60 if (m_converters.get(interfaceName).isNull())
61 m_converters.set(interfaceName, converter);
62 }
63
64 MediaProvider* MediaProviderConverterContainer::convert(const ScriptValue& value )
65 {
66 for (HashMap<String, MediaProvider::Converter>::iterator it = m_converters.b egin(); it != m_converters.end(); ++it) {
67 MediaProvider* provider = (it->value)(value);
68 if (provider)
69 return provider;
70 }
71 return nullptr;
72 }
73
74 MediaProvider::MediaProvider(const String& interfaceName, const Converter& conve rter)
75 {
76 MediaProviderConverterContainer& container = MediaProviderConverterContainer ::container();
77 container.registerMediaProviderConverter(interfaceName, converter);
78 }
79
80 MediaProvider* MediaProvider::convert(const ScriptValue& value)
81 {
82 MediaProviderConverterContainer& container = MediaProviderConverterContainer ::container();
83 return container.convert(value);
84 }
85
86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698