| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 | 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 , m_newCuesAvailable(false) | 44 , m_newCuesAvailable(false) |
| 45 { | 45 { |
| 46 } | 46 } |
| 47 | 47 |
| 48 TextTrackLoader::~TextTrackLoader() | 48 TextTrackLoader::~TextTrackLoader() |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 | 51 |
| 52 void TextTrackLoader::cueLoadTimerFired(TimerBase* timer) | 52 void TextTrackLoader::cueLoadTimerFired(TimerBase* timer) |
| 53 { | 53 { |
| 54 ASSERT_UNUSED(timer, timer == &m_cueLoadTimer); | 54 DCHECK_EQ(timer, &m_cueLoadTimer); |
| 55 | 55 |
| 56 if (m_newCuesAvailable) { | 56 if (m_newCuesAvailable) { |
| 57 m_newCuesAvailable = false; | 57 m_newCuesAvailable = false; |
| 58 m_client->newCuesAvailable(this); | 58 m_client->newCuesAvailable(this); |
| 59 } | 59 } |
| 60 | 60 |
| 61 if (m_state >= Finished) | 61 if (m_state >= Finished) |
| 62 m_client->cueLoadingCompleted(this, m_state == Failed); | 62 m_client->cueLoadingCompleted(this, m_state == Failed); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void TextTrackLoader::cancelLoad() | 65 void TextTrackLoader::cancelLoad() |
| 66 { | 66 { |
| 67 clearResource(); | 67 clearResource(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void TextTrackLoader::dataReceived(Resource* resource, const char* data, size_t
length) | 70 void TextTrackLoader::dataReceived(Resource* resource, const char* data, size_t
length) |
| 71 { | 71 { |
| 72 ASSERT(this->resource() == resource); | 72 DCHECK_EQ(this->resource(), resource); |
| 73 | 73 |
| 74 if (m_state == Failed) | 74 if (m_state == Failed) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 if (!m_cueParser) | 77 if (!m_cueParser) |
| 78 m_cueParser = VTTParser::create(this, document()); | 78 m_cueParser = VTTParser::create(this, document()); |
| 79 | 79 |
| 80 m_cueParser->parseBytes(data, length); | 80 m_cueParser->parseBytes(data, length); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void TextTrackLoader::corsPolicyPreventedLoad(SecurityOrigin* securityOrigin, co
nst KURL& url) | 83 void TextTrackLoader::corsPolicyPreventedLoad(SecurityOrigin* securityOrigin, co
nst KURL& url) |
| 84 { | 84 { |
| 85 String consoleMessage("Text track from origin '" + SecurityOrigin::create(ur
l)->toString() + "' has been blocked from loading: Not at same origin as the doc
ument, and parent of track element does not have a 'crossorigin' attribute. Orig
in '" + securityOrigin->toString() + "' is therefore not allowed access."); | 85 String consoleMessage("Text track from origin '" + SecurityOrigin::create(ur
l)->toString() + "' has been blocked from loading: Not at same origin as the doc
ument, and parent of track element does not have a 'crossorigin' attribute. Orig
in '" + securityOrigin->toString() + "' is therefore not allowed access."); |
| 86 document().addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, E
rrorMessageLevel, consoleMessage)); | 86 document().addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, E
rrorMessageLevel, consoleMessage)); |
| 87 m_state = Failed; | 87 m_state = Failed; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void TextTrackLoader::notifyFinished(Resource* resource) | 90 void TextTrackLoader::notifyFinished(Resource* resource) |
| 91 { | 91 { |
| 92 ASSERT(this->resource() == resource); | 92 DCHECK_EQ(this->resource(), resource); |
| 93 if (m_state != Failed) | 93 if (m_state != Failed) |
| 94 m_state = resource->errorOccurred() ? Failed : Finished; | 94 m_state = resource->errorOccurred() ? Failed : Finished; |
| 95 | 95 |
| 96 if (m_state == Finished && m_cueParser) | 96 if (m_state == Finished && m_cueParser) |
| 97 m_cueParser->flush(); | 97 m_cueParser->flush(); |
| 98 | 98 |
| 99 if (!m_cueLoadTimer.isActive()) | 99 if (!m_cueLoadTimer.isActive()) |
| 100 m_cueLoadTimer.startOneShot(0, BLINK_FROM_HERE); | 100 m_cueLoadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 101 | 101 |
| 102 cancelLoad(); | 102 cancelLoad(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 m_state = Failed; | 140 m_state = Failed; |
| 141 | 141 |
| 142 if (!m_cueLoadTimer.isActive()) | 142 if (!m_cueLoadTimer.isActive()) |
| 143 m_cueLoadTimer.startOneShot(0, BLINK_FROM_HERE); | 143 m_cueLoadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 144 | 144 |
| 145 cancelLoad(); | 145 cancelLoad(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void TextTrackLoader::getNewCues(HeapVector<Member<TextTrackCue>>& outputCues) | 148 void TextTrackLoader::getNewCues(HeapVector<Member<TextTrackCue>>& outputCues) |
| 149 { | 149 { |
| 150 ASSERT(m_cueParser); | 150 DCHECK(m_cueParser); |
| 151 if (m_cueParser) | 151 if (m_cueParser) |
| 152 m_cueParser->getNewCues(outputCues); | 152 m_cueParser->getNewCues(outputCues); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void TextTrackLoader::getNewRegions(HeapVector<Member<VTTRegion>>& outputRegions
) | 155 void TextTrackLoader::getNewRegions(HeapVector<Member<VTTRegion>>& outputRegions
) |
| 156 { | 156 { |
| 157 ASSERT(m_cueParser); | 157 DCHECK(m_cueParser); |
| 158 if (m_cueParser) | 158 if (m_cueParser) |
| 159 m_cueParser->getNewRegions(outputRegions); | 159 m_cueParser->getNewRegions(outputRegions); |
| 160 } | 160 } |
| 161 | 161 |
| 162 DEFINE_TRACE(TextTrackLoader) | 162 DEFINE_TRACE(TextTrackLoader) |
| 163 { | 163 { |
| 164 visitor->trace(m_client); | 164 visitor->trace(m_client); |
| 165 visitor->trace(m_cueParser); | 165 visitor->trace(m_cueParser); |
| 166 visitor->trace(m_document); | 166 visitor->trace(m_document); |
| 167 ResourceOwner<RawResource>::trace(visitor); | 167 ResourceOwner<RawResource>::trace(visitor); |
| 168 VTTParserClient::trace(visitor); | 168 VTTParserClient::trace(visitor); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace blink | 171 } // namespace blink |
| OLD | NEW |