Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1617)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 235113002: Oilpan: Remove guardRef and guardDeref from TreeScope. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Only perform weak processing of the event handler registry if the document is active. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > WeakMediaEl ementSet;
126 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Document>, WeakMediaElementSet> DocumentElementSetMap;
126 static DocumentElementSetMap& documentToElementSetMap() 127 static DocumentElementSetMap& documentToElementSetMap()
127 { 128 {
129 #if ENABLE(OILPAN)
130 DEFINE_STATIC_LOCAL(Persistent<DocumentElementSetMap>, map, (new DocumentEle mentSetMap()));
131 return *map;
132 #else
128 DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ()); 133 DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ());
129 return map; 134 return map;
135 #endif
haraken 2014/04/25 14:30:32 Nit: We've been using #if for this pattern in a lo
Mads Ager (chromium) 2014/04/28 09:45:21 Yes, we should see what we can do with these. The
130 } 136 }
131 137
132 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen t) 138 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen t)
133 { 139 {
134 DocumentElementSetMap& map = documentToElementSetMap(); 140 DocumentElementSetMap& map = documentToElementSetMap();
135 HashSet<HTMLMediaElement*> set = map.take(document); 141 WeakMediaElementSet set = map.take(document);
136 set.add(element); 142 set.add(element);
137 map.add(document, set); 143 map.add(document, set);
138 } 144 }
139 145
140 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do cument) 146 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do cument)
141 { 147 {
142 DocumentElementSetMap& map = documentToElementSetMap(); 148 DocumentElementSetMap& map = documentToElementSetMap();
143 HashSet<HTMLMediaElement*> set = map.take(document); 149 WeakMediaElementSet set = map.take(document);
144 set.remove(element); 150 set.remove(element);
145 if (!set.isEmpty()) 151 if (!set.isEmpty())
146 map.add(document, set); 152 map.add(document, set);
147 } 153 }
148 154
149 class TrackDisplayUpdateScope { 155 class TrackDisplayUpdateScope {
150 public: 156 public:
151 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) 157 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement)
152 { 158 {
153 m_mediaElement = mediaElement; 159 m_mediaElement = mediaElement;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 m_textTracks->clearOwner(); 317 m_textTracks->clearOwner();
312 #endif 318 #endif
313 319
314 if (m_mediaController) { 320 if (m_mediaController) {
315 m_mediaController->removeMediaElement(this); 321 m_mediaController->removeMediaElement(this);
316 m_mediaController = nullptr; 322 m_mediaController = nullptr;
317 } 323 }
318 324
319 closeMediaSource(); 325 closeMediaSource();
320 326
327 #if !ENABLE(OILPAN)
321 removeElementFromDocumentMap(this, &document()); 328 removeElementFromDocumentMap(this, &document());
329 #endif
322 330
323 // Destroying the player may cause a resource load to be canceled, 331 // Destroying the player may cause a resource load to be canceled,
324 // which could result in userCancelledLoad() being called back. 332 // which could result in userCancelledLoad() being called back.
325 // Setting m_completelyLoaded ensures that such a call will not cause 333 // Setting m_completelyLoaded ensures that such a call will not cause
326 // us to dispatch an abort event, which would result in a crash. 334 // us to dispatch an abort event, which would result in a crash.
327 // See http://crbug.com/233654 for more details. 335 // See http://crbug.com/233654 for more details.
328 m_completelyLoaded = true; 336 m_completelyLoaded = true;
329 337
338 // With Oilpan load events on the Document are always delayed during
339 // sweeping so we don't need to explicitly increment and decrement
340 // load event delay counts.
341 #if !ENABLE(OILPAN)
330 // Destroying the player may cause a resource load to be canceled, 342 // Destroying the player may cause a resource load to be canceled,
331 // which could result in Document::dispatchWindowLoadEvent() being 343 // which could result in Document::dispatchWindowLoadEvent() being
332 // called via ResourceFetch::didLoadResource() then 344 // called via ResourceFetch::didLoadResource() then
333 // FrameLoader::loadDone(). To prevent load event dispatching during 345 // FrameLoader::loadDone(). To prevent load event dispatching during
334 // object destruction, we use Document::incrementLoadEventDelayCount(). 346 // object destruction, we use Document::incrementLoadEventDelayCount().
335 // See http://crbug.com/275223 for more details. 347 // See http://crbug.com/275223 for more details.
336 document().incrementLoadEventDelayCount(); 348 document().incrementLoadEventDelayCount();
349 #endif
337 350
338 clearMediaPlayerAndAudioSourceProviderClient(); 351 clearMediaPlayerAndAudioSourceProviderClient();
339 352
353 #if !ENABLE(OILPAN)
340 document().decrementLoadEventDelayCount(); 354 document().decrementLoadEventDelayCount();
355 #endif
341 } 356 }
342 357
343 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) 358 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
344 { 359 {
345 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); 360 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument");
346 361
347 if (m_shouldDelayLoadEvent) { 362 if (m_shouldDelayLoadEvent) {
348 document().incrementLoadEventDelayCount(); 363 document().incrementLoadEventDelayCount();
349 // Note: Keeping the load event delay count increment on oldDocument tha t was added 364 // 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 365 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not
(...skipping 3120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3471 // 1. Let m [this] be the media element in question. 3486 // 1. Let m [this] be the media element in question.
3472 // 2. Let m have no current media controller, if it currently has one. 3487 // 2. Let m have no current media controller, if it currently has one.
3473 setControllerInternal(nullptr); 3488 setControllerInternal(nullptr);
3474 3489
3475 // 3. If m's mediagroup attribute is being removed, then abort these steps. 3490 // 3. If m's mediagroup attribute is being removed, then abort these steps.
3476 if (group.isNull() || group.isEmpty()) 3491 if (group.isNull() || group.isEmpty())
3477 return; 3492 return;
3478 3493
3479 // 4. If there is another media element whose Document is the same as m's Do cument (even if one or both 3494 // 4. If there is another media element whose Document is the same as m's Do cument (even if one or both
3480 // of these elements are not actually in the Document), 3495 // of these elements are not actually in the Document),
3481 HashSet<HTMLMediaElement*> elements = documentToElementSetMap().get(&documen t()); 3496 WeakMediaElementSet elements = documentToElementSetMap().get(&document());
3482 for (HashSet<HTMLMediaElement*>::iterator i = elements.begin(); i != element s.end(); ++i) { 3497 for (WeakMediaElementSet::iterator i = elements.begin(); i != elements.end() ; ++i) {
3483 if (*i == this) 3498 if (*i == this)
3484 continue; 3499 continue;
3485 3500
3486 // and which also has a mediagroup attribute, and whose mediagroup attri bute has the same value as 3501 // and which also has a mediagroup attribute, and whose mediagroup attri bute has the same value as
3487 // the new value of m's mediagroup attribute, 3502 // the new value of m's mediagroup attribute,
3488 if ((*i)->mediaGroup() == group) { 3503 if ((*i)->mediaGroup() == group) {
3489 // then let controller be that media element's current media contro ller. 3504 // then let controller be that media element's current media contro ller.
3490 setControllerInternal((*i)->controller()); 3505 setControllerInternal((*i)->controller());
3491 return; 3506 return;
3492 } 3507 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3633 3648
3634 void HTMLMediaElement::trace(Visitor* visitor) 3649 void HTMLMediaElement::trace(Visitor* visitor)
3635 { 3650 {
3636 visitor->trace(m_textTracks); 3651 visitor->trace(m_textTracks);
3637 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3652 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3638 Supplementable<HTMLMediaElement>::trace(visitor); 3653 Supplementable<HTMLMediaElement>::trace(visitor);
3639 HTMLElement::trace(visitor); 3654 HTMLElement::trace(visitor);
3640 } 3655 }
3641 3656
3642 } 3657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698