| Index: trunk/Source/platform/mediastream/MediaStreamDescriptor.cpp
|
| ===================================================================
|
| --- trunk/Source/platform/mediastream/MediaStreamDescriptor.cpp (revision 183662)
|
| +++ trunk/Source/platform/mediastream/MediaStreamDescriptor.cpp (working copy)
|
| @@ -37,22 +37,22 @@
|
|
|
| namespace blink {
|
|
|
| -MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
|
| +PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
|
| {
|
| - return new MediaStreamDescriptor(createCanonicalUUIDString(), audioSources, videoSources);
|
| + return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audioSources, videoSources));
|
| }
|
|
|
| -MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents)
|
| +PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents)
|
| {
|
| - return new MediaStreamDescriptor(createCanonicalUUIDString(), audioComponents, videoComponents);
|
| + return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audioComponents, videoComponents));
|
| }
|
|
|
| -MediaStreamDescriptor* MediaStreamDescriptor::create(const String& id, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents)
|
| +PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const String& id, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents)
|
| {
|
| - return new MediaStreamDescriptor(id, audioComponents, videoComponents);
|
| + return adoptRef(new MediaStreamDescriptor(id, audioComponents, videoComponents));
|
| }
|
|
|
| -void MediaStreamDescriptor::addComponent(MediaStreamComponent* component)
|
| +void MediaStreamDescriptor::addComponent(PassRefPtr<MediaStreamComponent> component)
|
| {
|
| switch (component->source()->type()) {
|
| case MediaStreamSource::TypeAudio:
|
| @@ -66,7 +66,7 @@
|
| }
|
| }
|
|
|
| -void MediaStreamDescriptor::removeComponent(MediaStreamComponent* component)
|
| +void MediaStreamDescriptor::removeComponent(PassRefPtr<MediaStreamComponent> component)
|
| {
|
| size_t pos = kNotFound;
|
| switch (component->source()->type()) {
|
| @@ -100,7 +100,7 @@
|
| }
|
|
|
| MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
|
| - : m_client(nullptr)
|
| + : m_client(0)
|
| , m_id(id)
|
| , m_ended(false)
|
| {
|
| @@ -112,35 +112,8 @@
|
| m_videoComponents.append(MediaStreamComponent::create(videoSources[i]));
|
| }
|
|
|
| -// 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 MediaStreamDescriptorDisposer {
|
| -public:
|
| - explicit MediaStreamDescriptorDisposer(MediaStreamDescriptor& descriptor) : m_descriptor(descriptor) { }
|
| - ~MediaStreamDescriptorDisposer()
|
| - {
|
| - m_descriptor.dispose();
|
| - }
|
| -
|
| -private:
|
| - MediaStreamDescriptor& m_descriptor;
|
| -};
|
| -
|
| -typedef HeapHashMap<WeakMember<MediaStreamDescriptor>, OwnPtr<MediaStreamDescriptorDisposer> > DescriptorDisposers;
|
| -
|
| -static DescriptorDisposers& descriptorDisposers()
|
| -{
|
| - DEFINE_STATIC_LOCAL(Persistent<DescriptorDisposers>, disposers, (new DescriptorDisposers));
|
| - return *disposers;
|
| -}
|
| -
|
| MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents)
|
| - : m_client(nullptr)
|
| + : m_client(0)
|
| , m_id(id)
|
| , m_ended(false)
|
| {
|
| @@ -149,20 +122,7 @@
|
| m_audioComponents.append((*iter));
|
| for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin(); iter != videoComponents.end(); ++iter)
|
| m_videoComponents.append((*iter));
|
| - descriptorDisposers().add(this, adoptPtr(new MediaStreamDescriptorDisposer(*this)));
|
| }
|
|
|
| -void MediaStreamDescriptor::dispose()
|
| -{
|
| - m_extraData = nullptr;
|
| -}
|
| -
|
| -void MediaStreamDescriptor::trace(Visitor* visitor)
|
| -{
|
| - visitor->trace(m_audioComponents);
|
| - visitor->trace(m_videoComponents);
|
| - visitor->trace(m_client);
|
| -}
|
| -
|
| } // namespace blink
|
|
|
|
|