OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 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 |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
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 #ifndef WebKitSourceBufferList_h | 31 #ifndef SourceBufferList_h |
32 #define WebKitSourceBufferList_h | 32 #define SourceBufferList_h |
33 | 33 |
34 #include "bindings/v8/ScriptWrappable.h" | 34 #include "bindings/v8/ScriptWrappable.h" |
35 #include "core/dom/EventTarget.h" | 35 #include "core/dom/EventTarget.h" |
36 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 class WebKitSourceBuffer; | 41 class SourceBuffer; |
42 class GenericEventQueue; | 42 class GenericEventQueue; |
43 | 43 |
44 class WebKitSourceBufferList : public RefCounted<WebKitSourceBufferList>, public
ScriptWrappable, public EventTarget { | 44 class SourceBufferList : public RefCounted<SourceBufferList>, public ScriptWrapp
able, public EventTarget { |
45 public: | 45 public: |
46 static PassRefPtr<WebKitSourceBufferList> create(ScriptExecutionContext* con
text, GenericEventQueue* asyncEventQueue) | 46 static PassRefPtr<SourceBufferList> create(ScriptExecutionContext* context,
GenericEventQueue* asyncEventQueue) |
47 { | 47 { |
48 return adoptRef(new WebKitSourceBufferList(context, asyncEventQueue)); | 48 return adoptRef(new SourceBufferList(context, asyncEventQueue)); |
49 } | 49 } |
50 virtual ~WebKitSourceBufferList() { } | 50 virtual ~SourceBufferList(); |
51 | 51 |
52 unsigned long length() const; | 52 unsigned long length() const { return m_list.size(); } |
53 WebKitSourceBuffer* item(unsigned index) const; | 53 SourceBuffer* item(unsigned long index) const { return (index < m_list.size(
)) ? m_list[index].get() : 0; } |
54 | 54 |
55 void add(PassRefPtr<WebKitSourceBuffer>); | 55 void add(PassRefPtr<SourceBuffer>); |
56 bool remove(WebKitSourceBuffer*); | 56 void remove(SourceBuffer*); |
| 57 bool contains(SourceBuffer* buffer) { return m_list.find(buffer) != notFound
; } |
57 void clear(); | 58 void clear(); |
58 | 59 |
59 // EventTarget interface | 60 // EventTarget interface |
60 virtual const AtomicString& interfaceName() const OVERRIDE; | 61 virtual const AtomicString& interfaceName() const OVERRIDE; |
61 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; | 62 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
62 | 63 |
63 using RefCounted<WebKitSourceBufferList>::ref; | 64 using RefCounted<SourceBufferList>::ref; |
64 using RefCounted<WebKitSourceBufferList>::deref; | 65 using RefCounted<SourceBufferList>::deref; |
65 | 66 |
66 protected: | 67 protected: |
67 virtual EventTargetData* eventTargetData() OVERRIDE; | 68 virtual EventTargetData* eventTargetData() OVERRIDE; |
68 virtual EventTargetData* ensureEventTargetData() OVERRIDE; | 69 virtual EventTargetData* ensureEventTargetData() OVERRIDE; |
69 | 70 |
70 private: | 71 private: |
71 WebKitSourceBufferList(ScriptExecutionContext*, GenericEventQueue*); | 72 SourceBufferList(ScriptExecutionContext*, GenericEventQueue*); |
72 | 73 |
73 void createAndFireEvent(const AtomicString&); | 74 void scheduleEvent(const AtomicString&); |
74 | 75 |
75 virtual void refEventTarget() OVERRIDE { ref(); } | 76 virtual void refEventTarget() OVERRIDE { ref(); } |
76 virtual void derefEventTarget() OVERRIDE { deref(); } | 77 virtual void derefEventTarget() OVERRIDE { deref(); } |
77 | 78 |
78 EventTargetData m_eventTargetData; | 79 EventTargetData m_eventTargetData; |
79 ScriptExecutionContext* m_scriptExecutionContext; | 80 ScriptExecutionContext* m_scriptExecutionContext; |
80 GenericEventQueue* m_asyncEventQueue; | 81 GenericEventQueue* m_asyncEventQueue; |
81 | 82 |
82 Vector<RefPtr<WebKitSourceBuffer> > m_list; | 83 Vector<RefPtr<SourceBuffer> > m_list; |
83 }; | 84 }; |
84 | 85 |
85 } // namespace WebCore | 86 } // namespace WebCore |
86 | 87 |
87 #endif | 88 #endif |
OLD | NEW |