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

Unified 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: Address comments. 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 8904ce96bc1c6f41ebd7605b24ee1295a1d70ffa..ce3fd89b58e880b56d5adb0c4ccc44d3193b835b 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -122,17 +122,22 @@ static const char mediaSourceBlobProtocol[] = "blob";
using namespace HTMLNames;
using namespace std;
-typedef HashMap<Document*, HashSet<HTMLMediaElement*> > DocumentElementSetMap;
+typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Document>, WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > > DocumentElementSetMap;
static DocumentElementSetMap& documentToElementSetMap()
{
+#if ENABLE(OILPAN)
+ DEFINE_STATIC_LOCAL(Persistent<DocumentElementSetMap>, map, (new DocumentElementSetMap()));
+ return *map;
+#else
DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ());
return map;
+#endif
}
static void addElementToDocumentMap(HTMLMediaElement* element, Document* document)
{
DocumentElementSetMap& map = documentToElementSetMap();
- HashSet<HTMLMediaElement*> set = map.take(document);
+ WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > set = map.take(document);
set.add(element);
map.add(document, set);
}
@@ -140,7 +145,7 @@ static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen
static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* document)
{
DocumentElementSetMap& map = documentToElementSetMap();
- HashSet<HTMLMediaElement*> set = map.take(document);
+ WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > set = map.take(document);
set.remove(element);
if (!set.isEmpty())
map.add(document, set);
@@ -318,7 +323,9 @@ HTMLMediaElement::~HTMLMediaElement()
closeMediaSource();
+#if !ENABLE(OILPAN)
removeElementFromDocumentMap(this, &document());
+#endif
// Destroying the player may cause a resource load to be canceled,
// which could result in userCancelledLoad() being called back.
@@ -327,6 +334,10 @@ HTMLMediaElement::~HTMLMediaElement()
// See http://crbug.com/233654 for more details.
m_completelyLoaded = true;
+ // 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
+ // sweeping so we don't need to explicitly increment and decrement
+ // load event delay counts.
+#if !ENABLE(OILPAN)
// Destroying the player may cause a resource load to be canceled,
// which could result in Document::dispatchWindowLoadEvent() being
// called via ResourceFetch::didLoadResource() then
@@ -334,10 +345,13 @@ HTMLMediaElement::~HTMLMediaElement()
// object destruction, we use Document::incrementLoadEventDelayCount().
// See http://crbug.com/275223 for more details.
document().incrementLoadEventDelayCount();
+#endif
clearMediaPlayerAndAudioSourceProviderClient();
+#if !ENABLE(OILPAN)
document().decrementLoadEventDelayCount();
+#endif
}
void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
@@ -3494,8 +3508,8 @@ void HTMLMediaElement::setMediaGroup(const AtomicString& group)
// 4. If there is another media element whose Document is the same as m's Document (even if one or both
// of these elements are not actually in the Document),
- HashSet<HTMLMediaElement*> elements = documentToElementSetMap().get(&document());
- for (HashSet<HTMLMediaElement*>::iterator i = elements.begin(); i != elements.end(); ++i) {
+ WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > elements = documentToElementSetMap().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.
+ for (WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> >::iterator i = elements.begin(); i != elements.end(); ++i) {
if (*i == this)
continue;

Powered by Google App Engine
This is Rietveld 408576698