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

Side by Side Diff: third_party/WebKit/Source/modules/webmidi/MIDIPort.cpp

Issue 1901103006: Web MIDI: Replace ASSERT macros with DCHECK macros (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/webmidi/MIDIOutput.cpp ('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) 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 : ActiveScriptWrappable(this) 43 : ActiveScriptWrappable(this)
44 , ActiveDOMObject(access->getExecutionContext()) 44 , ActiveDOMObject(access->getExecutionContext())
45 , m_id(id) 45 , m_id(id)
46 , m_manufacturer(manufacturer) 46 , m_manufacturer(manufacturer)
47 , m_name(name) 47 , m_name(name)
48 , m_type(type) 48 , m_type(type)
49 , m_version(version) 49 , m_version(version)
50 , m_access(access) 50 , m_access(access)
51 , m_connection(ConnectionStateClosed) 51 , m_connection(ConnectionStateClosed)
52 { 52 {
53 ASSERT(access); 53 DCHECK(access);
54 ASSERT(type == TypeInput || type == TypeOutput); 54 DCHECK(type == TypeInput || type == TypeOutput);
55 ASSERT(state == PortState::MIDIPortStateDisconnected 55 DCHECK(state == PortState::MIDIPortStateDisconnected
56 || state == PortState::MIDIPortStateConnected); 56 || state == PortState::MIDIPortStateConnected);
57 m_state = state; 57 m_state = state;
58 } 58 }
59 59
60 String MIDIPort::connection() const 60 String MIDIPort::connection() const
61 { 61 {
62 switch (m_connection) { 62 switch (m_connection) {
63 case ConnectionStateOpen: 63 case ConnectionStateOpen:
64 return "open"; 64 return "open";
65 case ConnectionStateClosed: 65 case ConnectionStateClosed:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 break; 119 break;
120 case ConnectionStateClosed: 120 case ConnectionStateClosed:
121 // Will do nothing. 121 // Will do nothing.
122 setStates(PortState::MIDIPortStateDisconnected, ConnectionStateClose d); 122 setStates(PortState::MIDIPortStateDisconnected, ConnectionStateClose d);
123 break; 123 break;
124 } 124 }
125 break; 125 break;
126 case PortState::MIDIPortStateConnected: 126 case PortState::MIDIPortStateConnected:
127 switch (m_connection) { 127 switch (m_connection) {
128 case ConnectionStateOpen: 128 case ConnectionStateOpen:
129 ASSERT_NOT_REACHED(); 129 NOTREACHED();
130 break; 130 break;
131 case ConnectionStatePending: 131 case ConnectionStatePending:
132 // We do not use |setStates| in order not to dispatch events twice. 132 // We do not use |setStates| in order not to dispatch events twice.
133 // |open| calls |setStates|. 133 // |open| calls |setStates|.
134 m_state = PortState::MIDIPortStateConnected; 134 m_state = PortState::MIDIPortStateConnected;
135 open(); 135 open();
136 break; 136 break;
137 case ConnectionStateClosed: 137 case ConnectionStateClosed:
138 setStates(PortState::MIDIPortStateConnected, ConnectionStateClosed); 138 setStates(PortState::MIDIPortStateConnected, ConnectionStateClosed);
139 break; 139 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return ScriptPromise::cast(scriptState, toV8(this, scriptState->context()->G lobal(), scriptState->isolate())); 186 return ScriptPromise::cast(scriptState, toV8(this, scriptState->context()->G lobal(), scriptState->isolate()));
187 } 187 }
188 188
189 ScriptPromise MIDIPort::reject(ScriptState* scriptState, ExceptionCode ec, const String& message) 189 ScriptPromise MIDIPort::reject(ScriptState* scriptState, ExceptionCode ec, const String& message)
190 { 190 {
191 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(ec, message)); 191 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(ec, message));
192 } 192 }
193 193
194 void MIDIPort::setStates(PortState state, ConnectionState connection) 194 void MIDIPort::setStates(PortState state, ConnectionState connection)
195 { 195 {
196 ASSERT(state != PortState::MIDIPortStateDisconnected || connection != Connec tionStateOpen); 196 DCHECK(state != PortState::MIDIPortStateDisconnected || connection != Connec tionStateOpen);
197 if (m_state == state && m_connection == connection) 197 if (m_state == state && m_connection == connection)
198 return; 198 return;
199 m_state = state; 199 m_state = state;
200 m_connection = connection; 200 m_connection = connection;
201 dispatchEvent(MIDIConnectionEvent::create(this)); 201 dispatchEvent(MIDIConnectionEvent::create(this));
202 m_access->dispatchEvent(MIDIConnectionEvent::create(this)); 202 m_access->dispatchEvent(MIDIConnectionEvent::create(this));
203 } 203 }
204 204
205 } // namespace blink 205 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webmidi/MIDIOutput.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698