#ifndef MOJO_BINDINGS_JS_HANDLE_H_
#define MOJO_BINDINGS_JS_HANDLE_H_
#include "gin/converter.h"
#include "gin/handle.h"
#include "gin/wrappable.h"
#include "mojo/public/cpp/system/core.h"
namespace gin {
class HandleWrapper : public gin::Wrappable<HandleWrapper> {
public:
static gin::WrapperInfo kWrapperInfo;
static gin::Handle<HandleWrapper> Create(v8::Isolate* isolate,
MojoHandle handle) {
return gin::CreateHandle(isolate, new HandleWrapper(handle));
}
mojo::Handle get() const { return handle_.get(); }
mojo::Handle release() { return handle_.release(); }
void Close() { handle_.reset(); }
protected:
HandleWrapper(MojoHandle handle);
virtual ~HandleWrapper();
mojo::ScopedHandle handle_;
};
template<>
struct Converter<mojo::Handle> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
const mojo::Handle& val);
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
mojo::Handle* out);
};
}
#endif