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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 virtual void newCuesAvailable(TextTrackLoader*) = 0; | 45 virtual void newCuesAvailable(TextTrackLoader*) = 0; |
46 virtual void cueLoadingStarted(TextTrackLoader*) = 0; | 46 virtual void cueLoadingStarted(TextTrackLoader*) = 0; |
47 virtual void cueLoadingCompleted(TextTrackLoader*, bool loadingFailed) = 0; | 47 virtual void cueLoadingCompleted(TextTrackLoader*, bool loadingFailed) = 0; |
48 virtual void newRegionsAvailable(TextTrackLoader*) = 0; | 48 virtual void newRegionsAvailable(TextTrackLoader*) = 0; |
49 }; | 49 }; |
50 | 50 |
51 class TextTrackLoader : public RawResourceClient, private WebVTTParserClient { | 51 class TextTrackLoader : public RawResourceClient, private WebVTTParserClient { |
52 WTF_MAKE_NONCOPYABLE(TextTrackLoader); | 52 WTF_MAKE_NONCOPYABLE(TextTrackLoader); |
53 WTF_MAKE_FAST_ALLOCATED; | 53 WTF_MAKE_FAST_ALLOCATED; |
54 public: | 54 public: |
55 static PassOwnPtr<TextTrackLoader> create(TextTrackLoaderClient* client, Doc
ument& document) | 55 static PassOwnPtr<TextTrackLoader> create(TextTrackLoaderClient& client, Doc
ument& document) |
56 { | 56 { |
57 return adoptPtr(new TextTrackLoader(client, document)); | 57 return adoptPtr(new TextTrackLoader(client, document)); |
58 } | 58 } |
59 virtual ~TextTrackLoader(); | 59 virtual ~TextTrackLoader(); |
60 | 60 |
61 bool load(const KURL&, const String& crossOriginMode); | 61 bool load(const KURL&, const String& crossOriginMode); |
62 void cancelLoad(); | 62 void cancelLoad(); |
63 | 63 |
64 enum State { Idle, Loading, Finished, Failed }; | 64 enum State { Idle, Loading, Finished, Failed }; |
65 State loadState() { return m_state; } | 65 State loadState() { return m_state; } |
66 | 66 |
67 void getNewCues(Vector<RefPtr<TextTrackCue> >& outputCues); | 67 void getNewCues(Vector<RefPtr<TextTrackCue> >& outputCues); |
68 void getNewRegions(Vector<RefPtr<TextTrackRegion> >& outputRegions); | 68 void getNewRegions(Vector<RefPtr<TextTrackRegion> >& outputRegions); |
69 private: | 69 private: |
70 | 70 |
71 // RawResourceClient | 71 // RawResourceClient |
72 virtual void dataReceived(Resource*, const char* data, int length) OVERRIDE; | 72 virtual void dataReceived(Resource*, const char* data, int length) OVERRIDE; |
73 virtual void notifyFinished(Resource*) OVERRIDE; | 73 virtual void notifyFinished(Resource*) OVERRIDE; |
74 | 74 |
75 // WebVTTParserClient | 75 // WebVTTParserClient |
76 virtual void newCuesParsed() OVERRIDE; | 76 virtual void newCuesParsed() OVERRIDE; |
77 virtual void newRegionsParsed() OVERRIDE; | 77 virtual void newRegionsParsed() OVERRIDE; |
78 virtual void fileFailedToParse() OVERRIDE; | 78 virtual void fileFailedToParse() OVERRIDE; |
79 | 79 |
80 TextTrackLoader(TextTrackLoaderClient*, Document&); | 80 TextTrackLoader(TextTrackLoaderClient&, Document&); |
81 | 81 |
82 void cueLoadTimerFired(Timer<TextTrackLoader>*); | 82 void cueLoadTimerFired(Timer<TextTrackLoader>*); |
83 void corsPolicyPreventedLoad(); | 83 void corsPolicyPreventedLoad(); |
84 | 84 |
85 TextTrackLoaderClient* m_client; | 85 TextTrackLoaderClient& m_client; |
86 OwnPtr<WebVTTParser> m_cueParser; | 86 OwnPtr<WebVTTParser> m_cueParser; |
87 ResourcePtr<RawResource> m_resource; | 87 ResourcePtr<RawResource> m_resource; |
88 // FIXME: Remove this pointer and get the Document from m_client. | 88 // FIXME: Remove this pointer and get the Document from m_client. |
89 Document& m_document; | 89 Document& m_document; |
90 Timer<TextTrackLoader> m_cueLoadTimer; | 90 Timer<TextTrackLoader> m_cueLoadTimer; |
91 String m_crossOriginMode; | 91 String m_crossOriginMode; |
92 State m_state; | 92 State m_state; |
93 bool m_newCuesAvailable; | 93 bool m_newCuesAvailable; |
94 }; | 94 }; |
95 | 95 |
96 } // namespace WebCore | 96 } // namespace WebCore |
97 | 97 |
98 #endif | 98 #endif |
OLD | NEW |