OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gin/per_isolate_data.h" | 5 #include "gin/per_isolate_data.h" |
6 | 6 |
7 using v8::Eternal; | 7 using v8::Eternal; |
8 using v8::Handle; | 8 using v8::Handle; |
9 using v8::Isolate; | 9 using v8::Isolate; |
10 using v8::Local; | 10 using v8::Local; |
11 using v8::Object; | 11 using v8::Object; |
12 using v8::ObjectTemplate; | 12 using v8::ObjectTemplate; |
13 | 13 |
14 namespace gin { | 14 namespace gin { |
15 | 15 |
16 PerIsolateData::PerIsolateData(Isolate* isolate) | 16 PerIsolateData::PerIsolateData(Isolate* isolate) |
17 : isolate_(isolate) { | 17 : isolate_(isolate) { |
18 isolate_->SetData(this); | 18 isolate_->SetData(this); |
19 } | 19 } |
20 | 20 |
21 PerIsolateData::~PerIsolateData() { | 21 PerIsolateData::~PerIsolateData() { |
22 } | 22 } |
23 | 23 |
24 PerIsolateData* PerIsolateData::From(Isolate* isolate) { | 24 PerIsolateData* PerIsolateData::From(Isolate* isolate) { |
25 return static_cast<PerIsolateData*>(isolate->GetData()); | 25 return static_cast<PerIsolateData*>(isolate->GetData()); |
26 } | 26 } |
27 | 27 |
28 void PerIsolateData::RegisterObjectTemplate( | 28 void PerIsolateData::RegisterObjectTemplate(WrapperInfo* info, |
29 WrapperInfo* info, Local<ObjectTemplate> object_template) { | 29 Local<ObjectTemplate> templ) { |
30 object_templates_[info] = Eternal<ObjectTemplate>(isolate_, object_template); | 30 object_templates_[info] = Eternal<ObjectTemplate>(isolate_, templ); |
31 } | |
32 | |
33 bool PerIsolateData::GetObjectTemplate(WrapperInfo* info, | |
Aaron Boodman
2013/11/11 19:01:08
You can avoid the two return values by having this
abarth-chromium
2013/11/11 20:17:42
Ok.
| |
34 Local<ObjectTemplate>* out) { | |
35 ObjectTemplateMap::iterator it = object_templates_.find(info); | |
36 if (it == object_templates_.end()) | |
37 return false; | |
38 *out = it->second.Get(isolate_); | |
39 return true; | |
31 } | 40 } |
32 | 41 |
33 } // namespace gin | 42 } // namespace gin |
OLD | NEW |