| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 class Document; | 37 class Document; |
| 38 class TextTrackLoader; | 38 class TextTrackLoader; |
| 39 | 39 |
| 40 class TextTrackLoaderClient : public GarbageCollectedMixin { | 40 class TextTrackLoaderClient : public GarbageCollectedMixin { |
| 41 public: | 41 public: |
| 42 virtual ~TextTrackLoaderClient() {} | 42 virtual ~TextTrackLoaderClient() {} |
| 43 | 43 |
| 44 virtual void newCuesAvailable(TextTrackLoader*) = 0; | 44 virtual void newCuesAvailable(TextTrackLoader*) = 0; |
| 45 virtual void cueLoadingCompleted(TextTrackLoader*, bool loadingFailed) = 0; | 45 virtual void cueLoadingCompleted(TextTrackLoader*, bool loadingFailed) = 0; |
| 46 virtual void newRegionsAvailable(TextTrackLoader*) = 0; | |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 class TextTrackLoader final : public GarbageCollectedFinalized<TextTrackLoader>, | 48 class TextTrackLoader final : public GarbageCollectedFinalized<TextTrackLoader>, |
| 50 public ResourceOwner<RawResource>, | 49 public ResourceOwner<RawResource>, |
| 51 private VTTParserClient { | 50 private VTTParserClient { |
| 52 USING_GARBAGE_COLLECTED_MIXIN(TextTrackLoader); | 51 USING_GARBAGE_COLLECTED_MIXIN(TextTrackLoader); |
| 53 | 52 |
| 54 public: | 53 public: |
| 55 static TextTrackLoader* create(TextTrackLoaderClient& client, | 54 static TextTrackLoader* create(TextTrackLoaderClient& client, |
| 56 Document& document) { | 55 Document& document) { |
| 57 return new TextTrackLoader(client, document); | 56 return new TextTrackLoader(client, document); |
| 58 } | 57 } |
| 59 ~TextTrackLoader() override; | 58 ~TextTrackLoader() override; |
| 60 | 59 |
| 61 bool load(const KURL&, CrossOriginAttributeValue); | 60 bool load(const KURL&, CrossOriginAttributeValue); |
| 62 void cancelLoad(); | 61 void cancelLoad(); |
| 63 | 62 |
| 64 enum State { Idle, Loading, Finished, Failed }; | 63 enum State { Idle, Loading, Finished, Failed }; |
| 65 State loadState() { return m_state; } | 64 State loadState() { return m_state; } |
| 66 | 65 |
| 67 void getNewCues(HeapVector<Member<TextTrackCue>>& outputCues); | 66 void getNewCues(HeapVector<Member<TextTrackCue>>& outputCues); |
| 68 void getNewRegions(HeapVector<Member<VTTRegion>>& outputRegions); | |
| 69 | 67 |
| 70 DECLARE_TRACE(); | 68 DECLARE_TRACE(); |
| 71 | 69 |
| 72 private: | 70 private: |
| 73 // RawResourceClient | 71 // RawResourceClient |
| 74 bool redirectReceived(Resource*, | 72 bool redirectReceived(Resource*, |
| 75 const ResourceRequest&, | 73 const ResourceRequest&, |
| 76 const ResourceResponse&) override; | 74 const ResourceResponse&) override; |
| 77 void dataReceived(Resource*, const char* data, size_t length) override; | 75 void dataReceived(Resource*, const char* data, size_t length) override; |
| 78 void notifyFinished(Resource*) override; | 76 void notifyFinished(Resource*) override; |
| 79 String debugName() const override { return "TextTrackLoader"; } | 77 String debugName() const override { return "TextTrackLoader"; } |
| 80 | 78 |
| 81 // VTTParserClient | 79 // VTTParserClient |
| 82 void newCuesParsed() override; | 80 void newCuesParsed() override; |
| 83 void newRegionsParsed() override; | |
| 84 void fileFailedToParse() override; | 81 void fileFailedToParse() override; |
| 85 | 82 |
| 86 TextTrackLoader(TextTrackLoaderClient&, Document&); | 83 TextTrackLoader(TextTrackLoaderClient&, Document&); |
| 87 | 84 |
| 88 void cueLoadTimerFired(TimerBase*); | 85 void cueLoadTimerFired(TimerBase*); |
| 89 void corsPolicyPreventedLoad(SecurityOrigin*, const KURL&); | 86 void corsPolicyPreventedLoad(SecurityOrigin*, const KURL&); |
| 90 | 87 |
| 91 Document& document() const { return *m_document; } | 88 Document& document() const { return *m_document; } |
| 92 | 89 |
| 93 Member<TextTrackLoaderClient> m_client; | 90 Member<TextTrackLoaderClient> m_client; |
| 94 Member<VTTParser> m_cueParser; | 91 Member<VTTParser> m_cueParser; |
| 95 // FIXME: Remove this pointer and get the Document from m_client. | 92 // FIXME: Remove this pointer and get the Document from m_client. |
| 96 Member<Document> m_document; | 93 Member<Document> m_document; |
| 97 TaskRunnerTimer<TextTrackLoader> m_cueLoadTimer; | 94 TaskRunnerTimer<TextTrackLoader> m_cueLoadTimer; |
| 98 State m_state; | 95 State m_state; |
| 99 bool m_newCuesAvailable; | 96 bool m_newCuesAvailable; |
| 100 }; | 97 }; |
| 101 | 98 |
| 102 } // namespace blink | 99 } // namespace blink |
| 103 | 100 |
| 104 #endif | 101 #endif |
| OLD | NEW |