OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/remoteplayback/AvailabilityCallbackWrapper.h" |
| 6 |
| 7 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" |
| 8 #include "modules/remoteplayback/RemotePlayback.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 AvailabilityCallbackWrapper::AvailabilityCallbackWrapper( |
| 13 RemotePlaybackAvailabilityCallback* callback) |
| 14 : bindings_cb_(this, callback) {} |
| 15 |
| 16 AvailabilityCallbackWrapper::AvailabilityCallbackWrapper( |
| 17 std::unique_ptr<WTF::Closure> callback) |
| 18 : bindings_cb_(nullptr, nullptr), internal_cb_(std::move(callback)) {} |
| 19 |
| 20 void AvailabilityCallbackWrapper::Run(RemotePlayback* remote_playback, |
| 21 bool new_availability) { |
| 22 if (internal_cb_) { |
| 23 DCHECK(!bindings_cb_); |
| 24 (*internal_cb_.get())(); |
| 25 return; |
| 26 } |
| 27 |
| 28 bindings_cb_->call(remote_playback, new_availability); |
| 29 } |
| 30 |
| 31 DEFINE_TRACE(AvailabilityCallbackWrapper) { |
| 32 visitor->Trace(bindings_cb_); |
| 33 } |
| 34 |
| 35 DEFINE_TRACE_WRAPPERS(AvailabilityCallbackWrapper) { |
| 36 visitor->TraceWrappers(bindings_cb_); |
| 37 } |
| 38 |
| 39 } // namespace blink |
OLD | NEW |