Shaka Player Embedded
callback.cc
Go to the documentation of this file.
1 // Copyright 2016 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/mapping/callback.h"
16 
17 #include "src/memory/heap_tracer.h"
18 
19 namespace shaka {
20 
23 
24 Callback::Callback(const Callback&) = default;
25 Callback::Callback(Callback&&) = default;
26 Callback& Callback::operator=(const Callback&) = default;
28 
29 bool Callback::TryConvert(Handle<JsValue> given) {
31  return false;
32  callback_ = UnsafeJsCast<JsFunction>(given);
33  return true;
34 }
35 
36 ReturnVal<JsValue> Callback::ToJsValue() const {
37  return callback_.value();
38 }
39 
40 void Callback::Trace(memory::HeapTracer* tracer) const {
41  tracer->Trace(&callback_);
42 }
43 
44 } // namespace shaka
ReturnVal< JsValue > value() const
Definition: weak_js_ptr.h:97
Callback & operator=(const Callback &)
ReturnVal< JsValue > ToJsValue() const override
Definition: callback.cc:36
void Trace(const Traceable *ptr)
Definition: heap_tracer.cc:43
proto::ValueType GetValueType(Handle< JsValue > value)
Definition: js_wrappers.cc:329
void Trace(memory::HeapTracer *tracer) const override
Definition: callback.cc:40
bool TryConvert(Handle< JsValue > given) override
Definition: callback.cc:29
~Callback() override
Definition: callback.cc:22