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

Side by Side Diff: Source/bindings/core/v8/V8ObjectBuilder.cpp

Issue 1029093003: [WIP] IDL: Add limited serializer support and use for RTCIceCandidate (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use V8ObjectBuilder in modules/crypto 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "bindings/core/v8/V8ObjectBuilder.h"
7
8 #include "bindings/core/v8/V8Binding.h"
9
10 namespace blink {
11
12 V8ObjectBuilder::V8ObjectBuilder(v8::Isolate* isolate)
13 : m_isolate(isolate)
14 , m_object(v8::Object::New(isolate))
15 {
16 }
17
18 ScriptValue V8ObjectBuilder::scriptValue() const
19 {
20 return ScriptValue(ScriptState::current(m_isolate), m_object);
21 }
22
23 void V8ObjectBuilder::add(String name, const ScriptValue& value)
24 {
25 add(name, value.v8Value());
26 }
27
28 void V8ObjectBuilder::addNull(String name)
29 {
30 add(name, v8::Null(m_isolate));
31 }
32
33 void V8ObjectBuilder::addBoolean(String name, bool value)
34 {
35 add(name, value ? v8::True(m_isolate) : v8::False(m_isolate));
36 }
37
38 void V8ObjectBuilder::addNumber(String name, double value)
39 {
40 add(name, v8::Number::New(m_isolate, value));
41 }
42
43 void V8ObjectBuilder::addString(String name, String value)
44 {
45 add(name, v8String(m_isolate, value));
46 }
47
48 V8ObjectBuilder V8ObjectBuilder::addObject(String name)
bashi 2015/03/24 00:49:04 This looks different from other add methds() so ad
Jens Widell 2015/03/24 07:10:03 Yes, it's a bit unusual. Would probably be better
49 {
50 V8ObjectBuilder builder(m_isolate);
51 add(name, builder.v8Value());
52 return builder;
53 }
54
55 void V8ObjectBuilder::add(String name, v8::Local<v8::Value> value)
56 {
57 m_object->Set(m_isolate->GetCurrentContext(), v8String(m_isolate, name), val ue);
58 }
59
60 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698