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

Side by Side Diff: third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.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 // 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 "modules/webmidi/MIDIAccessInitializer.h" 5 #include "modules/webmidi/MIDIAccessInitializer.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 25 matching lines...) Expand all
36 { 36 {
37 dispose(); 37 dispose();
38 LifecycleObserver::contextDestroyed(); 38 LifecycleObserver::contextDestroyed();
39 } 39 }
40 40
41 void MIDIAccessInitializer::dispose() 41 void MIDIAccessInitializer::dispose()
42 { 42 {
43 if (m_hasBeenDisposed) 43 if (m_hasBeenDisposed)
44 return; 44 return;
45 45
46 if (!executionContext()) 46 if (!getExecutionContext())
47 return; 47 return;
48 48
49 if (!m_permissionResolved) { 49 if (!m_permissionResolved) {
50 Document* document = toDocument(executionContext()); 50 Document* document = toDocument(getExecutionContext());
51 ASSERT(document); 51 ASSERT(document);
52 if (MIDIController* controller = MIDIController::from(document->frame()) ) 52 if (MIDIController* controller = MIDIController::from(document->frame()) )
53 controller->cancelPermissionRequest(this); 53 controller->cancelPermissionRequest(this);
54 m_permissionResolved = true; 54 m_permissionResolved = true;
55 } 55 }
56 56
57 m_hasBeenDisposed = true; 57 m_hasBeenDisposed = true;
58 } 58 }
59 59
60 ScriptPromise MIDIAccessInitializer::start() 60 ScriptPromise MIDIAccessInitializer::start()
61 { 61 {
62 ScriptPromise promise = this->promise(); 62 ScriptPromise promise = this->promise();
63 m_accessor = MIDIAccessor::create(this); 63 m_accessor = MIDIAccessor::create(this);
64 64
65 Document* document = toDocument(executionContext()); 65 Document* document = toDocument(getExecutionContext());
66 ASSERT(document); 66 ASSERT(document);
67 if (MIDIController* controller = MIDIController::from(document->frame())) 67 if (MIDIController* controller = MIDIController::from(document->frame()))
68 controller->requestPermission(this, m_options); 68 controller->requestPermission(this, m_options);
69 else 69 else
70 reject(DOMException::create(SecurityError)); 70 reject(DOMException::create(SecurityError));
71 71
72 return promise; 72 return promise;
73 } 73 }
74 74
75 void MIDIAccessInitializer::didAddInputPort(const String& id, const String& manu facturer, const String& name, const String& version, PortState state) 75 void MIDIAccessInitializer::didAddInputPort(const String& id, const String& manu facturer, const String& name, const String& version, PortState state)
(...skipping 19 matching lines...) Expand all
95 void MIDIAccessInitializer::didSetOutputPortState(unsigned portIndex, PortState state) 95 void MIDIAccessInitializer::didSetOutputPortState(unsigned portIndex, PortState state)
96 { 96 {
97 // See comments on didSetInputPortState(). 97 // See comments on didSetInputPortState().
98 ASSERT_NOT_REACHED(); 98 ASSERT_NOT_REACHED();
99 } 99 }
100 100
101 void MIDIAccessInitializer::didStartSession(bool success, const String& error, c onst String& message) 101 void MIDIAccessInitializer::didStartSession(bool success, const String& error, c onst String& message)
102 { 102 {
103 ASSERT(m_accessor); 103 ASSERT(m_accessor);
104 if (success) { 104 if (success) {
105 resolve(MIDIAccess::create(m_accessor.release(), m_options.hasSysex() && m_options.sysex(), m_portDescriptors, executionContext())); 105 resolve(MIDIAccess::create(m_accessor.release(), m_options.hasSysex() && m_options.sysex(), m_portDescriptors, getExecutionContext()));
106 } else { 106 } else {
107 // The spec says the name is one of 107 // The spec says the name is one of
108 // - SecurityError 108 // - SecurityError
109 // - AbortError 109 // - AbortError
110 // - InvalidStateError 110 // - InvalidStateError
111 // - NotSupportedError 111 // - NotSupportedError
112 // TODO(toyoshim): Do not rely on |error| string. Instead an enum 112 // TODO(toyoshim): Do not rely on |error| string. Instead an enum
113 // representing an ExceptionCode should be defined and deliverred. 113 // representing an ExceptionCode should be defined and deliverred.
114 ExceptionCode ec = InvalidStateError; 114 ExceptionCode ec = InvalidStateError;
115 if (error == DOMException::getErrorName(SecurityError)) { 115 if (error == DOMException::getErrorName(SecurityError)) {
(...skipping 11 matching lines...) Expand all
127 127
128 void MIDIAccessInitializer::resolvePermission(bool allowed) 128 void MIDIAccessInitializer::resolvePermission(bool allowed)
129 { 129 {
130 m_permissionResolved = true; 130 m_permissionResolved = true;
131 if (allowed) 131 if (allowed)
132 m_accessor->startSession(); 132 m_accessor->startSession();
133 else 133 else
134 reject(DOMException::create(SecurityError)); 134 reject(DOMException::create(SecurityError));
135 } 135 }
136 136
137 SecurityOrigin* MIDIAccessInitializer::securityOrigin() const 137 SecurityOrigin* MIDIAccessInitializer::getSecurityOrigin() const
138 { 138 {
139 return executionContext()->securityOrigin(); 139 return getExecutionContext()->getSecurityOrigin();
140 } 140 }
141 141
142 ExecutionContext* MIDIAccessInitializer::executionContext() const 142 ExecutionContext* MIDIAccessInitializer::getExecutionContext() const
143 { 143 {
144 return scriptState()->executionContext(); 144 return getScriptState()->getExecutionContext();
145 } 145 }
146 146
147 } // namespace blink 147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698