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/wrappable.h" | 5 #include "gin/wrappable.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "gin/per_isolate_data.h" | 8 #include "gin/per_isolate_data.h" |
9 | 9 |
10 namespace gin { | 10 namespace gin { |
(...skipping 16 matching lines...) Expand all Loading... | |
27 Wrappable* wrappable = data.GetParameter(); | 27 Wrappable* wrappable = data.GetParameter(); |
28 wrappable->wrapper_.Reset(); | 28 wrappable->wrapper_.Reset(); |
29 wrappable->Release(); // Balanced in Wrappable::ConfigureWrapper. | 29 wrappable->Release(); // Balanced in Wrappable::ConfigureWrapper. |
30 } | 30 } |
31 | 31 |
32 v8::Handle<v8::Object> Wrappable::CreateWrapper(v8::Isolate* isolate) { | 32 v8::Handle<v8::Object> Wrappable::CreateWrapper(v8::Isolate* isolate) { |
33 WrapperInfo* info = GetWrapperInfo(); | 33 WrapperInfo* info = GetWrapperInfo(); |
34 PerIsolateData* data = PerIsolateData::From(isolate); | 34 PerIsolateData* data = PerIsolateData::From(isolate); |
35 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(info); | 35 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(info); |
36 CHECK(!templ.IsEmpty()); // Don't forget to register an object template. | 36 CHECK(!templ.IsEmpty()); // Don't forget to register an object template. |
37 CHECK(templ->InternalFieldCount() == kNumberOfInternalFields); | 37 CHECK_EQ(kNumberOfInternalFields, templ->InternalFieldCount()); |
Aaron Boodman
2013/12/04 07:05:29
So that the mismatch is printed in the logs if thi
abarth-chromium
2013/12/04 16:27:55
Thanks for fixing these. My Chromium idioms are a
| |
38 v8::Handle<v8::Object> wrapper = templ->NewInstance(); | 38 v8::Handle<v8::Object> wrapper = templ->NewInstance(); |
39 wrapper->SetAlignedPointerInInternalField(kWrapperInfoIndex, info); | 39 wrapper->SetAlignedPointerInInternalField(kWrapperInfoIndex, info); |
40 wrapper->SetAlignedPointerInInternalField(kEncodedValueIndex, this); | 40 wrapper->SetAlignedPointerInInternalField(kEncodedValueIndex, this); |
41 wrapper_.Reset(isolate, wrapper); | 41 wrapper_.Reset(isolate, wrapper); |
42 AddRef(); // Balanced in Wrappable::WeakCallback. | 42 AddRef(); // Balanced in Wrappable::WeakCallback. |
43 wrapper_.SetWeak(this, WeakCallback); | 43 wrapper_.SetWeak(this, WeakCallback); |
44 return wrapper; | 44 return wrapper; |
45 } | 45 } |
46 | 46 |
47 v8::Handle<v8::Value> Converter<Wrappable*>::ToV8(v8::Isolate* isolate, | 47 v8::Handle<v8::Value> Converter<Wrappable*>::ToV8(v8::Isolate* isolate, |
(...skipping 12 matching lines...) Expand all Loading... | |
60 if (!info) | 60 if (!info) |
61 return false; | 61 return false; |
62 void* pointer = obj->GetAlignedPointerFromInternalField(kEncodedValueIndex); | 62 void* pointer = obj->GetAlignedPointerFromInternalField(kEncodedValueIndex); |
63 Wrappable* wrappable = static_cast<Wrappable*>(pointer); | 63 Wrappable* wrappable = static_cast<Wrappable*>(pointer); |
64 CHECK(wrappable->GetWrapperInfo() == info); // Security check for cast above. | 64 CHECK(wrappable->GetWrapperInfo() == info); // Security check for cast above. |
65 *out = wrappable; | 65 *out = wrappable; |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 } // namespace gin | 69 } // namespace gin |
OLD | NEW |