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 #ifndef AvailabilityCallbackWrapper_h |
| 6 #define AvailabilityCallbackWrapper_h |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "bindings/core/v8/TraceWrapperMember.h" |
| 12 #include "platform/heap/GarbageCollected.h" |
| 13 #include "platform/wtf/Compiler.h" |
| 14 #include "platform/wtf/Functional.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 class RemotePlaybackAvailabilityCallback; |
| 19 class RemotePlayback; |
| 20 |
| 21 // Wraps either a WTF::Closure or RemotePlaybackAvailabilityCallback object |
| 22 // to be kept in the RemotePlayback's |availability_callbacks_| map. |
| 23 class AvailabilityCallbackWrapper final |
| 24 : public GarbageCollectedFinalized<AvailabilityCallbackWrapper>, |
| 25 public TraceWrapperBase { |
| 26 WTF_MAKE_NONCOPYABLE(AvailabilityCallbackWrapper); |
| 27 |
| 28 public: |
| 29 explicit AvailabilityCallbackWrapper(RemotePlaybackAvailabilityCallback*); |
| 30 explicit AvailabilityCallbackWrapper(std::unique_ptr<WTF::Closure>); |
| 31 ~AvailabilityCallbackWrapper() = default; |
| 32 |
| 33 void Run(RemotePlayback*, bool new_availability); |
| 34 |
| 35 DECLARE_VIRTUAL_TRACE(); |
| 36 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
| 37 |
| 38 private: |
| 39 // Only one of these callbacks must be set. |
| 40 TraceWrapperMember<RemotePlaybackAvailabilityCallback> bindings_cb_; |
| 41 std::unique_ptr<WTF::Closure> internal_cb_; |
| 42 }; |
| 43 |
| 44 } // namespace blink |
| 45 |
| 46 #endif // AvailabilityCallbackWrapper_h |
OLD | NEW |