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

Side by Side Diff: Source/modules/mediastream/RTCDTMFSender.cpp

Issue 19724003: Revert "Transition modules/** to use ExceptionState" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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
« no previous file with comments | « Source/modules/mediastream/RTCDTMFSender.h ('k') | Source/modules/mediastream/RTCDataChannel.h » ('j') | 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) 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (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 "config.h" 26 #include "config.h"
27
27 #include "modules/mediastream/RTCDTMFSender.h" 28 #include "modules/mediastream/RTCDTMFSender.h"
28 29
29 #include "bindings/v8/ExceptionState.h"
30 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
31 #include "core/dom/ScriptExecutionContext.h" 31 #include "core/dom/ScriptExecutionContext.h"
32 #include "core/platform/mediastream/RTCDTMFSenderHandler.h" 32 #include "core/platform/mediastream/RTCDTMFSenderHandler.h"
33 #include "core/platform/mediastream/RTCPeerConnectionHandler.h" 33 #include "core/platform/mediastream/RTCPeerConnectionHandler.h"
34 #include "modules/mediastream/MediaStreamTrack.h" 34 #include "modules/mediastream/MediaStreamTrack.h"
35 #include "modules/mediastream/RTCDTMFToneChangeEvent.h" 35 #include "modules/mediastream/RTCDTMFToneChangeEvent.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 static const long minToneDurationMs = 70; 39 static const long minToneDurationMs = 70;
40 static const long defaultToneDurationMs = 100; 40 static const long defaultToneDurationMs = 100;
41 static const long maxToneDurationMs = 6000; 41 static const long maxToneDurationMs = 6000;
42 static const long minInterToneGapMs = 50; 42 static const long minInterToneGapMs = 50;
43 static const long defaultInterToneGapMs = 50; 43 static const long defaultInterToneGapMs = 50;
44 44
45 PassRefPtr<RTCDTMFSender> RTCDTMFSender::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* peerConnectionHandler, PassRefPtr<MediaStreamTrack> p rpTrack, ExceptionState& es) 45 PassRefPtr<RTCDTMFSender> RTCDTMFSender::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* peerConnectionHandler, PassRefPtr<MediaStreamTrack> p rpTrack, ExceptionCode& ec)
46 { 46 {
47 RefPtr<MediaStreamTrack> track = prpTrack; 47 RefPtr<MediaStreamTrack> track = prpTrack;
48 OwnPtr<RTCDTMFSenderHandler> handler = peerConnectionHandler->createDTMFSend er(track->component()); 48 OwnPtr<RTCDTMFSenderHandler> handler = peerConnectionHandler->createDTMFSend er(track->component());
49 if (!handler) { 49 if (!handler) {
50 es.throwDOMException(NotSupportedError); 50 ec = NotSupportedError;
51 return 0; 51 return 0;
52 } 52 }
53 53
54 RefPtr<RTCDTMFSender> dtmfSender = adoptRef(new RTCDTMFSender(context, track , handler.release())); 54 RefPtr<RTCDTMFSender> dtmfSender = adoptRef(new RTCDTMFSender(context, track , handler.release()));
55 dtmfSender->suspendIfNeeded(); 55 dtmfSender->suspendIfNeeded();
56 return dtmfSender.release(); 56 return dtmfSender.release();
57 } 57 }
58 58
59 RTCDTMFSender::RTCDTMFSender(ScriptExecutionContext* context, PassRefPtr<MediaSt reamTrack> track, PassOwnPtr<RTCDTMFSenderHandler> handler) 59 RTCDTMFSender::RTCDTMFSender(ScriptExecutionContext* context, PassRefPtr<MediaSt reamTrack> track, PassOwnPtr<RTCDTMFSenderHandler> handler)
60 : ActiveDOMObject(context) 60 : ActiveDOMObject(context)
(...skipping 20 matching lines...) Expand all
81 MediaStreamTrack* RTCDTMFSender::track() const 81 MediaStreamTrack* RTCDTMFSender::track() const
82 { 82 {
83 return m_track.get(); 83 return m_track.get();
84 } 84 }
85 85
86 String RTCDTMFSender::toneBuffer() const 86 String RTCDTMFSender::toneBuffer() const
87 { 87 {
88 return m_handler->currentToneBuffer(); 88 return m_handler->currentToneBuffer();
89 } 89 }
90 90
91 void RTCDTMFSender::insertDTMF(const String& tones, ExceptionState& es) 91 void RTCDTMFSender::insertDTMF(const String& tones, ExceptionCode& ec)
92 { 92 {
93 insertDTMF(tones, defaultToneDurationMs, defaultInterToneGapMs, es); 93 insertDTMF(tones, defaultToneDurationMs, defaultInterToneGapMs, ec);
94 } 94 }
95 95
96 void RTCDTMFSender::insertDTMF(const String& tones, long duration, ExceptionStat e& es) 96 void RTCDTMFSender::insertDTMF(const String& tones, long duration, ExceptionCode & ec)
97 { 97 {
98 insertDTMF(tones, duration, defaultInterToneGapMs, es); 98 insertDTMF(tones, duration, defaultInterToneGapMs, ec);
99 } 99 }
100 100
101 void RTCDTMFSender::insertDTMF(const String& tones, long duration, long interTon eGap, ExceptionState& es) 101 void RTCDTMFSender::insertDTMF(const String& tones, long duration, long interTon eGap, ExceptionCode& ec)
102 { 102 {
103 if (!canInsertDTMF()) { 103 if (!canInsertDTMF()) {
104 es.throwDOMException(NotSupportedError); 104 ec = NotSupportedError;
105 return; 105 return;
106 } 106 }
107 107
108 if (duration > maxToneDurationMs || duration < minToneDurationMs) { 108 if (duration > maxToneDurationMs || duration < minToneDurationMs) {
109 es.throwDOMException(SyntaxError); 109 ec = SyntaxError;
110 return; 110 return;
111 } 111 }
112 112
113 if (interToneGap < minInterToneGapMs) { 113 if (interToneGap < minInterToneGapMs) {
114 es.throwDOMException(SyntaxError); 114 ec = SyntaxError;
115 return; 115 return;
116 } 116 }
117 117
118 m_duration = duration; 118 m_duration = duration;
119 m_interToneGap = interToneGap; 119 m_interToneGap = interToneGap;
120 120
121 if (!m_handler->insertDTMF(tones, m_duration, m_interToneGap)) 121 if (!m_handler->insertDTMF(tones, m_duration, m_interToneGap))
122 es.throwDOMException(SyntaxError); 122 ec = SyntaxError;
123 } 123 }
124 124
125 void RTCDTMFSender::didPlayTone(const String& tone) 125 void RTCDTMFSender::didPlayTone(const String& tone)
126 { 126 {
127 scheduleDispatchEvent(RTCDTMFToneChangeEvent::create(tone)); 127 scheduleDispatchEvent(RTCDTMFToneChangeEvent::create(tone));
128 } 128 }
129 129
130 const AtomicString& RTCDTMFSender::interfaceName() const 130 const AtomicString& RTCDTMFSender::interfaceName() const
131 { 131 {
132 return eventNames().interfaceForRTCDTMFSender; 132 return eventNames().interfaceForRTCDTMFSender;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 Vector<RefPtr<Event> > events; 169 Vector<RefPtr<Event> > events;
170 events.swap(m_scheduledEvents); 170 events.swap(m_scheduledEvents);
171 171
172 Vector<RefPtr<Event> >::iterator it = events.begin(); 172 Vector<RefPtr<Event> >::iterator it = events.begin();
173 for (; it != events.end(); ++it) 173 for (; it != events.end(); ++it)
174 dispatchEvent((*it).release()); 174 dispatchEvent((*it).release());
175 } 175 }
176 176
177 } // namespace WebCore 177 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediastream/RTCDTMFSender.h ('k') | Source/modules/mediastream/RTCDataChannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698