OLD | NEW |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 { | 57 { |
58 stop(); | 58 stop(); |
59 } | 59 } |
60 | 60 |
61 void MIDIAccessPromise::fulfill() | 61 void MIDIAccessPromise::fulfill() |
62 { | 62 { |
63 if (m_state == Pending) { | 63 if (m_state == Pending) { |
64 if (m_successCallback) { | 64 if (m_successCallback) { |
65 m_state = Invoked; | 65 m_state = Invoked; |
66 ASSERT(m_access.get()); | 66 ASSERT(m_access.get()); |
67 m_successCallback->handleEvent(m_access.release().leakRef(), m_optio
ns->sysexEnabled); | 67 m_successCallback->handleEvent(m_access.release().leakRef(), m_optio
ns->sysex); |
68 m_options.clear(); | 68 m_options.clear(); |
69 } else { | 69 } else { |
70 m_state = Accepted; | 70 m_state = Accepted; |
71 } | 71 } |
72 unsetPendingActivity(this); | 72 unsetPendingActivity(this); |
73 } | 73 } |
74 m_successCallback.clear(); | 74 m_successCallback.clear(); |
75 m_errorCallback.clear(); | 75 m_errorCallback.clear(); |
76 } | 76 } |
77 | 77 |
(...skipping 16 matching lines...) Expand all Loading... |
94 void MIDIAccessPromise::then(PassRefPtr<MIDISuccessCallback> successCallback, Pa
ssRefPtr<MIDIErrorCallback> errorCallback) | 94 void MIDIAccessPromise::then(PassRefPtr<MIDISuccessCallback> successCallback, Pa
ssRefPtr<MIDIErrorCallback> errorCallback) |
95 { | 95 { |
96 // Lazily request access. | 96 // Lazily request access. |
97 if (!m_access) { | 97 if (!m_access) { |
98 setPendingActivity(this); | 98 setPendingActivity(this); |
99 m_access = MIDIAccess::create(scriptExecutionContext(), this); | 99 m_access = MIDIAccess::create(scriptExecutionContext(), this); |
100 } | 100 } |
101 | 101 |
102 switch (m_state) { | 102 switch (m_state) { |
103 case Accepted: | 103 case Accepted: |
104 successCallback->handleEvent(m_access.release().leakRef(), m_options->sy
sexEnabled); | 104 successCallback->handleEvent(m_access.release().leakRef(), m_options->sy
sex); |
105 m_options.clear(); | 105 m_options.clear(); |
106 m_state = Invoked; | 106 m_state = Invoked; |
107 break; | 107 break; |
108 case Rejected: | 108 case Rejected: |
109 errorCallback->handleEvent(m_error.release().leakRef()); | 109 errorCallback->handleEvent(m_error.release().leakRef()); |
110 m_state = Invoked; | 110 m_state = Invoked; |
111 break; | 111 break; |
112 case Pending: | 112 case Pending: |
113 m_successCallback = successCallback; | 113 m_successCallback = successCallback; |
114 m_errorCallback = errorCallback; | 114 m_errorCallback = errorCallback; |
115 break; | 115 break; |
116 case Invoked: | 116 case Invoked: |
117 break; | 117 break; |
118 default: | 118 default: |
119 ASSERT_NOT_REACHED(); | 119 ASSERT_NOT_REACHED(); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 } // namespace WebCore | 123 } // namespace WebCore |
OLD | NEW |