| 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 , m_hasBeenDisposed(false) | 23 , m_hasBeenDisposed(false) |
| 24 , m_sysexPermissionResolved(false) | 24 , m_sysexPermissionResolved(false) |
| 25 { | 25 { |
| 26 #if ENABLE(OILPAN) | |
| 27 // A prefinalizer has already been registered (as a LifecycleObserver); | |
| 28 // remove it and register a combined one, as the infrastructure doesn't | |
| 29 // support multiple prefinalizers for an object. | |
| 30 // | |
| 31 // FIXME: Oilpan: remove LifecycleObserver's need for a prefinalizer, | |
| 32 // and as a consequence, this unregistration step. If the former is independ
ently | |
| 33 // removed, the unregisterPreFinalizer() call will assert. | |
| 34 ThreadState::current()->unregisterPreFinalizer(*static_cast<LifecycleObserve
r*>(this)); | |
| 35 ThreadState::current()->registerPreFinalizer(*this); | |
| 36 #endif | |
| 37 if (options.hasSysex()) | 26 if (options.hasSysex()) |
| 38 m_requestSysex = options.sysex(); | 27 m_requestSysex = options.sysex(); |
| 39 } | 28 } |
| 40 | 29 |
| 41 MIDIAccessInitializer::~MIDIAccessInitializer() | 30 MIDIAccessInitializer::~MIDIAccessInitializer() |
| 42 { | 31 { |
| 43 #if !ENABLE(OILPAN) | 32 #if !ENABLE(OILPAN) |
| 44 dispose(); | 33 dispose(); |
| 45 #endif | 34 #endif |
| 46 } | 35 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 | 49 |
| 61 if (!m_sysexPermissionResolved) { | 50 if (!m_sysexPermissionResolved) { |
| 62 Document* document = toDocument(executionContext()); | 51 Document* document = toDocument(executionContext()); |
| 63 ASSERT(document); | 52 ASSERT(document); |
| 64 if (MIDIController* controller = MIDIController::from(document->frame())
) | 53 if (MIDIController* controller = MIDIController::from(document->frame())
) |
| 65 controller->cancelSysexPermissionRequest(this); | 54 controller->cancelSysexPermissionRequest(this); |
| 66 m_sysexPermissionResolved = true; | 55 m_sysexPermissionResolved = true; |
| 67 } | 56 } |
| 68 | 57 |
| 69 m_hasBeenDisposed = true; | 58 m_hasBeenDisposed = true; |
| 70 | |
| 71 #if ENABLE(OILPAN) | |
| 72 // Delegate to LifecycleObserver's prefinalizer. | |
| 73 LifecycleObserver::dispose(); | |
| 74 #endif | |
| 75 } | 59 } |
| 76 | 60 |
| 77 ScriptPromise MIDIAccessInitializer::start() | 61 ScriptPromise MIDIAccessInitializer::start() |
| 78 { | 62 { |
| 79 ScriptPromise promise = this->promise(); | 63 ScriptPromise promise = this->promise(); |
| 80 m_accessor = MIDIAccessor::create(this); | 64 m_accessor = MIDIAccessor::create(this); |
| 81 | 65 |
| 82 if (!m_requestSysex) { | 66 if (!m_requestSysex) { |
| 83 m_accessor->startSession(); | 67 m_accessor->startSession(); |
| 84 return promise; | 68 return promise; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 { | 126 { |
| 143 return executionContext()->securityOrigin(); | 127 return executionContext()->securityOrigin(); |
| 144 } | 128 } |
| 145 | 129 |
| 146 ExecutionContext* MIDIAccessInitializer::executionContext() const | 130 ExecutionContext* MIDIAccessInitializer::executionContext() const |
| 147 { | 131 { |
| 148 return scriptState()->executionContext(); | 132 return scriptState()->executionContext(); |
| 149 } | 133 } |
| 150 | 134 |
| 151 } // namespace blink | 135 } // namespace blink |
| OLD | NEW |