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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp

Issue 1680563002: Improve MediaStreamTrack's hasPendingActivity predicate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Ericsson AB. All rights reserved. 3 * Copyright (C) 2011 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 m_isIteratingRegisteredMediaStreams = false; 205 m_isIteratingRegisteredMediaStreams = false;
206 } 206 }
207 207
208 void MediaStreamTrack::stop() 208 void MediaStreamTrack::stop()
209 { 209 {
210 m_stopped = true; 210 m_stopped = true;
211 } 211 }
212 212
213 bool MediaStreamTrack::hasPendingActivity() const 213 bool MediaStreamTrack::hasPendingActivity() const
214 { 214 {
215 return !m_stopped && hasEventListeners(); 215 // If 'ended' listeners exist and the object hasn't yet reached
216 // that state, keep the object alive.
217 //
218 // An otherwise unreachable MediaStreamTrack object in an non-ended
219 // state will otherwise indirectly be transitioned to the 'ended' state
220 // while finalizing m_component. Which dispatches an 'ended' event,
221 // referring to this object as the target. If this object is then GCed
222 // at the same time, v8 objects will retain (wrapper) references to
223 // this dead MediaStreamTrack object. Bad.
224 //
225 // Hence insisting on keeping this object alive until the 'ended'
226 // state has been reached & handled.
227 return !ended() && hasEventListeners(EventTypeNames::ended);
216 } 228 }
217 229
218 PassOwnPtr<AudioSourceProvider> MediaStreamTrack::createWebAudioSource() 230 PassOwnPtr<AudioSourceProvider> MediaStreamTrack::createWebAudioSource()
219 { 231 {
220 return MediaStreamCenter::instance().createWebAudioSourceFromMediaStreamTrac k(component()); 232 return MediaStreamCenter::instance().createWebAudioSourceFromMediaStreamTrac k(component());
221 } 233 }
222 234
223 void MediaStreamTrack::registerMediaStream(MediaStream* mediaStream) 235 void MediaStreamTrack::registerMediaStream(MediaStream* mediaStream)
224 { 236 {
225 RELEASE_ASSERT(!m_isIteratingRegisteredMediaStreams); 237 RELEASE_ASSERT(!m_isIteratingRegisteredMediaStreams);
(...skipping 21 matching lines...) Expand all
247 259
248 DEFINE_TRACE(MediaStreamTrack) 260 DEFINE_TRACE(MediaStreamTrack)
249 { 261 {
250 visitor->trace(m_registeredMediaStreams); 262 visitor->trace(m_registeredMediaStreams);
251 visitor->trace(m_component); 263 visitor->trace(m_component);
252 RefCountedGarbageCollectedEventTargetWithInlineData<MediaStreamTrack>::trace (visitor); 264 RefCountedGarbageCollectedEventTargetWithInlineData<MediaStreamTrack>::trace (visitor);
253 ActiveDOMObject::trace(visitor); 265 ActiveDOMObject::trace(visitor);
254 } 266 }
255 267
256 } // namespace blink 268 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698