| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/fetch/CrossOriginAccessControl.h" | 32 #include "core/fetch/CrossOriginAccessControl.h" |
| 33 #include "core/fetch/FetchRequest.h" | 33 #include "core/fetch/FetchRequest.h" |
| 34 #include "core/fetch/ResourceFetcher.h" | 34 #include "core/fetch/ResourceFetcher.h" |
| 35 #include "core/html/track/WebVTTParser.h" | 35 #include "core/html/track/WebVTTParser.h" |
| 36 #include "platform/Logging.h" | 36 #include "platform/Logging.h" |
| 37 #include "platform/SharedBuffer.h" | 37 #include "platform/SharedBuffer.h" |
| 38 #include "weborigin/SecurityOrigin.h" | 38 #include "weborigin/SecurityOrigin.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 TextTrackLoader::TextTrackLoader(TextTrackLoaderClient* client, Document& docume
nt) | 42 TextTrackLoader::TextTrackLoader(TextTrackLoaderClient& client, Document& docume
nt) |
| 43 : m_client(client) | 43 : m_client(client) |
| 44 , m_document(document) | 44 , m_document(document) |
| 45 , m_cueLoadTimer(this, &TextTrackLoader::cueLoadTimerFired) | 45 , m_cueLoadTimer(this, &TextTrackLoader::cueLoadTimerFired) |
| 46 , m_state(Idle) | 46 , m_state(Idle) |
| 47 , m_newCuesAvailable(false) | 47 , m_newCuesAvailable(false) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 TextTrackLoader::~TextTrackLoader() | 51 TextTrackLoader::~TextTrackLoader() |
| 52 { | 52 { |
| 53 if (m_resource) | 53 if (m_resource) |
| 54 m_resource->removeClient(this); | 54 m_resource->removeClient(this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void TextTrackLoader::cueLoadTimerFired(Timer<TextTrackLoader>* timer) | 57 void TextTrackLoader::cueLoadTimerFired(Timer<TextTrackLoader>* timer) |
| 58 { | 58 { |
| 59 ASSERT_UNUSED(timer, timer == &m_cueLoadTimer); | 59 ASSERT_UNUSED(timer, timer == &m_cueLoadTimer); |
| 60 | 60 |
| 61 if (m_newCuesAvailable) { | 61 if (m_newCuesAvailable) { |
| 62 m_newCuesAvailable = false; | 62 m_newCuesAvailable = false; |
| 63 m_client->newCuesAvailable(this); | 63 m_client.newCuesAvailable(this); |
| 64 } | 64 } |
| 65 | 65 |
| 66 if (m_state >= Finished) | 66 if (m_state >= Finished) |
| 67 m_client->cueLoadingCompleted(this, m_state == Failed); | 67 m_client.cueLoadingCompleted(this, m_state == Failed); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void TextTrackLoader::cancelLoad() | 70 void TextTrackLoader::cancelLoad() |
| 71 { | 71 { |
| 72 if (m_resource) { | 72 if (m_resource) { |
| 73 m_resource->removeClient(this); | 73 m_resource->removeClient(this); |
| 74 m_resource = 0; | 74 m_resource = 0; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (!m_cueLoadTimer.isActive()) | 112 if (!m_cueLoadTimer.isActive()) |
| 113 m_cueLoadTimer.startOneShot(0); | 113 m_cueLoadTimer.startOneShot(0); |
| 114 | 114 |
| 115 cancelLoad(); | 115 cancelLoad(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool TextTrackLoader::load(const KURL& url, const String& crossOriginMode) | 118 bool TextTrackLoader::load(const KURL& url, const String& crossOriginMode) |
| 119 { | 119 { |
| 120 cancelLoad(); | 120 cancelLoad(); |
| 121 | 121 |
| 122 if (!m_client->shouldLoadCues(this)) | 122 if (!m_client.shouldLoadCues(this)) |
| 123 return false; | 123 return false; |
| 124 | 124 |
| 125 FetchRequest cueRequest(ResourceRequest(m_document.completeURL(url)), FetchI
nitiatorTypeNames::texttrack); | 125 FetchRequest cueRequest(ResourceRequest(m_document.completeURL(url)), FetchI
nitiatorTypeNames::texttrack); |
| 126 | 126 |
| 127 if (!crossOriginMode.isNull()) { | 127 if (!crossOriginMode.isNull()) { |
| 128 m_crossOriginMode = crossOriginMode; | 128 m_crossOriginMode = crossOriginMode; |
| 129 StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode,
"use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials; | 129 StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode,
"use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials; |
| 130 updateRequestForAccessControl(cueRequest.mutableResourceRequest(), m_doc
ument.securityOrigin(), allowCredentials); | 130 updateRequestForAccessControl(cueRequest.mutableResourceRequest(), m_doc
ument.securityOrigin(), allowCredentials); |
| 131 } else { | 131 } else { |
| 132 // Cross-origin resources that are not suitably CORS-enabled may not loa
d. | 132 // Cross-origin resources that are not suitably CORS-enabled may not loa
d. |
| 133 if (!m_document.securityOrigin()->canRequest(url)) { | 133 if (!m_document.securityOrigin()->canRequest(url)) { |
| 134 corsPolicyPreventedLoad(); | 134 corsPolicyPreventedLoad(); |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 ResourceFetcher* fetcher = m_document.fetcher(); | 139 ResourceFetcher* fetcher = m_document.fetcher(); |
| 140 m_resource = fetcher->fetchRawResource(cueRequest); | 140 m_resource = fetcher->fetchRawResource(cueRequest); |
| 141 if (m_resource) | 141 if (m_resource) |
| 142 m_resource->addClient(this); | 142 m_resource->addClient(this); |
| 143 | 143 |
| 144 m_client->cueLoadingStarted(this); | 144 m_client.cueLoadingStarted(this); |
| 145 | 145 |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void TextTrackLoader::newCuesParsed() | 149 void TextTrackLoader::newCuesParsed() |
| 150 { | 150 { |
| 151 if (m_cueLoadTimer.isActive()) | 151 if (m_cueLoadTimer.isActive()) |
| 152 return; | 152 return; |
| 153 | 153 |
| 154 m_newCuesAvailable = true; | 154 m_newCuesAvailable = true; |
| 155 m_cueLoadTimer.startOneShot(0); | 155 m_cueLoadTimer.startOneShot(0); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void TextTrackLoader::newRegionsParsed() | 158 void TextTrackLoader::newRegionsParsed() |
| 159 { | 159 { |
| 160 m_client->newRegionsAvailable(this); | 160 m_client.newRegionsAvailable(this); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void TextTrackLoader::fileFailedToParse() | 163 void TextTrackLoader::fileFailedToParse() |
| 164 { | 164 { |
| 165 LOG(Media, "TextTrackLoader::fileFailedToParse"); | 165 LOG(Media, "TextTrackLoader::fileFailedToParse"); |
| 166 | 166 |
| 167 m_state = Failed; | 167 m_state = Failed; |
| 168 | 168 |
| 169 if (!m_cueLoadTimer.isActive()) | 169 if (!m_cueLoadTimer.isActive()) |
| 170 m_cueLoadTimer.startOneShot(0); | 170 m_cueLoadTimer.startOneShot(0); |
| 171 | 171 |
| 172 cancelLoad(); | 172 cancelLoad(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void TextTrackLoader::getNewCues(Vector<RefPtr<TextTrackCue> >& outputCues) | 175 void TextTrackLoader::getNewCues(Vector<RefPtr<TextTrackCue> >& outputCues) |
| 176 { | 176 { |
| 177 ASSERT(m_cueParser); | 177 ASSERT(m_cueParser); |
| 178 if (m_cueParser) | 178 if (m_cueParser) |
| 179 m_cueParser->getNewCues(outputCues); | 179 m_cueParser->getNewCues(outputCues); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TextTrackLoader::getNewRegions(Vector<RefPtr<TextTrackRegion> >& outputRegi
ons) | 182 void TextTrackLoader::getNewRegions(Vector<RefPtr<TextTrackRegion> >& outputRegi
ons) |
| 183 { | 183 { |
| 184 ASSERT(m_cueParser); | 184 ASSERT(m_cueParser); |
| 185 if (m_cueParser) | 185 if (m_cueParser) |
| 186 m_cueParser->getNewRegions(outputRegions); | 186 m_cueParser->getNewRegions(outputRegions); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| OLD | NEW |