Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/webmidi/MIDIAccessInitializer.h" | 6 #include "modules/webmidi/MIDIAccessInitializer.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMError.h" | 10 #include "core/dom/DOMError.h" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/frame/Navigator.h" | 12 #include "core/frame/Navigator.h" |
| 13 #include "modules/webmidi/MIDIAccess.h" | 13 #include "modules/webmidi/MIDIAccess.h" |
| 14 #include "modules/webmidi/MIDIController.h" | 14 #include "modules/webmidi/MIDIController.h" |
| 15 #include "modules/webmidi/MIDIOptions.h" | 15 #include "modules/webmidi/MIDIOptions.h" |
| 16 #include "modules/webmidi/MIDIPort.h" | 16 #include "modules/webmidi/MIDIPort.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 MIDIAccessInitializer::MIDIAccessInitializer(ScriptState* scriptState, const MID IOptions& options) | 20 MIDIAccessInitializer::MIDIAccessInitializer(ScriptState* scriptState, const MID IOptions& options) |
| 21 : ScriptPromiseResolver(scriptState) | 21 : ScriptPromiseResolver(scriptState) |
| 22 , m_requestSysex(false) | 22 , m_requestSysex(false) |
| 23 { | 23 { |
| 24 if (options.hasSysex()) | 24 if (options.hasSysex()) |
| 25 m_requestSysex = options.sysex(); | 25 m_requestSysex = options.sysex(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 MIDIAccessInitializer::~MIDIAccessInitializer() | 28 MIDIAccessInitializer::~MIDIAccessInitializer() |
| 29 { | 29 { |
|
haraken
2014/12/18 14:42:46
What happens if MIDIAccessInitializer gets destruc
sof
2014/12/18 14:53:54
A permissions request will be made with the contro
haraken
2014/12/18 15:02:28
I'm wondering if it's possible that the MIDIAccess
sof
2014/12/18 15:17:57
If that's a concern, I can rephrase this to be a r
haraken
2014/12/18 15:44:02
Yeah, I guess a more straightforward approach woul
| |
| 30 // It is safe to cancel a request which is already finished or canceld. | 30 } |
| 31 | |
| 32 void MIDIAccessInitializer::cancel() | |
| 33 { | |
| 31 Document* document = toDocument(executionContext()); | 34 Document* document = toDocument(executionContext()); |
| 32 ASSERT(document); | 35 ASSERT(document); |
| 33 MIDIController* controller = MIDIController::from(document->frame()); | 36 MIDIController* controller = MIDIController::from(document->frame()); |
| 34 if (controller) | 37 if (controller) |
| 35 controller->cancelSysexPermissionRequest(this); | 38 controller->cancelSysexPermissionRequest(this); |
| 36 } | 39 } |
| 37 | 40 |
| 41 void MIDIAccessInitializer::stop() | |
| 42 { | |
| 43 // It is safe to cancel a request which is already finished or canceld. | |
|
haraken
2014/12/18 14:42:46
canceled
| |
| 44 cancel(); | |
| 45 ScriptPromiseResolver::stop(); | |
| 46 } | |
| 47 | |
| 38 ScriptPromise MIDIAccessInitializer::start() | 48 ScriptPromise MIDIAccessInitializer::start() |
| 39 { | 49 { |
| 40 ScriptPromise promise = this->promise(); | 50 ScriptPromise promise = this->promise(); |
| 41 m_accessor = MIDIAccessor::create(this); | 51 m_accessor = MIDIAccessor::create(this); |
| 42 | 52 |
| 43 if (!m_requestSysex) { | 53 if (!m_requestSysex) { |
| 44 m_accessor->startSession(); | 54 m_accessor->startSession(); |
| 45 return promise; | 55 return promise; |
| 46 } | 56 } |
| 47 Document* document = toDocument(executionContext()); | 57 Document* document = toDocument(executionContext()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 { | 113 { |
| 104 return executionContext()->securityOrigin(); | 114 return executionContext()->securityOrigin(); |
| 105 } | 115 } |
| 106 | 116 |
| 107 ExecutionContext* MIDIAccessInitializer::executionContext() const | 117 ExecutionContext* MIDIAccessInitializer::executionContext() const |
| 108 { | 118 { |
| 109 return scriptState()->executionContext(); | 119 return scriptState()->executionContext(); |
| 110 } | 120 } |
| 111 | 121 |
| 112 } // namespace blink | 122 } // namespace blink |
| OLD | NEW |