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 ENABLE(OILPAN) | 24 #if ENABLE(OILPAN) |
| 25 // A prefinalizer has already been registered (as a LifecycleObserver); |
| 26 // remove it and register a combined one, as the infrastructure doesn't |
| 27 // support multiple prefinalizers for an object. |
| 28 // |
| 29 // FIXME: Oilpan: remove LifecycleObserver's need for a prefinalizer, |
| 30 // and as a consequence, this unregistration step. If the former is independ
ently |
| 31 // removed, the unregisterPreFinalizer() call will assert. |
| 32 ThreadState::current()->unregisterPreFinalizer(*static_cast<LifecycleObserve
r*>(this)); |
25 ThreadState::current()->registerPreFinalizer(*this); | 33 ThreadState::current()->registerPreFinalizer(*this); |
26 #endif | 34 #endif |
27 if (options.hasSysex()) | 35 if (options.hasSysex()) |
28 m_requestSysex = options.sysex(); | 36 m_requestSysex = options.sysex(); |
29 } | 37 } |
30 | 38 |
31 MIDIAccessInitializer::~MIDIAccessInitializer() | 39 MIDIAccessInitializer::~MIDIAccessInitializer() |
32 { | 40 { |
33 #if !ENABLE(OILPAN) | 41 #if !ENABLE(OILPAN) |
34 dispose(); | 42 dispose(); |
35 #endif | 43 #endif |
36 } | 44 } |
37 | 45 |
38 void MIDIAccessInitializer::dispose() | 46 void MIDIAccessInitializer::dispose() |
39 { | 47 { |
40 // It is safe to cancel a request which is already finished or cancelled. | 48 // It is safe to cancel a request which is already finished or cancelled. |
41 Document* document = toDocument(executionContext()); | 49 Document* document = toDocument(executionContext()); |
42 ASSERT(document); | 50 ASSERT(document); |
43 if (MIDIController* controller = MIDIController::from(document->frame())) | 51 if (MIDIController* controller = MIDIController::from(document->frame())) |
44 controller->cancelSysexPermissionRequest(this); | 52 controller->cancelSysexPermissionRequest(this); |
| 53 |
| 54 #if ENABLE(OILPAN) |
| 55 // Delegate to LifecycleObserver's prefinalizer. |
| 56 LifecycleObserver::dispose(); |
| 57 #endif |
45 } | 58 } |
46 | 59 |
47 ScriptPromise MIDIAccessInitializer::start() | 60 ScriptPromise MIDIAccessInitializer::start() |
48 { | 61 { |
49 ScriptPromise promise = this->promise(); | 62 ScriptPromise promise = this->promise(); |
50 m_accessor = MIDIAccessor::create(this); | 63 m_accessor = MIDIAccessor::create(this); |
51 | 64 |
52 if (!m_requestSysex) { | 65 if (!m_requestSysex) { |
53 m_accessor->startSession(); | 66 m_accessor->startSession(); |
54 return promise; | 67 return promise; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 { | 124 { |
112 return executionContext()->securityOrigin(); | 125 return executionContext()->securityOrigin(); |
113 } | 126 } |
114 | 127 |
115 ExecutionContext* MIDIAccessInitializer::executionContext() const | 128 ExecutionContext* MIDIAccessInitializer::executionContext() const |
116 { | 129 { |
117 return scriptState()->executionContext(); | 130 return scriptState()->executionContext(); |
118 } | 131 } |
119 | 132 |
120 } // namespace blink | 133 } // namespace blink |
OLD | NEW |