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

Side by Side Diff: content/renderer/pepper/v8_var_converter.cc

Issue 301883002: Should provide creation context and isolate for WebArrayConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed bad coding style Created 6 years, 6 months 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 | « no previous file | content/renderer/skia_benchmarking_extension.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/renderer/pepper/v8_var_converter.h" 5 #include "content/renderer/pepper/v8_var_converter.h"
6 6
7 #include <map> 7 #include <map>
8 #include <stack> 8 #include <stack>
9 #include <string> 9 #include <string>
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 case PP_VARTYPE_ARRAY_BUFFER: { 134 case PP_VARTYPE_ARRAY_BUFFER: {
135 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(var); 135 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(var);
136 if (!buffer) { 136 if (!buffer) {
137 NOTREACHED(); 137 NOTREACHED();
138 result->Clear(); 138 result->Clear();
139 return false; 139 return false;
140 } 140 }
141 HostArrayBufferVar* host_buffer = 141 HostArrayBufferVar* host_buffer =
142 static_cast<HostArrayBufferVar*>(buffer); 142 static_cast<HostArrayBufferVar*>(buffer);
143 *result = blink::WebArrayBufferConverter::toV8Value( 143 *result = blink::WebArrayBufferConverter::toV8Value(
144 &host_buffer->webkit_buffer()); 144 &host_buffer->webkit_buffer(), context->Global(), isolate);
145 break; 145 break;
146 } 146 }
147 case PP_VARTYPE_ARRAY: 147 case PP_VARTYPE_ARRAY:
148 *result = v8::Array::New(isolate); 148 *result = v8::Array::New(isolate);
149 break; 149 break;
150 case PP_VARTYPE_DICTIONARY: 150 case PP_VARTYPE_DICTIONARY:
151 *result = v8::Object::New(isolate); 151 *result = v8::Object::New(isolate);
152 break; 152 break;
153 case PP_VARTYPE_OBJECT: 153 case PP_VARTYPE_OBJECT:
154 result->Clear(); 154 result->Clear();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 *result = PP_MakeInt32(val->ToInt32()->Value()); 207 *result = PP_MakeInt32(val->ToInt32()->Value());
208 } else if (val->IsNumber() || val->IsNumberObject()) { 208 } else if (val->IsNumber() || val->IsNumberObject()) {
209 *result = PP_MakeDouble(val->ToNumber()->Value()); 209 *result = PP_MakeDouble(val->ToNumber()->Value());
210 } else if (val->IsString() || val->IsStringObject()) { 210 } else if (val->IsString() || val->IsStringObject()) {
211 v8::String::Utf8Value utf8(val->ToString()); 211 v8::String::Utf8Value utf8(val->ToString());
212 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length())); 212 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length()));
213 } else if (val->IsArray()) { 213 } else if (val->IsArray()) {
214 *result = (new ArrayVar())->GetPPVar(); 214 *result = (new ArrayVar())->GetPPVar();
215 } else if (val->IsObject()) { 215 } else if (val->IsObject()) {
216 scoped_ptr<blink::WebArrayBuffer> web_array_buffer( 216 scoped_ptr<blink::WebArrayBuffer> web_array_buffer(
217 blink::WebArrayBufferConverter::createFromV8Value(val)); 217 blink::WebArrayBufferConverter::createFromV8Value(
218 val, context->GetIsolate()));
218 if (web_array_buffer.get()) { 219 if (web_array_buffer.get()) {
219 scoped_refptr<HostArrayBufferVar> buffer_var( 220 scoped_refptr<HostArrayBufferVar> buffer_var(
220 new HostArrayBufferVar(*web_array_buffer)); 221 new HostArrayBufferVar(*web_array_buffer));
221 *result = buffer_var->GetPPVar(); 222 *result = buffer_var->GetPPVar();
222 } else { 223 } else {
223 bool was_resource; 224 bool was_resource;
224 if (!resource_converter->FromV8Value( 225 if (!resource_converter->FromV8Value(
225 val->ToObject(), context, result, &was_resource)) 226 val->ToObject(), context, result, &was_resource))
226 return false; 227 return false;
227 if (!was_resource) { 228 if (!was_resource) {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 std::string(*name_utf8, name_utf8.length()), child_var); 542 std::string(*name_utf8, name_utf8.length()), child_var);
542 DCHECK(success); 543 DCHECK(success);
543 } 544 }
544 } 545 }
545 } 546 }
546 *result_var = root; 547 *result_var = root;
547 return true; 548 return true;
548 } 549 }
549 550
550 } // namespace content 551 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/skia_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698