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

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

Issue 2633273002: Move MediaStream m_scheduledEventTimer to TaskRunnerTimer (Closed)
Patch Set: Review feedback Created 3 years, 11 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 | « third_party/WebKit/Source/modules/mediastream/MediaStream.h ('k') | 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, 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2011, 2012 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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR 17 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "modules/mediastream/MediaStream.h" 26 #include "modules/mediastream/MediaStream.h"
27 27
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "core/dom/ExceptionCode.h" 29 #include "core/dom/ExceptionCode.h"
30 #include "core/dom/TaskRunnerHelper.h"
30 #include "core/frame/Deprecation.h" 31 #include "core/frame/Deprecation.h"
31 #include "modules/mediastream/MediaStreamRegistry.h" 32 #include "modules/mediastream/MediaStreamRegistry.h"
32 #include "modules/mediastream/MediaStreamTrackEvent.h" 33 #include "modules/mediastream/MediaStreamTrackEvent.h"
33 #include "platform/mediastream/MediaStreamCenter.h" 34 #include "platform/mediastream/MediaStreamCenter.h"
34 #include "platform/mediastream/MediaStreamSource.h" 35 #include "platform/mediastream/MediaStreamSource.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 static bool containsSource(MediaStreamTrackVector& trackVector, 39 static bool containsSource(MediaStreamTrackVector& trackVector,
39 MediaStreamSource* source) { 40 MediaStreamSource* source) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 92
92 MediaStream* MediaStream::create(ExecutionContext* context, 93 MediaStream* MediaStream::create(ExecutionContext* context,
93 MediaStreamDescriptor* streamDescriptor) { 94 MediaStreamDescriptor* streamDescriptor) {
94 return new MediaStream(context, streamDescriptor); 95 return new MediaStream(context, streamDescriptor);
95 } 96 }
96 97
97 MediaStream::MediaStream(ExecutionContext* context, 98 MediaStream::MediaStream(ExecutionContext* context,
98 MediaStreamDescriptor* streamDescriptor) 99 MediaStreamDescriptor* streamDescriptor)
99 : ContextClient(context), 100 : ContextClient(context),
100 m_descriptor(streamDescriptor), 101 m_descriptor(streamDescriptor),
101 m_scheduledEventTimer(this, &MediaStream::scheduledEventTimerFired) { 102 m_scheduledEventTimer(
103 TaskRunnerHelper::get(TaskType::MediaElementEvent, context),
104 this,
105 &MediaStream::scheduledEventTimerFired) {
102 m_descriptor->setClient(this); 106 m_descriptor->setClient(this);
103 107
104 size_t numberOfAudioTracks = m_descriptor->numberOfAudioComponents(); 108 size_t numberOfAudioTracks = m_descriptor->numberOfAudioComponents();
105 m_audioTracks.reserveCapacity(numberOfAudioTracks); 109 m_audioTracks.reserveCapacity(numberOfAudioTracks);
106 for (size_t i = 0; i < numberOfAudioTracks; i++) { 110 for (size_t i = 0; i < numberOfAudioTracks; i++) {
107 MediaStreamTrack* newTrack = 111 MediaStreamTrack* newTrack =
108 MediaStreamTrack::create(context, m_descriptor->audioComponent(i)); 112 MediaStreamTrack::create(context, m_descriptor->audioComponent(i));
109 newTrack->registerMediaStream(this); 113 newTrack->registerMediaStream(this);
110 m_audioTracks.push_back(newTrack); 114 m_audioTracks.push_back(newTrack);
111 } 115 }
112 116
113 size_t numberOfVideoTracks = m_descriptor->numberOfVideoComponents(); 117 size_t numberOfVideoTracks = m_descriptor->numberOfVideoComponents();
114 m_videoTracks.reserveCapacity(numberOfVideoTracks); 118 m_videoTracks.reserveCapacity(numberOfVideoTracks);
115 for (size_t i = 0; i < numberOfVideoTracks; i++) { 119 for (size_t i = 0; i < numberOfVideoTracks; i++) {
116 MediaStreamTrack* newTrack = 120 MediaStreamTrack* newTrack =
117 MediaStreamTrack::create(context, m_descriptor->videoComponent(i)); 121 MediaStreamTrack::create(context, m_descriptor->videoComponent(i));
118 newTrack->registerMediaStream(this); 122 newTrack->registerMediaStream(this);
119 m_videoTracks.push_back(newTrack); 123 m_videoTracks.push_back(newTrack);
120 } 124 }
121 125
122 if (emptyOrOnlyEndedTracks()) { 126 if (emptyOrOnlyEndedTracks()) {
123 m_descriptor->setActive(false); 127 m_descriptor->setActive(false);
124 } 128 }
125 } 129 }
126 130
127 MediaStream::MediaStream(ExecutionContext* context, 131 MediaStream::MediaStream(ExecutionContext* context,
128 const MediaStreamTrackVector& audioTracks, 132 const MediaStreamTrackVector& audioTracks,
129 const MediaStreamTrackVector& videoTracks) 133 const MediaStreamTrackVector& videoTracks)
130 : ContextClient(context), 134 : ContextClient(context),
131 m_scheduledEventTimer(this, &MediaStream::scheduledEventTimerFired) { 135 m_scheduledEventTimer(
136 TaskRunnerHelper::get(TaskType::MediaElementEvent, context),
137 this,
138 &MediaStream::scheduledEventTimerFired) {
132 MediaStreamComponentVector audioComponents; 139 MediaStreamComponentVector audioComponents;
133 MediaStreamComponentVector videoComponents; 140 MediaStreamComponentVector videoComponents;
134 141
135 MediaStreamTrackVector::const_iterator iter; 142 MediaStreamTrackVector::const_iterator iter;
136 for (iter = audioTracks.begin(); iter != audioTracks.end(); ++iter) { 143 for (iter = audioTracks.begin(); iter != audioTracks.end(); ++iter) {
137 (*iter)->registerMediaStream(this); 144 (*iter)->registerMediaStream(this);
138 audioComponents.push_back((*iter)->component()); 145 audioComponents.push_back((*iter)->component());
139 } 146 }
140 for (iter = videoTracks.begin(); iter != videoTracks.end(); ++iter) { 147 for (iter = videoTracks.begin(); iter != videoTracks.end(); ++iter) {
141 (*iter)->registerMediaStream(this); 148 (*iter)->registerMediaStream(this);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 EventTargetWithInlineData::trace(visitor); 427 EventTargetWithInlineData::trace(visitor);
421 ContextClient::trace(visitor); 428 ContextClient::trace(visitor);
422 MediaStreamDescriptorClient::trace(visitor); 429 MediaStreamDescriptorClient::trace(visitor);
423 } 430 }
424 431
425 MediaStream* toMediaStream(MediaStreamDescriptor* descriptor) { 432 MediaStream* toMediaStream(MediaStreamDescriptor* descriptor) {
426 return static_cast<MediaStream*>(descriptor->client()); 433 return static_cast<MediaStream*>(descriptor->client());
427 } 434 }
428 435
429 } // namespace blink 436 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/mediastream/MediaStream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698