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

Side by Side Diff: Source/bindings/core/v8/V8Binding.h

Issue 1027593003: bindings: Use Maybe version of v8::String::NewFromUtf8() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // Return a V8 external string that shares the underlying buffer with the given 340 // Return a V8 external string that shares the underlying buffer with the given
341 // WebCore string. The reference counting mechanism is used to keep the 341 // WebCore string. The reference counting mechanism is used to keep the
342 // underlying buffer alive while the string is still live in the V8 engine. 342 // underlying buffer alive while the string is still live in the V8 engine.
343 inline v8::Handle<v8::String> v8String(v8::Isolate* isolate, const String& strin g) 343 inline v8::Handle<v8::String> v8String(v8::Isolate* isolate, const String& strin g)
344 { 344 {
345 if (string.isNull()) 345 if (string.isNull())
346 return v8::String::Empty(isolate); 346 return v8::String::Empty(isolate);
347 return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(stri ng.impl(), isolate); 347 return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(stri ng.impl(), isolate);
348 } 348 }
349 349
350 inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* s tr) 350 inline v8::Local<v8::String> v8NormalString(v8::Isolate* isolate, const char* st r, int length = -1)
bashi 2015/03/20 08:16:44 I think we can remove this. When length is -1, v8:
351 { 351 {
352 ASSERT(isolate); 352 ASSERT(isolate);
353 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , strlen(str)); 353 v8::Local<v8::String> value;
354 if (LIKELY(v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal, length).ToLocal(&value)))
bashi 2015/03/20 08:16:44 I added LIKELY() because according to the v8.h, Ne
haraken 2015/03/20 09:46:08 v8NormalString is performance-sensitive, so LIKELY
355 return value;
356 return v8::String::Empty(isolate);
354 } 357 }
355 358
356 inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* s tr, size_t length) 359 inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* s tr, int length = -1)
357 { 360 {
358 ASSERT(isolate); 361 ASSERT(isolate);
359 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , length); 362 v8::Local<v8::String> value;
363 if (LIKELY(v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kInterna lized, length).ToLocal(&value)))
364 return value;
365 return v8::String::Empty(isolate);
360 } 366 }
361 367
362 inline v8::Handle<v8::Value> v8Undefined() 368 inline v8::Handle<v8::Value> v8Undefined()
363 { 369 {
364 return v8::Handle<v8::Value>(); 370 return v8::Handle<v8::Value>();
365 } 371 }
366 372
367 // Conversion flags, used in toIntXX/toUIntXX. 373 // Conversion flags, used in toIntXX/toUIntXX.
368 enum IntegerConversionConfiguration { 374 enum IntegerConversionConfiguration {
369 NormalConversion, 375 NormalConversion,
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate*, ExecutionContext*, v8::Handle<v8::Function>); 973 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate*, ExecutionContext*, v8::Handle<v8::Function>);
968 974
969 // Callback functions used by generated code. 975 // Callback functions used by generated code.
970 void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::Pr opertyCallbackInfo<v8::Value>&); 976 void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::Pr opertyCallbackInfo<v8::Value>&);
971 977
972 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); 978 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*);
973 979
974 } // namespace blink 980 } // namespace blink
975 981
976 #endif // V8Binding_h 982 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptValueSerializer.cpp ('k') | Source/bindings/core/v8/V8DOMConfiguration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698