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

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

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 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
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 void MIDIAccess::setOnstatechange(PassRefPtrWillBeRawPtr<EventListener> listener ) 76 void MIDIAccess::setOnstatechange(PassRefPtrWillBeRawPtr<EventListener> listener )
77 { 77 {
78 m_hasPendingActivity = listener; 78 m_hasPendingActivity = listener;
79 setAttributeEventListener(EventTypeNames::statechange, listener); 79 setAttributeEventListener(EventTypeNames::statechange, listener);
80 } 80 }
81 81
82 bool MIDIAccess::hasPendingActivity() const 82 bool MIDIAccess::hasPendingActivity() const
83 { 83 {
84 return m_hasPendingActivity && !executionContext()->activeDOMObjectsAreStopp ed(); 84 return m_hasPendingActivity && !getExecutionContext()->activeDOMObjectsAreSt opped();
85 } 85 }
86 86
87 MIDIInputMap* MIDIAccess::inputs() const 87 MIDIInputMap* MIDIAccess::inputs() const
88 { 88 {
89 HeapVector<Member<MIDIInput>> inputs; 89 HeapVector<Member<MIDIInput>> inputs;
90 HashSet<String> ids; 90 HashSet<String> ids;
91 for (size_t i = 0; i < m_inputs.size(); ++i) { 91 for (size_t i = 0; i < m_inputs.size(); ++i) {
92 MIDIInput* input = m_inputs[i]; 92 MIDIInput* input = m_inputs[i];
93 if (input->getState() != PortState::MIDIPortStateDisconnected) { 93 if (input->getState() != PortState::MIDIPortStateDisconnected) {
94 inputs.append(input); 94 inputs.append(input);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 void MIDIAccess::didReceiveMIDIData(unsigned portIndex, const unsigned char* dat a, size_t length, double timeStamp) 158 void MIDIAccess::didReceiveMIDIData(unsigned portIndex, const unsigned char* dat a, size_t length, double timeStamp)
159 { 159 {
160 ASSERT(isMainThread()); 160 ASSERT(isMainThread());
161 if (portIndex >= m_inputs.size()) 161 if (portIndex >= m_inputs.size())
162 return; 162 return;
163 163
164 // Convert from time in seconds which is based on the time coordinate system of monotonicallyIncreasingTime() 164 // Convert from time in seconds which is based on the time coordinate system of monotonicallyIncreasingTime()
165 // into time in milliseconds (a DOMHighResTimeStamp) according to the same t ime coordinate system as performance.now(). 165 // into time in milliseconds (a DOMHighResTimeStamp) according to the same t ime coordinate system as performance.now().
166 // This is how timestamps are defined in the Web MIDI spec. 166 // This is how timestamps are defined in the Web MIDI spec.
167 Document* document = toDocument(executionContext()); 167 Document* document = toDocument(getExecutionContext());
168 ASSERT(document); 168 ASSERT(document);
169 169
170 double timeStampInMilliseconds = 1000 * document->loader()->timing().monoton icTimeToZeroBasedDocumentTime(timeStamp); 170 double timeStampInMilliseconds = 1000 * document->loader()->timing().monoton icTimeToZeroBasedDocumentTime(timeStamp);
171 171
172 m_inputs[portIndex]->didReceiveMIDIData(portIndex, data, length, timeStampIn Milliseconds); 172 m_inputs[portIndex]->didReceiveMIDIData(portIndex, data, length, timeStampIn Milliseconds);
173 } 173 }
174 174
175 void MIDIAccess::sendMIDIData(unsigned portIndex, const unsigned char* data, siz e_t length, double timeStampInMilliseconds) 175 void MIDIAccess::sendMIDIData(unsigned portIndex, const unsigned char* data, siz e_t length, double timeStampInMilliseconds)
176 { 176 {
177 if (!data || !length || portIndex >= m_outputs.size()) 177 if (!data || !length || portIndex >= m_outputs.size())
178 return; 178 return;
179 // Convert from a time in milliseconds (a DOMHighResTimeStamp) according to the same time coordinate system as performance.now() 179 // Convert from a time in milliseconds (a DOMHighResTimeStamp) according to the same time coordinate system as performance.now()
180 // into a time in seconds which is based on the time coordinate system of mo notonicallyIncreasingTime(). 180 // into a time in seconds which is based on the time coordinate system of mo notonicallyIncreasingTime().
181 double timeStamp; 181 double timeStamp;
182 182
183 if (!timeStampInMilliseconds) { 183 if (!timeStampInMilliseconds) {
184 // We treat a value of 0 (which is the default value) as special, meanin g "now". 184 // We treat a value of 0 (which is the default value) as special, meanin g "now".
185 // We need to translate it exactly to 0 seconds. 185 // We need to translate it exactly to 0 seconds.
186 timeStamp = 0; 186 timeStamp = 0;
187 } else { 187 } else {
188 Document* document = toDocument(executionContext()); 188 Document* document = toDocument(getExecutionContext());
189 ASSERT(document); 189 ASSERT(document);
190 double documentStartTime = document->loader()->timing().referenceMonoton icTime(); 190 double documentStartTime = document->loader()->timing().referenceMonoton icTime();
191 timeStamp = documentStartTime + 0.001 * timeStampInMilliseconds; 191 timeStamp = documentStartTime + 0.001 * timeStampInMilliseconds;
192 } 192 }
193 193
194 m_accessor->sendMIDIData(portIndex, data, length, timeStamp); 194 m_accessor->sendMIDIData(portIndex, data, length, timeStamp);
195 } 195 }
196 196
197 void MIDIAccess::stop() 197 void MIDIAccess::stop()
198 { 198 {
199 m_accessor.clear(); 199 m_accessor.clear();
200 } 200 }
201 201
202 DEFINE_TRACE(MIDIAccess) 202 DEFINE_TRACE(MIDIAccess)
203 { 203 {
204 visitor->trace(m_inputs); 204 visitor->trace(m_inputs);
205 visitor->trace(m_outputs); 205 visitor->trace(m_outputs);
206 RefCountedGarbageCollectedEventTargetWithInlineData<MIDIAccess>::trace(visit or); 206 RefCountedGarbageCollectedEventTargetWithInlineData<MIDIAccess>::trace(visit or);
207 ActiveDOMObject::trace(visitor); 207 ActiveDOMObject::trace(visitor);
208 } 208 }
209 209
210 } // namespace blink 210 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698