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

Side by Side Diff: third_party/WebKit/Source/modules/peerconnection/RTCDTMFSender.cpp

Issue 2583093002: Reduce SuspendableObjects (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 std::unique_ptr<WebRTCDTMFSenderHandler> handler = WTF::wrapUnique( 53 std::unique_ptr<WebRTCDTMFSenderHandler> handler = WTF::wrapUnique(
54 peerConnectionHandler->createDTMFSender(track->component())); 54 peerConnectionHandler->createDTMFSender(track->component()));
55 if (!handler) { 55 if (!handler) {
56 exceptionState.throwDOMException(NotSupportedError, 56 exceptionState.throwDOMException(NotSupportedError,
57 "The MediaStreamTrack provided is not an " 57 "The MediaStreamTrack provided is not an "
58 "element of a MediaStream that's " 58 "element of a MediaStream that's "
59 "currently in the local streams set."); 59 "currently in the local streams set.");
60 return nullptr; 60 return nullptr;
61 } 61 }
62 62
63 RTCDTMFSender* dtmfSender = 63 return new RTCDTMFSender(context, track, std::move(handler));
64 new RTCDTMFSender(context, track, std::move(handler));
65 dtmfSender->suspendIfNeeded();
66 return dtmfSender;
67 } 64 }
68 65
69 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context, 66 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context,
70 MediaStreamTrack* track, 67 MediaStreamTrack* track,
71 std::unique_ptr<WebRTCDTMFSenderHandler> handler) 68 std::unique_ptr<WebRTCDTMFSenderHandler> handler)
72 : SuspendableObject(context), 69 : ContextLifecycleObserver(context),
73 m_track(track), 70 m_track(track),
74 m_duration(defaultToneDurationMs), 71 m_duration(defaultToneDurationMs),
75 m_interToneGap(defaultInterToneGapMs), 72 m_interToneGap(defaultInterToneGapMs),
76 m_handler(std::move(handler)), 73 m_handler(std::move(handler)),
77 m_stopped(false), 74 m_stopped(false),
78 m_scheduledEventTimer(this, &RTCDTMFSender::scheduledEventTimerFired) { 75 m_scheduledEventTimer(this, &RTCDTMFSender::scheduledEventTimerFired) {
79 m_handler->setClient(this); 76 m_handler->setClient(this);
80 } 77 }
81 78
82 RTCDTMFSender::~RTCDTMFSender() {} 79 RTCDTMFSender::~RTCDTMFSender() {}
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 146
150 void RTCDTMFSender::didPlayTone(const WebString& tone) { 147 void RTCDTMFSender::didPlayTone(const WebString& tone) {
151 scheduleDispatchEvent(RTCDTMFToneChangeEvent::create(tone)); 148 scheduleDispatchEvent(RTCDTMFToneChangeEvent::create(tone));
152 } 149 }
153 150
154 const AtomicString& RTCDTMFSender::interfaceName() const { 151 const AtomicString& RTCDTMFSender::interfaceName() const {
155 return EventTargetNames::RTCDTMFSender; 152 return EventTargetNames::RTCDTMFSender;
156 } 153 }
157 154
158 ExecutionContext* RTCDTMFSender::getExecutionContext() const { 155 ExecutionContext* RTCDTMFSender::getExecutionContext() const {
159 return SuspendableObject::getExecutionContext(); 156 return ContextLifecycleObserver::getExecutionContext();
160 } 157 }
161 158
162 void RTCDTMFSender::contextDestroyed() { 159 void RTCDTMFSender::contextDestroyed() {
163 m_stopped = true; 160 m_stopped = true;
164 m_handler->setClient(nullptr); 161 m_handler->setClient(nullptr);
165 } 162 }
166 163
167 void RTCDTMFSender::scheduleDispatchEvent(Event* event) { 164 void RTCDTMFSender::scheduleDispatchEvent(Event* event) {
168 m_scheduledEvents.append(event); 165 m_scheduledEvents.append(event);
169 166
(...skipping 10 matching lines...) Expand all
180 177
181 HeapVector<Member<Event>>::iterator it = events.begin(); 178 HeapVector<Member<Event>>::iterator it = events.begin();
182 for (; it != events.end(); ++it) 179 for (; it != events.end(); ++it)
183 dispatchEvent((*it).release()); 180 dispatchEvent((*it).release());
184 } 181 }
185 182
186 DEFINE_TRACE(RTCDTMFSender) { 183 DEFINE_TRACE(RTCDTMFSender) {
187 visitor->trace(m_track); 184 visitor->trace(m_track);
188 visitor->trace(m_scheduledEvents); 185 visitor->trace(m_scheduledEvents);
189 EventTargetWithInlineData::trace(visitor); 186 EventTargetWithInlineData::trace(visitor);
190 SuspendableObject::trace(visitor); 187 ContextLifecycleObserver::trace(visitor);
191 } 188 }
192 189
193 } // namespace blink 190 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698