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

Side by Side Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp

Issue 2475293003: [RemotePlayback] No monitoring on low-end devices (Closed)
Patch Set: Moved to Platform::initialize() Created 4 years 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 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 RemotePlaybackAvailabilityCallback* callback) { 67 RemotePlaybackAvailabilityCallback* callback) {
67 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 68 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
68 ScriptPromise promise = resolver->promise(); 69 ScriptPromise promise = resolver->promise();
69 70
70 if (m_mediaElement->fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) { 71 if (m_mediaElement->fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) {
71 resolver->reject(DOMException::create( 72 resolver->reject(DOMException::create(
72 InvalidStateError, "disableRemotePlayback attribute is present.")); 73 InvalidStateError, "disableRemotePlayback attribute is present."));
73 return promise; 74 return promise;
74 } 75 }
75 76
76 // TODO(avayvod): implement steps 4 and 5 of the algorithm. 77 if (MemoryCoordinator::isLowEndDevice()) {
77 // https://crbug.com/655233 78 resolver->reject(DOMException::create(
79 NotSupportedError,
80 "Availability monitoring is not supported on this device."));
81 return promise;
82 }
83
78 int id; 84 int id;
79 do { 85 do {
80 id = getExecutionContext()->circularSequentialID(); 86 id = getExecutionContext()->circularSequentialID();
81 } while (!m_availabilityCallbacks 87 } while (!m_availabilityCallbacks
82 .add(id, TraceWrapperMember<RemotePlaybackAvailabilityCallback>( 88 .add(id, TraceWrapperMember<RemotePlaybackAvailabilityCallback>(
83 this, callback)) 89 this, callback))
84 .isNewEntry); 90 .isNewEntry);
85 91
86 // Report the current availability via the callback. 92 // Report the current availability via the callback.
87 getExecutionContext()->postTask( 93 getExecutionContext()->postTask(
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 314 }
309 315
310 DEFINE_TRACE_WRAPPERS(RemotePlayback) { 316 DEFINE_TRACE_WRAPPERS(RemotePlayback) {
311 for (auto callback : m_availabilityCallbacks.values()) { 317 for (auto callback : m_availabilityCallbacks.values()) {
312 visitor->traceWrappers(callback); 318 visitor->traceWrappers(callback);
313 } 319 }
314 EventTargetWithInlineData::traceWrappers(visitor); 320 EventTargetWithInlineData::traceWrappers(visitor);
315 } 321 }
316 322
317 } // namespace blink 323 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.idl ('k') | third_party/WebKit/Source/platform/MemoryCoordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698