| 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" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/dom/ExecutionContextTask.h" | 12 #include "core/dom/ExecutionContextTask.h" |
| 13 #include "core/events/Event.h" | 13 #include "core/events/Event.h" |
| 14 #include "core/html/HTMLMediaElement.h" | 14 #include "core/html/HTMLMediaElement.h" |
| 15 #include "modules/EventTargetModules.h" | 15 #include "modules/EventTargetModules.h" |
| 16 #include "platform/MemoryCoordinator.h" |
| 16 #include "platform/UserGestureIndicator.h" | 17 #include "platform/UserGestureIndicator.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const AtomicString& remotePlaybackStateToString(WebRemotePlaybackState state) { | 23 const AtomicString& remotePlaybackStateToString(WebRemotePlaybackState state) { |
| 23 DEFINE_STATIC_LOCAL(const AtomicString, connectingValue, ("connecting")); | 24 DEFINE_STATIC_LOCAL(const AtomicString, connectingValue, ("connecting")); |
| 24 DEFINE_STATIC_LOCAL(const AtomicString, connectedValue, ("connected")); | 25 DEFINE_STATIC_LOCAL(const AtomicString, connectedValue, ("connected")); |
| 25 DEFINE_STATIC_LOCAL(const AtomicString, disconnectedValue, ("disconnected")); | 26 DEFINE_STATIC_LOCAL(const AtomicString, disconnectedValue, ("disconnected")); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 RemotePlaybackAvailabilityCallback* callback) { | 66 RemotePlaybackAvailabilityCallback* callback) { |
| 66 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 67 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 67 ScriptPromise promise = resolver->promise(); | 68 ScriptPromise promise = resolver->promise(); |
| 68 | 69 |
| 69 if (m_mediaElement->fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) { | 70 if (m_mediaElement->fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) { |
| 70 resolver->reject(DOMException::create( | 71 resolver->reject(DOMException::create( |
| 71 InvalidStateError, "disableRemotePlayback attribute is present.")); | 72 InvalidStateError, "disableRemotePlayback attribute is present.")); |
| 72 return promise; | 73 return promise; |
| 73 } | 74 } |
| 74 | 75 |
| 75 // TODO(avayvod): implement steps 4 and 5 of the algorithm. | 76 if (MemoryCoordinator::isLowEndDevice()) { |
| 76 // https://crbug.com/655233 | 77 resolver->reject(DOMException::create( |
| 78 NotSupportedError, |
| 79 "Availability monitoring is not supported on this device.")); |
| 80 return promise; |
| 81 } |
| 82 |
| 77 int id; | 83 int id; |
| 78 do { | 84 do { |
| 79 id = getExecutionContext()->circularSequentialID(); | 85 id = getExecutionContext()->circularSequentialID(); |
| 80 } while (!m_availabilityCallbacks | 86 } while (!m_availabilityCallbacks |
| 81 .add(id, TraceWrapperMember<RemotePlaybackAvailabilityCallback>( | 87 .add(id, TraceWrapperMember<RemotePlaybackAvailabilityCallback>( |
| 82 this, callback)) | 88 this, callback)) |
| 83 .isNewEntry); | 89 .isNewEntry); |
| 84 | 90 |
| 85 // Report the current availability via the callback. | 91 // Report the current availability via the callback. |
| 86 getExecutionContext()->postTask( | 92 getExecutionContext()->postTask( |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 307 } |
| 302 | 308 |
| 303 DEFINE_TRACE_WRAPPERS(RemotePlayback) { | 309 DEFINE_TRACE_WRAPPERS(RemotePlayback) { |
| 304 for (auto callback : m_availabilityCallbacks.values()) { | 310 for (auto callback : m_availabilityCallbacks.values()) { |
| 305 visitor->traceWrappers(callback); | 311 visitor->traceWrappers(callback); |
| 306 } | 312 } |
| 307 EventTargetWithInlineData::traceWrappers(visitor); | 313 EventTargetWithInlineData::traceWrappers(visitor); |
| 308 } | 314 } |
| 309 | 315 |
| 310 } // namespace blink | 316 } // namespace blink |
| OLD | NEW |