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

Side by Side Diff: gin/converter.cc

Issue 83143002: [Mojo] Improve JavaScript API for MojoReadMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup Created 7 years, 1 month 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/converter.h ('k') | gin/modules/module_registry.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/converter.h" 5 #include "gin/converter.h"
6 6
7 #include "v8/include/v8.h" 7 #include "v8/include/v8.h"
8 8
9 using v8::ArrayBuffer;
9 using v8::Boolean; 10 using v8::Boolean;
10 using v8::External; 11 using v8::External;
11 using v8::Function; 12 using v8::Function;
12 using v8::Handle; 13 using v8::Handle;
13 using v8::Integer; 14 using v8::Integer;
14 using v8::Isolate; 15 using v8::Isolate;
15 using v8::Number; 16 using v8::Number;
16 using v8::Object; 17 using v8::Object;
17 using v8::String; 18 using v8::String;
18 using v8::Value; 19 using v8::Value;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 119 }
119 120
120 bool Converter<Handle<Object> >::FromV8(Handle<Value> val, 121 bool Converter<Handle<Object> >::FromV8(Handle<Value> val,
121 Handle<Object>* out) { 122 Handle<Object>* out) {
122 if (!val->IsObject()) 123 if (!val->IsObject())
123 return false; 124 return false;
124 *out = Handle<Object>::Cast(val); 125 *out = Handle<Object>::Cast(val);
125 return true; 126 return true;
126 } 127 }
127 128
129 Handle<Value> Converter<Handle<ArrayBuffer> >::ToV8(v8::Isolate* isolate,
130 Handle<ArrayBuffer> val) {
131 return val.As<Value>();
132 }
133
134 bool Converter<Handle<ArrayBuffer> >::FromV8(Handle<Value> val,
135 Handle<ArrayBuffer>* out) {
136 if (!val->IsArrayBuffer())
137 return false;
138 *out = Handle<ArrayBuffer>::Cast(val);
139 return true;
140 }
141
128 Handle<Value> Converter<Handle<External> >::ToV8(v8::Isolate* isolate, 142 Handle<Value> Converter<Handle<External> >::ToV8(v8::Isolate* isolate,
129 Handle<External> val) { 143 Handle<External> val) {
130 return val.As<Value>(); 144 return val.As<Value>();
131 } 145 }
132 146
133 bool Converter<Handle<External> >::FromV8(Handle<Value> val, 147 bool Converter<Handle<External> >::FromV8(Handle<Value> val,
134 Handle<External>* out) { 148 Handle<External>* out) {
135 if (!val->IsExternal()) 149 if (!val->IsExternal())
136 return false; 150 return false;
137 *out = Handle<External>::Cast(val); 151 *out = Handle<External>::Cast(val);
(...skipping 14 matching lines...) Expand all
152 v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate, 166 v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate,
153 const std::string& val) { 167 const std::string& val) {
154 return String::NewFromUtf8(isolate, 168 return String::NewFromUtf8(isolate,
155 val.data(), 169 val.data(),
156 String::kInternalizedString, 170 String::kInternalizedString,
157 static_cast<uint32_t>(val.length())); 171 static_cast<uint32_t>(val.length()));
158 } 172 }
159 173
160 174
161 } // namespace gin 175 } // namespace gin
OLDNEW
« no previous file with comments | « gin/converter.h ('k') | gin/modules/module_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698