blob: 56b2c533fb08ca2c7ca86c2f6662a54f51801a89 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gin/per_isolate_data.h"
using v8::Eternal;
using v8::Handle;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::ObjectTemplate;
namespace gin {
PerIsolateData::PerIsolateData(Isolate* isolate)
: isolate_(isolate) {
isolate_->SetData(this);
}
PerIsolateData::~PerIsolateData() {
}
PerIsolateData* PerIsolateData::From(Isolate* isolate) {
return static_cast<PerIsolateData*>(isolate->GetData());
}
void PerIsolateData::SetObjectTemplate(WrapperInfo* info,
Local<ObjectTemplate> templ) {
object_templates_[info] = Eternal<ObjectTemplate>(isolate_, templ);
}
v8::Local<v8::ObjectTemplate> PerIsolateData::GetObjectTemplate(
WrapperInfo* info) {
ObjectTemplateMap::iterator it = object_templates_.find(info);
if (it == object_templates_.end())
return v8::Local<v8::ObjectTemplate>();
return it->second.Get(isolate_);
}
} // namespace gin