| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/remoteplayback/RemotePlayback.h" | 5 #include "modules/remoteplayback/RemotePlayback.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" | 8 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" |
| 9 #include "core/HTMLNames.h" | 9 #include "core/HTMLNames.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return hasEventListeners() || !m_availabilityCallbacks.isEmpty() || | 195 return hasEventListeners() || !m_availabilityCallbacks.isEmpty() || |
| 196 m_promptPromiseResolver; | 196 m_promptPromiseResolver; |
| 197 } | 197 } |
| 198 | 198 |
| 199 void RemotePlayback::notifyInitialAvailability(int callbackId) { | 199 void RemotePlayback::notifyInitialAvailability(int callbackId) { |
| 200 // May not find the callback if the website cancels it fast enough. | 200 // May not find the callback if the website cancels it fast enough. |
| 201 auto iter = m_availabilityCallbacks.find(callbackId); | 201 auto iter = m_availabilityCallbacks.find(callbackId); |
| 202 if (iter == m_availabilityCallbacks.end()) | 202 if (iter == m_availabilityCallbacks.end()) |
| 203 return; | 203 return; |
| 204 | 204 |
| 205 iter->value->call(m_scriptState.get(), this, m_availability); | 205 iter->value->call(this, m_availability); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void RemotePlayback::stateChanged(WebRemotePlaybackState state) { | 208 void RemotePlayback::stateChanged(WebRemotePlaybackState state) { |
| 209 // We may get a "disconnected" state change while in the "disconnected" | 209 // We may get a "disconnected" state change while in the "disconnected" |
| 210 // state if initiated connection fails. So cleanup the promise resolvers | 210 // state if initiated connection fails. So cleanup the promise resolvers |
| 211 // before checking if anything changed. | 211 // before checking if anything changed. |
| 212 // TODO(avayvod): cleanup this logic when we implementing the "connecting" | 212 // TODO(avayvod): cleanup this logic when we implementing the "connecting" |
| 213 // state. | 213 // state. |
| 214 if (m_promptPromiseResolver) { | 214 if (m_promptPromiseResolver) { |
| 215 if (state != WebRemotePlaybackState::Disconnected) | 215 if (state != WebRemotePlaybackState::Disconnected) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 236 break; | 236 break; |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 void RemotePlayback::availabilityChanged(bool available) { | 240 void RemotePlayback::availabilityChanged(bool available) { |
| 241 if (m_availability == available) | 241 if (m_availability == available) |
| 242 return; | 242 return; |
| 243 | 243 |
| 244 m_availability = available; | 244 m_availability = available; |
| 245 for (auto& callback : m_availabilityCallbacks.values()) | 245 for (auto& callback : m_availabilityCallbacks.values()) |
| 246 callback->call(m_scriptState.get(), this, m_availability); | 246 callback->call(this, m_availability); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void RemotePlayback::promptCancelled() { | 249 void RemotePlayback::promptCancelled() { |
| 250 if (!m_promptPromiseResolver) | 250 if (!m_promptPromiseResolver) |
| 251 return; | 251 return; |
| 252 | 252 |
| 253 m_promptPromiseResolver->reject( | 253 m_promptPromiseResolver->reject( |
| 254 DOMException::create(NotAllowedError, "The prompt was dismissed.")); | 254 DOMException::create(NotAllowedError, "The prompt was dismissed.")); |
| 255 m_promptPromiseResolver = nullptr; | 255 m_promptPromiseResolver = nullptr; |
| 256 } | 256 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 282 } | 282 } |
| 283 | 283 |
| 284 DEFINE_TRACE_WRAPPERS(RemotePlayback) { | 284 DEFINE_TRACE_WRAPPERS(RemotePlayback) { |
| 285 for (auto callback : m_availabilityCallbacks.values()) { | 285 for (auto callback : m_availabilityCallbacks.values()) { |
| 286 visitor->traceWrappers(callback); | 286 visitor->traceWrappers(callback); |
| 287 } | 287 } |
| 288 EventTargetWithInlineData::traceWrappers(visitor); | 288 EventTargetWithInlineData::traceWrappers(visitor); |
| 289 } | 289 } |
| 290 | 290 |
| 291 } // namespace blink | 291 } // namespace blink |
| OLD | NEW |