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

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

Issue 744723002: remove some calls to to-be-deprecated v8::Value::To* functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 PP_Instance instance, 192 PP_Instance instance,
193 V8VarConverter::AllowObjectVars object_vars_allowed, 193 V8VarConverter::AllowObjectVars object_vars_allowed,
194 PP_Var* result, 194 PP_Var* result,
195 bool* did_create, 195 bool* did_create,
196 HandleVarMap* visited_handles, 196 HandleVarMap* visited_handles,
197 ParentHandleSet* parent_handles, 197 ParentHandleSet* parent_handles,
198 ResourceConverter* resource_converter) { 198 ResourceConverter* resource_converter) {
199 CHECK(!val.IsEmpty()); 199 CHECK(!val.IsEmpty());
200 *did_create = false; 200 *did_create = false;
201 201
202 v8::Isolate* isolate = context->GetIsolate();
202 // Even though every v8 string primitive encountered will be a unique object, 203 // Even though every v8 string primitive encountered will be a unique object,
203 // we still add them to |visited_handles| so that the corresponding string 204 // we still add them to |visited_handles| so that the corresponding string
204 // PP_Var created will be properly refcounted. 205 // PP_Var created will be properly refcounted.
205 if (val->IsObject() || val->IsString()) { 206 if (val->IsObject() || val->IsString()) {
206 if (parent_handles->count(HashedHandle(val->ToObject())) != 0) 207 if (parent_handles->count(HashedHandle(val->ToObject(isolate))) != 0)
207 return false; 208 return false;
208 209
209 HandleVarMap::const_iterator it = 210 HandleVarMap::const_iterator it =
210 visited_handles->find(HashedHandle(val->ToObject())); 211 visited_handles->find(HashedHandle(val->ToObject(isolate)));
211 if (it != visited_handles->end()) { 212 if (it != visited_handles->end()) {
212 *result = it->second.get(); 213 *result = it->second.get();
213 return true; 214 return true;
214 } 215 }
215 } 216 }
216 217
217 v8::Isolate* isolate = context->GetIsolate();
218 if (val->IsUndefined()) { 218 if (val->IsUndefined()) {
219 *result = PP_MakeUndefined(); 219 *result = PP_MakeUndefined();
220 } else if (val->IsNull()) { 220 } else if (val->IsNull()) {
221 *result = PP_MakeNull(); 221 *result = PP_MakeNull();
222 } else if (val->IsBoolean() || val->IsBooleanObject()) { 222 } else if (val->IsBoolean() || val->IsBooleanObject()) {
223 *result = PP_MakeBool(PP_FromBool(val->ToBoolean()->Value())); 223 *result = PP_MakeBool(PP_FromBool(val->ToBoolean(isolate)->Value()));
224 } else if (val->IsInt32()) { 224 } else if (val->IsInt32()) {
225 *result = PP_MakeInt32(val->ToInt32()->Value()); 225 *result = PP_MakeInt32(val->ToInt32(isolate)->Value());
226 } else if (val->IsNumber() || val->IsNumberObject()) { 226 } else if (val->IsNumber() || val->IsNumberObject()) {
227 *result = PP_MakeDouble(val->ToNumber()->Value()); 227 *result = PP_MakeDouble(val->ToNumber(isolate)->Value());
228 } else if (val->IsString() || val->IsStringObject()) { 228 } else if (val->IsString() || val->IsStringObject()) {
229 v8::String::Utf8Value utf8(val->ToString()); 229 v8::String::Utf8Value utf8(val->ToString(isolate));
230 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length())); 230 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length()));
231 } else if (val->IsObject()) { 231 } else if (val->IsObject()) {
232 // For any other v8 objects, the conversion happens as follows: 232 // For any other v8 objects, the conversion happens as follows:
233 // 1) If the object is an array buffer, return an ArrayBufferVar. 233 // 1) If the object is an array buffer, return an ArrayBufferVar.
234 // 2) If object vars are allowed, return the object wrapped as a 234 // 2) If object vars are allowed, return the object wrapped as a
235 // V8ObjectVar. This is to maintain backward compatibility with 235 // V8ObjectVar. This is to maintain backward compatibility with
236 // synchronous scripting in Flash. 236 // synchronous scripting in Flash.
237 // 3) If the object is an array, return an ArrayVar. 237 // 3) If the object is an array, return an ArrayVar.
238 // 4) If the object can be converted to a resource, return the ResourceVar. 238 // 4) If the object can be converted to a resource, return the ResourceVar.
239 // 5) Otherwise return a DictionaryVar. 239 // 5) Otherwise return a DictionaryVar.
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 std::string(*name_utf8, name_utf8.length()), child_var); 595 std::string(*name_utf8, name_utf8.length()), child_var);
596 DCHECK(success); 596 DCHECK(success);
597 } 597 }
598 } 598 }
599 } 599 }
600 *result_var = root; 600 *result_var = root;
601 return true; 601 return true;
602 } 602 }
603 603
604 } // namespace content 604 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/message_channel.cc ('k') | extensions/renderer/binding_generating_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698