Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: gin/wrappable.cc

Issue 89723002: Convert the rest of the functions in core.cc to use CreateFunctionTemplate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase+comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gin/wrappable.h ('k') | gin/wrappable_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
48 Wrappable* val) { 48 Wrappable* val) {
49 if (val->wrapper_.IsEmpty()) 49 if (val->wrapper_.IsEmpty())
50 return val->CreateWrapper(isolate); 50 return val->CreateWrapper(isolate);
51 return v8::Local<v8::Object>::New(isolate, val->wrapper_); 51 return v8::Local<v8::Object>::New(isolate, val->wrapper_);
52 } 52 }
53 53
54 bool Converter<Wrappable*>::FromV8(v8::Handle<v8::Value> val, 54 bool Converter<Wrappable*>::FromV8(v8::Isolate* isolate,
55 Wrappable** out) { 55 v8::Handle<v8::Value> val, Wrappable** out) {
56 if (!val->IsObject()) 56 if (!val->IsObject())
57 return false; 57 return false;
58 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(val); 58 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(val);
59 WrapperInfo* info = WrapperInfo::From(obj); 59 WrapperInfo* info = WrapperInfo::From(obj);
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
OLDNEW
« no previous file with comments | « gin/wrappable.h ('k') | gin/wrappable_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698