| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (MemoryCoordinator::isLowEndDevice()) { | 82 if (MemoryCoordinator::isLowEndDevice()) { |
| 83 resolver->reject(DOMException::create( | 83 resolver->reject(DOMException::create( |
| 84 NotSupportedError, | 84 NotSupportedError, |
| 85 "Availability monitoring is not supported on this device.")); | 85 "Availability monitoring is not supported on this device.")); |
| 86 return promise; | 86 return promise; |
| 87 } | 87 } |
| 88 | 88 |
| 89 int id; | 89 int id; |
| 90 do { | 90 do { |
| 91 id = getExecutionContext()->circularSequentialID(); | 91 id = getExecutionContext()->circularSequentialID(); |
| 92 } while ( | 92 } while (!m_availabilityCallbacks |
| 93 !m_availabilityCallbacks | 93 .insert(id, |
| 94 .insert(id, TraceWrapperMember<RemotePlaybackAvailabilityCallback>( | 94 TraceWrapperMember<RemotePlaybackAvailabilityCallback>( |
| 95 this, callback)) | 95 this, callback)) |
| 96 .isNewEntry); | 96 .isNewEntry); |
| 97 | 97 |
| 98 // Report the current availability via the callback. | 98 // Report the current availability via the callback. |
| 99 // TODO(yuryu): Wrapping notifyInitialAvailability with WTF::Closure as | 99 // TODO(yuryu): Wrapping notifyInitialAvailability with WTF::Closure as |
| 100 // InspectorInstrumentation requires a globally unique pointer to track tasks. | 100 // InspectorInstrumentation requires a globally unique pointer to track tasks. |
| 101 // We can remove the wrapper if InspectorInstrumentation returns a task id. | 101 // We can remove the wrapper if InspectorInstrumentation returns a task id. |
| 102 std::unique_ptr<WTF::Closure> task = WTF::bind( | 102 std::unique_ptr<WTF::Closure> task = WTF::bind( |
| 103 &RemotePlayback::notifyInitialAvailability, wrapPersistent(this), id); | 103 &RemotePlayback::notifyInitialAvailability, wrapPersistent(this), id); |
| 104 InspectorInstrumentation::asyncTaskScheduled( | 104 InspectorInstrumentation::asyncTaskScheduled( |
| 105 getExecutionContext(), "watchAvailabilityCallback", task.get()); | 105 getExecutionContext(), "watchAvailabilityCallback", task.get()); |
| 106 TaskRunnerHelper::get(TaskType::MediaElementEvent, getExecutionContext()) | 106 TaskRunnerHelper::get(TaskType::MediaElementEvent, getExecutionContext()) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 314 } |
| 315 | 315 |
| 316 DEFINE_TRACE_WRAPPERS(RemotePlayback) { | 316 DEFINE_TRACE_WRAPPERS(RemotePlayback) { |
| 317 for (auto callback : m_availabilityCallbacks.values()) { | 317 for (auto callback : m_availabilityCallbacks.values()) { |
| 318 visitor->traceWrappers(callback); | 318 visitor->traceWrappers(callback); |
| 319 } | 319 } |
| 320 EventTargetWithInlineData::traceWrappers(visitor); | 320 EventTargetWithInlineData::traceWrappers(visitor); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace blink | 323 } // namespace blink |
| OLD | NEW |