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

Side by Side Diff: Source/platform/mediastream/MediaStreamDescriptor.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, 2 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) 2011 Ericsson AB. All rights reserved. 2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. 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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 19 matching lines...) Expand all
30 */ 30 */
31 31
32 #include "config.h" 32 #include "config.h"
33 33
34 #include "platform/mediastream/MediaStreamDescriptor.h" 34 #include "platform/mediastream/MediaStreamDescriptor.h"
35 35
36 #include "platform/UUID.h" 36 #include "platform/UUID.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea mSourceVector& audioSources, const MediaStreamSourceVector& videoSources) 40 MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamSourceVect or& audioSources, const MediaStreamSourceVector& videoSources)
41 { 41 {
42 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audio Sources, videoSources)); 42 return new MediaStreamDescriptor(createCanonicalUUIDString(), audioSources, videoSources);
43 } 43 }
44 44
45 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea mComponentVector& audioComponents, const MediaStreamComponentVector& videoCompon ents) 45 MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamComponentV ector& audioComponents, const MediaStreamComponentVector& videoComponents)
46 { 46 {
47 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audio Components, videoComponents)); 47 return new MediaStreamDescriptor(createCanonicalUUIDString(), audioComponent s, videoComponents);
48 } 48 }
49 49
50 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const String& id , const MediaStreamComponentVector& audioComponents, const MediaStreamComponentV ector& videoComponents) 50 MediaStreamDescriptor* MediaStreamDescriptor::create(const String& id, const Med iaStreamComponentVector& audioComponents, const MediaStreamComponentVector& vide oComponents)
51 { 51 {
52 return adoptRef(new MediaStreamDescriptor(id, audioComponents, videoComponen ts)); 52 return new MediaStreamDescriptor(id, audioComponents, videoComponents);
53 } 53 }
54 54
55 void MediaStreamDescriptor::addComponent(PassRefPtr<MediaStreamComponent> compon ent) 55 void MediaStreamDescriptor::addComponent(MediaStreamComponent* component)
56 { 56 {
57 switch (component->source()->type()) { 57 switch (component->source()->type()) {
58 case MediaStreamSource::TypeAudio: 58 case MediaStreamSource::TypeAudio:
59 if (m_audioComponents.find(component) == kNotFound) 59 if (m_audioComponents.find(component) == kNotFound)
60 m_audioComponents.append(component); 60 m_audioComponents.append(component);
61 break; 61 break;
62 case MediaStreamSource::TypeVideo: 62 case MediaStreamSource::TypeVideo:
63 if (m_videoComponents.find(component) == kNotFound) 63 if (m_videoComponents.find(component) == kNotFound)
64 m_videoComponents.append(component); 64 m_videoComponents.append(component);
65 break; 65 break;
66 } 66 }
67 } 67 }
68 68
69 void MediaStreamDescriptor::removeComponent(PassRefPtr<MediaStreamComponent> com ponent) 69 void MediaStreamDescriptor::removeComponent(MediaStreamComponent* component)
70 { 70 {
71 size_t pos = kNotFound; 71 size_t pos = kNotFound;
72 switch (component->source()->type()) { 72 switch (component->source()->type()) {
73 case MediaStreamSource::TypeAudio: 73 case MediaStreamSource::TypeAudio:
74 pos = m_audioComponents.find(component); 74 pos = m_audioComponents.find(component);
75 if (pos != kNotFound) 75 if (pos != kNotFound)
76 m_audioComponents.remove(pos); 76 m_audioComponents.remove(pos);
77 break; 77 break;
78 case MediaStreamSource::TypeVideo: 78 case MediaStreamSource::TypeVideo:
79 pos = m_videoComponents.find(component); 79 pos = m_videoComponents.find(component);
(...skipping 13 matching lines...) Expand all
93 93
94 void MediaStreamDescriptor::removeRemoteTrack(MediaStreamComponent* component) 94 void MediaStreamDescriptor::removeRemoteTrack(MediaStreamComponent* component)
95 { 95 {
96 if (m_client) 96 if (m_client)
97 m_client->removeRemoteTrack(component); 97 m_client->removeRemoteTrack(component);
98 else 98 else
99 removeComponent(component); 99 removeComponent(component);
100 } 100 }
101 101
102 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream SourceVector& audioSources, const MediaStreamSourceVector& videoSources) 102 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream SourceVector& audioSources, const MediaStreamSourceVector& videoSources)
103 : m_client(0) 103 : m_client(nullptr)
104 , m_id(id) 104 , m_id(id)
105 , m_ended(false) 105 , m_ended(false)
106 { 106 {
107 ASSERT(m_id.length()); 107 ASSERT(m_id.length());
108 for (size_t i = 0; i < audioSources.size(); i++) 108 for (size_t i = 0; i < audioSources.size(); i++)
109 m_audioComponents.append(MediaStreamComponent::create(audioSources[i])); 109 m_audioComponents.append(MediaStreamComponent::create(audioSources[i]));
110 110
111 for (size_t i = 0; i < videoSources.size(); i++) 111 for (size_t i = 0; i < videoSources.size(); i++)
112 m_videoComponents.append(MediaStreamComponent::create(videoSources[i])); 112 m_videoComponents.append(MediaStreamComponent::create(videoSources[i]));
113 } 113 }
114 114
115 // The disposer pattern actually makes the deletion of the extra data happen
116 // earlier and not later. The disposer makes sure that the extra data is
117 // destructed in weak processing which is run before sweeping and therefore
118 // all the objects are still alive and can be touched.
119 //
120 // FIXME: Oilpan: This disposer pattern is duplicated in a lot of places.
121 // We should create a good abstraction class for this and remove the code duplic ation.
122 class MediaStreamDescriptorDisposer {
123 public:
124 explicit MediaStreamDescriptorDisposer(MediaStreamDescriptor& descriptor) : m_descriptor(descriptor) { }
125 ~MediaStreamDescriptorDisposer()
126 {
127 m_descriptor.dispose();
128 }
129
130 private:
131 MediaStreamDescriptor& m_descriptor;
132 };
133
134 typedef HeapHashMap<WeakMember<MediaStreamDescriptor>, OwnPtr<MediaStreamDescrip torDisposer> > DescriptorDisposers;
135
136 static DescriptorDisposers& descriptorDisposers()
137 {
138 DEFINE_STATIC_LOCAL(Persistent<DescriptorDisposers>, disposers, (new Descrip torDisposers));
139 return *disposers;
140 }
141
115 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream ComponentVector& audioComponents, const MediaStreamComponentVector& videoCompone nts) 142 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream ComponentVector& audioComponents, const MediaStreamComponentVector& videoCompone nts)
116 : m_client(0) 143 : m_client(nullptr)
117 , m_id(id) 144 , m_id(id)
118 , m_ended(false) 145 , m_ended(false)
119 { 146 {
120 ASSERT(m_id.length()); 147 ASSERT(m_id.length());
121 for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin (); iter != audioComponents.end(); ++iter) 148 for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin (); iter != audioComponents.end(); ++iter)
122 m_audioComponents.append((*iter)); 149 m_audioComponents.append((*iter));
123 for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin (); iter != videoComponents.end(); ++iter) 150 for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin (); iter != videoComponents.end(); ++iter)
124 m_videoComponents.append((*iter)); 151 m_videoComponents.append((*iter));
152 descriptorDisposers().add(this, adoptPtr(new MediaStreamDescriptorDisposer(* this)));
153 }
154
155 void MediaStreamDescriptor::dispose()
156 {
157 m_extraData = nullptr;
158 }
159
160 void MediaStreamDescriptor::trace(Visitor* visitor)
161 {
162 visitor->trace(m_audioComponents);
163 visitor->trace(m_videoComponents);
164 visitor->trace(m_client);
125 } 165 }
126 166
127 } // namespace blink 167 } // namespace blink
128 168
OLDNEW
« no previous file with comments | « Source/platform/mediastream/MediaStreamDescriptor.h ('k') | Source/platform/mediastream/MediaStreamSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698