OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 29 matching lines...) Expand all Loading... |
40 class ExecutionContext; | 40 class ExecutionContext; |
41 | 41 |
42 class TextTrackLoaderClient { | 42 class TextTrackLoaderClient { |
43 public: | 43 public: |
44 virtual ~TextTrackLoaderClient() { } | 44 virtual ~TextTrackLoaderClient() { } |
45 | 45 |
46 virtual bool shouldLoadCues(TextTrackLoader*) = 0; | 46 virtual bool shouldLoadCues(TextTrackLoader*) = 0; |
47 virtual void newCuesAvailable(TextTrackLoader*) = 0; | 47 virtual void newCuesAvailable(TextTrackLoader*) = 0; |
48 virtual void cueLoadingStarted(TextTrackLoader*) = 0; | 48 virtual void cueLoadingStarted(TextTrackLoader*) = 0; |
49 virtual void cueLoadingCompleted(TextTrackLoader*, bool loadingFailed) = 0; | 49 virtual void cueLoadingCompleted(TextTrackLoader*, bool loadingFailed) = 0; |
50 #if ENABLE(WEBVTT_REGIONS) | |
51 virtual void newRegionsAvailable(TextTrackLoader*) = 0; | 50 virtual void newRegionsAvailable(TextTrackLoader*) = 0; |
52 #endif | |
53 }; | 51 }; |
54 | 52 |
55 class TextTrackLoader : public ResourceClient, private WebVTTParserClient { | 53 class TextTrackLoader : public ResourceClient, private WebVTTParserClient { |
56 WTF_MAKE_NONCOPYABLE(TextTrackLoader); | 54 WTF_MAKE_NONCOPYABLE(TextTrackLoader); |
57 WTF_MAKE_FAST_ALLOCATED; | 55 WTF_MAKE_FAST_ALLOCATED; |
58 public: | 56 public: |
59 static PassOwnPtr<TextTrackLoader> create(TextTrackLoaderClient* client, Exe
cutionContext* context) | 57 static PassOwnPtr<TextTrackLoader> create(TextTrackLoaderClient* client, Exe
cutionContext* context) |
60 { | 58 { |
61 return adoptPtr(new TextTrackLoader(client, context)); | 59 return adoptPtr(new TextTrackLoader(client, context)); |
62 } | 60 } |
63 virtual ~TextTrackLoader(); | 61 virtual ~TextTrackLoader(); |
64 | 62 |
65 bool load(const KURL&, const String& crossOriginMode); | 63 bool load(const KURL&, const String& crossOriginMode); |
66 void cancelLoad(); | 64 void cancelLoad(); |
67 | 65 |
68 enum State { Idle, Loading, Finished, Failed }; | 66 enum State { Idle, Loading, Finished, Failed }; |
69 State loadState() { return m_state; } | 67 State loadState() { return m_state; } |
70 | 68 |
71 void getNewCues(Vector<RefPtr<TextTrackCue> >& outputCues); | 69 void getNewCues(Vector<RefPtr<TextTrackCue> >& outputCues); |
72 #if ENABLE(WEBVTT_REGIONS) | |
73 void getNewRegions(Vector<RefPtr<TextTrackRegion> >& outputRegions); | 70 void getNewRegions(Vector<RefPtr<TextTrackRegion> >& outputRegions); |
74 #endif | |
75 private: | 71 private: |
76 | 72 |
77 // ResourceClient | 73 // ResourceClient |
78 virtual void notifyFinished(Resource*); | 74 virtual void notifyFinished(Resource*); |
79 virtual void deprecatedDidReceiveResource(Resource*); | 75 virtual void deprecatedDidReceiveResource(Resource*); |
80 | 76 |
81 // WebVTTParserClient | 77 // WebVTTParserClient |
82 virtual void newCuesParsed(); | 78 virtual void newCuesParsed(); |
83 #if ENABLE(WEBVTT_REGIONS) | |
84 virtual void newRegionsParsed(); | 79 virtual void newRegionsParsed(); |
85 #endif | |
86 virtual void fileFailedToParse(); | 80 virtual void fileFailedToParse(); |
87 | 81 |
88 TextTrackLoader(TextTrackLoaderClient*, ExecutionContext*); | 82 TextTrackLoader(TextTrackLoaderClient*, ExecutionContext*); |
89 | 83 |
90 void processNewCueData(Resource*); | 84 void processNewCueData(Resource*); |
91 void cueLoadTimerFired(Timer<TextTrackLoader>*); | 85 void cueLoadTimerFired(Timer<TextTrackLoader>*); |
92 void corsPolicyPreventedLoad(); | 86 void corsPolicyPreventedLoad(); |
93 | 87 |
94 TextTrackLoaderClient* m_client; | 88 TextTrackLoaderClient* m_client; |
95 OwnPtr<WebVTTParser> m_cueParser; | 89 OwnPtr<WebVTTParser> m_cueParser; |
96 ResourcePtr<TextTrackResource> m_cachedCueData; | 90 ResourcePtr<TextTrackResource> m_cachedCueData; |
97 ExecutionContext* m_executionContext; | 91 ExecutionContext* m_executionContext; |
98 Timer<TextTrackLoader> m_cueLoadTimer; | 92 Timer<TextTrackLoader> m_cueLoadTimer; |
99 String m_crossOriginMode; | 93 String m_crossOriginMode; |
100 State m_state; | 94 State m_state; |
101 unsigned m_parseOffset; | 95 unsigned m_parseOffset; |
102 bool m_newCuesAvailable; | 96 bool m_newCuesAvailable; |
103 }; | 97 }; |
104 | 98 |
105 } // namespace WebCore | 99 } // namespace WebCore |
106 | 100 |
107 #endif | 101 #endif |
OLD | NEW |