OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 // fair amount of overhead and logging. | 115 // fair amount of overhead and logging. |
116 #define LOG_CACHED_TIME_WARNINGS 0 | 116 #define LOG_CACHED_TIME_WARNINGS 0 |
117 #endif | 117 #endif |
118 | 118 |
119 // URL protocol used to signal that the media source API is being used. | 119 // URL protocol used to signal that the media source API is being used. |
120 static const char mediaSourceBlobProtocol[] = "blob"; | 120 static const char mediaSourceBlobProtocol[] = "blob"; |
121 | 121 |
122 using namespace HTMLNames; | 122 using namespace HTMLNames; |
123 using namespace std; | 123 using namespace std; |
124 | 124 |
125 typedef HashMap<Document*, HashSet<HTMLMediaElement*> > DocumentElementSetMap; | 125 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Document>, WillBeHeapHashSet<Ra wPtrWillBeWeakMember<HTMLMediaElement> > > DocumentElementSetMap; |
126 static DocumentElementSetMap& documentToElementSetMap() | 126 static DocumentElementSetMap& documentToElementSetMap() |
127 { | 127 { |
128 #if ENABLE(OILPAN) | |
129 DEFINE_STATIC_LOCAL(Persistent<DocumentElementSetMap>, map, (new DocumentEle mentSetMap())); | |
130 return *map; | |
131 #else | |
128 DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ()); | 132 DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ()); |
129 return map; | 133 return map; |
134 #endif | |
130 } | 135 } |
131 | 136 |
132 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen t) | 137 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen t) |
133 { | 138 { |
134 DocumentElementSetMap& map = documentToElementSetMap(); | 139 DocumentElementSetMap& map = documentToElementSetMap(); |
135 HashSet<HTMLMediaElement*> set = map.take(document); | 140 WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > set = map.take( document); |
136 set.add(element); | 141 set.add(element); |
137 map.add(document, set); | 142 map.add(document, set); |
138 } | 143 } |
139 | 144 |
140 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do cument) | 145 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do cument) |
141 { | 146 { |
142 DocumentElementSetMap& map = documentToElementSetMap(); | 147 DocumentElementSetMap& map = documentToElementSetMap(); |
143 HashSet<HTMLMediaElement*> set = map.take(document); | 148 WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > set = map.take( document); |
144 set.remove(element); | 149 set.remove(element); |
145 if (!set.isEmpty()) | 150 if (!set.isEmpty()) |
146 map.add(document, set); | 151 map.add(document, set); |
147 } | 152 } |
148 | 153 |
149 class TrackDisplayUpdateScope { | 154 class TrackDisplayUpdateScope { |
150 public: | 155 public: |
151 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) | 156 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) |
152 { | 157 { |
153 m_mediaElement = mediaElement; | 158 m_mediaElement = mediaElement; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 m_textTracks->clearOwner(); | 316 m_textTracks->clearOwner(); |
312 #endif | 317 #endif |
313 | 318 |
314 if (m_mediaController) { | 319 if (m_mediaController) { |
315 m_mediaController->removeMediaElement(this); | 320 m_mediaController->removeMediaElement(this); |
316 m_mediaController = nullptr; | 321 m_mediaController = nullptr; |
317 } | 322 } |
318 | 323 |
319 closeMediaSource(); | 324 closeMediaSource(); |
320 | 325 |
326 #if !ENABLE(OILPAN) | |
321 removeElementFromDocumentMap(this, &document()); | 327 removeElementFromDocumentMap(this, &document()); |
328 #endif | |
322 | 329 |
323 // Destroying the player may cause a resource load to be canceled, | 330 // Destroying the player may cause a resource load to be canceled, |
324 // which could result in userCancelledLoad() being called back. | 331 // which could result in userCancelledLoad() being called back. |
325 // Setting m_completelyLoaded ensures that such a call will not cause | 332 // Setting m_completelyLoaded ensures that such a call will not cause |
326 // us to dispatch an abort event, which would result in a crash. | 333 // us to dispatch an abort event, which would result in a crash. |
327 // See http://crbug.com/233654 for more details. | 334 // See http://crbug.com/233654 for more details. |
328 m_completelyLoaded = true; | 335 m_completelyLoaded = true; |
329 | 336 |
337 // With Oilpan load events on the Document are always delayed during | |
Erik Corry
2014/04/25 09:23:48
Will this comment make sense once everything is Oi
Mads Ager (chromium)
2014/04/25 10:58:25
No, but it makes sense now and when we was to ship
| |
338 // sweeping so we don't need to explicitly increment and decrement | |
339 // load event delay counts. | |
340 #if !ENABLE(OILPAN) | |
330 // Destroying the player may cause a resource load to be canceled, | 341 // Destroying the player may cause a resource load to be canceled, |
331 // which could result in Document::dispatchWindowLoadEvent() being | 342 // which could result in Document::dispatchWindowLoadEvent() being |
332 // called via ResourceFetch::didLoadResource() then | 343 // called via ResourceFetch::didLoadResource() then |
333 // FrameLoader::loadDone(). To prevent load event dispatching during | 344 // FrameLoader::loadDone(). To prevent load event dispatching during |
334 // object destruction, we use Document::incrementLoadEventDelayCount(). | 345 // object destruction, we use Document::incrementLoadEventDelayCount(). |
335 // See http://crbug.com/275223 for more details. | 346 // See http://crbug.com/275223 for more details. |
336 document().incrementLoadEventDelayCount(); | 347 document().incrementLoadEventDelayCount(); |
348 #endif | |
337 | 349 |
338 clearMediaPlayerAndAudioSourceProviderClient(); | 350 clearMediaPlayerAndAudioSourceProviderClient(); |
339 | 351 |
352 #if !ENABLE(OILPAN) | |
340 document().decrementLoadEventDelayCount(); | 353 document().decrementLoadEventDelayCount(); |
354 #endif | |
341 } | 355 } |
342 | 356 |
343 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 357 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
344 { | 358 { |
345 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); | 359 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); |
346 | 360 |
347 if (m_shouldDelayLoadEvent) { | 361 if (m_shouldDelayLoadEvent) { |
348 document().incrementLoadEventDelayCount(); | 362 document().incrementLoadEventDelayCount(); |
349 // Note: Keeping the load event delay count increment on oldDocument tha t was added | 363 // Note: Keeping the load event delay count increment on oldDocument tha t was added |
350 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not | 364 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not |
(...skipping 3136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3487 // 1. Let m [this] be the media element in question. | 3501 // 1. Let m [this] be the media element in question. |
3488 // 2. Let m have no current media controller, if it currently has one. | 3502 // 2. Let m have no current media controller, if it currently has one. |
3489 setControllerInternal(nullptr); | 3503 setControllerInternal(nullptr); |
3490 | 3504 |
3491 // 3. If m's mediagroup attribute is being removed, then abort these steps. | 3505 // 3. If m's mediagroup attribute is being removed, then abort these steps. |
3492 if (group.isNull() || group.isEmpty()) | 3506 if (group.isNull() || group.isEmpty()) |
3493 return; | 3507 return; |
3494 | 3508 |
3495 // 4. If there is another media element whose Document is the same as m's Do cument (even if one or both | 3509 // 4. If there is another media element whose Document is the same as m's Do cument (even if one or both |
3496 // of these elements are not actually in the Document), | 3510 // of these elements are not actually in the Document), |
3497 HashSet<HTMLMediaElement*> elements = documentToElementSetMap().get(&documen t()); | 3511 WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > elements = docu mentToElementSetMap().get(&document()); |
Erik Corry
2014/04/25 09:23:48
This type gets used 5 times. Typedef?
Mads Ager (chromium)
2014/04/25 10:58:25
Done.
| |
3498 for (HashSet<HTMLMediaElement*>::iterator i = elements.begin(); i != element s.end(); ++i) { | 3512 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> >::iterator i = elements.begin(); i != elements.end(); ++i) { |
3499 if (*i == this) | 3513 if (*i == this) |
3500 continue; | 3514 continue; |
3501 | 3515 |
3502 // and which also has a mediagroup attribute, and whose mediagroup attri bute has the same value as | 3516 // and which also has a mediagroup attribute, and whose mediagroup attri bute has the same value as |
3503 // the new value of m's mediagroup attribute, | 3517 // the new value of m's mediagroup attribute, |
3504 if ((*i)->mediaGroup() == group) { | 3518 if ((*i)->mediaGroup() == group) { |
3505 // then let controller be that media element's current media contro ller. | 3519 // then let controller be that media element's current media contro ller. |
3506 setControllerInternal((*i)->controller()); | 3520 setControllerInternal((*i)->controller()); |
3507 return; | 3521 return; |
3508 } | 3522 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3649 | 3663 |
3650 void HTMLMediaElement::trace(Visitor* visitor) | 3664 void HTMLMediaElement::trace(Visitor* visitor) |
3651 { | 3665 { |
3652 visitor->trace(m_textTracks); | 3666 visitor->trace(m_textTracks); |
3653 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3667 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3654 Supplementable<HTMLMediaElement>::trace(visitor); | 3668 Supplementable<HTMLMediaElement>::trace(visitor); |
3655 HTMLElement::trace(visitor); | 3669 HTMLElement::trace(visitor); |
3656 } | 3670 } |
3657 | 3671 |
3658 } | 3672 } |
OLD | NEW |