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

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

Issue 317413003: Move MIDI code to hang off WebFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix webkit tests Created 6 years, 6 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 | « no previous file | Source/modules/webmidi/MIDIClient.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 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 void MIDIAccess::stop() 168 void MIDIAccess::stop()
169 { 169 {
170 if (m_state == Stopped) 170 if (m_state == Stopped)
171 return; 171 return;
172 m_accessor.clear(); 172 m_accessor.clear();
173 m_weakPtrFactory.revokeAll(); 173 m_weakPtrFactory.revokeAll();
174 if (m_state == Requesting) { 174 if (m_state == Requesting) {
175 Document* document = toDocument(executionContext()); 175 Document* document = toDocument(executionContext());
176 ASSERT(document); 176 ASSERT(document);
177 MIDIController* controller = MIDIController::from(document->page()); 177 MIDIController* controller = MIDIController::from(document->frame());
178 ASSERT(controller); 178 ASSERT(controller);
179 controller->cancelSysexPermissionRequest(this); 179 controller->cancelSysexPermissionRequest(this);
180 } 180 }
181 m_state = Stopped; 181 m_state = Stopped;
182 } 182 }
183 183
184 bool MIDIAccess::hasPendingActivity() const 184 bool MIDIAccess::hasPendingActivity() const
185 { 185 {
186 return m_state == Requesting; 186 return m_state == Requesting;
187 } 187 }
(...skipping 10 matching lines...) Expand all
198 ScriptPromise promise = m_resolver->promise(); 198 ScriptPromise promise = m_resolver->promise();
199 promise.then(PostAction::create(scriptState->isolate(), m_weakPtrFactory.cre ateWeakPtr(), Resolved), 199 promise.then(PostAction::create(scriptState->isolate(), m_weakPtrFactory.cre ateWeakPtr(), Resolved),
200 PostAction::create(scriptState->isolate(), m_weakPtrFactory.createWeakPt r(), Stopped)); 200 PostAction::create(scriptState->isolate(), m_weakPtrFactory.createWeakPt r(), Stopped));
201 201
202 if (!m_options.sysex) { 202 if (!m_options.sysex) {
203 m_accessor->startSession(); 203 m_accessor->startSession();
204 return promise; 204 return promise;
205 } 205 }
206 Document* document = toDocument(executionContext()); 206 Document* document = toDocument(executionContext());
207 ASSERT(document); 207 ASSERT(document);
208 MIDIController* controller = MIDIController::from(document->page()); 208 MIDIController* controller = MIDIController::from(document->frame());
209 if (controller) { 209 if (controller) {
210 controller->requestSysexPermission(this); 210 controller->requestSysexPermission(this);
211 } else { 211 } else {
212 m_resolver->reject(DOMError::create("SecurityError")); 212 m_resolver->reject(DOMError::create("SecurityError"));
213 } 213 }
214 return promise; 214 return promise;
215 } 215 }
216 216
217 void MIDIAccess::doPostAction(State state) 217 void MIDIAccess::doPostAction(State state)
218 { 218 {
219 ASSERT(m_state == Requesting); 219 ASSERT(m_state == Requesting);
220 ASSERT(state == Resolved || state == Stopped); 220 ASSERT(state == Resolved || state == Stopped);
221 if (state == Stopped) { 221 if (state == Stopped) {
222 m_accessor.clear(); 222 m_accessor.clear();
223 } 223 }
224 m_weakPtrFactory.revokeAll(); 224 m_weakPtrFactory.revokeAll();
225 m_state = state; 225 m_state = state;
226 } 226 }
227 227
228 void MIDIAccess::trace(Visitor* visitor) 228 void MIDIAccess::trace(Visitor* visitor)
229 { 229 {
230 visitor->trace(m_inputs); 230 visitor->trace(m_inputs);
231 visitor->trace(m_outputs); 231 visitor->trace(m_outputs);
232 EventTargetWithInlineData::trace(visitor); 232 EventTargetWithInlineData::trace(visitor);
233 } 233 }
234 234
235 } // namespace WebCore 235 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/modules/webmidi/MIDIClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698