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

Unified Diff: Source/platform/mediastream/MediaStreamComponent.cpp

Issue 552653005: Oilpan: Move MediaStreamSource, MediaStreamComponent and MediaStreamDescriptor to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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/platform/mediastream/MediaStreamComponent.cpp
diff --git a/Source/platform/mediastream/MediaStreamComponent.cpp b/Source/platform/mediastream/MediaStreamComponent.cpp
index 43bc57d0c4d4148621eedb36f73676f052e7c74a..31fa69830641c459fc429f3550ef26a73709b87e 100644
--- a/Source/platform/mediastream/MediaStreamComponent.cpp
+++ b/Source/platform/mediastream/MediaStreamComponent.cpp
@@ -40,23 +40,56 @@
namespace blink {
-PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(PassRefPtr<MediaStreamSource> source)
+MediaStreamComponent* MediaStreamComponent::create(MediaStreamSource* source)
{
- return adoptRef(new MediaStreamComponent(createCanonicalUUIDString(), source));
+ return new MediaStreamComponent(createCanonicalUUIDString(), source);
}
-PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(const String& id, PassRefPtr<MediaStreamSource> source)
+MediaStreamComponent* MediaStreamComponent::create(const String& id, MediaStreamSource* source)
{
- return adoptRef(new MediaStreamComponent(id, source));
+ return new MediaStreamComponent(id, source);
}
-MediaStreamComponent::MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource> source)
+// The disposer pattern actually makes the deletion of the extra data happen
+// earlier and not later. The disposer makes sure that the extra data is
+// destructed in weak processing which is run before sweeping and therefore
+// all the objects are still alive and can be touched.
+//
+// FIXME: Oilpan: This disposer pattern is duplicated in a lot of places.
+// We should create a good abstraction class for this and remove the code duplication.
+class MediaStreamComponentDisposer {
+public:
+ explicit MediaStreamComponentDisposer(MediaStreamComponent& component) : m_component(component) { }
+ ~MediaStreamComponentDisposer()
+ {
+ m_component.dispose();
+ }
+
+private:
+ MediaStreamComponent& m_component;
+};
+
+typedef HeapHashMap<WeakMember<MediaStreamComponent>, OwnPtr<MediaStreamComponentDisposer> > ComponentDisposers;
+
+static ComponentDisposers& componentDisposers()
+{
+ DEFINE_STATIC_LOCAL(Persistent<ComponentDisposers>, disposers, (new ComponentDisposers));
+ return *disposers;
+}
+
+MediaStreamComponent::MediaStreamComponent(const String& id, MediaStreamSource* source)
: m_source(source)
, m_id(id)
, m_enabled(true)
, m_muted(false)
{
ASSERT(m_id.length());
+ componentDisposers().add(this, adoptPtr(new MediaStreamComponentDisposer(*this)));
+}
+
+void MediaStreamComponent::dispose()
+{
+ m_extraData = nullptr;
}
#if ENABLE(WEB_AUDIO)
@@ -88,5 +121,10 @@ void MediaStreamComponent::AudioSourceProviderImpl::provideInput(AudioBus* bus,
}
#endif // #if ENABLE(WEB_AUDIO)
+void MediaStreamComponent::trace(Visitor* visitor)
+{
+ visitor->trace(m_source);
+}
+
} // namespace blink
« no previous file with comments | « Source/platform/mediastream/MediaStreamComponent.h ('k') | Source/platform/mediastream/MediaStreamDescriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698