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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ToV8.h

Issue 2725883002: bindings: Add ToV8() overload for HeapVector<std::pair<String, T>>. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ToV8.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ToV8.h b/third_party/WebKit/Source/bindings/core/v8/ToV8.h
index 0f0cc79c21b58b35b9fafbf8314a9da9d1e4af1b..76aa60c08e36ed2c455bc6b6f7b11c441519079b 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ToV8.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ToV8.h
@@ -260,6 +260,27 @@ inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value,
return object;
}
+template <typename T>
+inline v8::Local<v8::Value> ToV8(const HeapVector<std::pair<String, T>>& value,
+ v8::Local<v8::Object> creationContext,
+ v8::Isolate* isolate) {
+ v8::Local<v8::Object> object;
+ {
+ v8::Context::Scope contextScope(creationContext->CreationContext());
+ object = v8::Object::New(isolate);
+ }
+ for (unsigned i = 0; i < value.size(); ++i) {
+ v8::Local<v8::Value> v8Value = ToV8(value[i].second, object, isolate);
+ if (v8Value.IsEmpty())
+ v8Value = v8::Undefined(isolate);
+ if (!v8CallBoolean(object->CreateDataProperty(
+ isolate->GetCurrentContext(), v8String(isolate, value[i].first),
+ v8Value)))
+ return v8::Local<v8::Value>();
+ }
+ return object;
+}
+
template <typename Sequence>
inline v8::Local<v8::Value> toV8SequenceInternal(
const Sequence& sequence,
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698