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

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

Issue 1031783003: Add V8ObjectBuilder helper and use in modules/crypto/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use "const String&" 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
« no previous file with comments | « Source/bindings/core/v8/Dictionary.cpp ('k') | Source/bindings/core/v8/V8ObjectBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef V8ObjectBuilder_h
6 #define V8ObjectBuilder_h
7
8 #include "bindings/core/v8/ToV8.h"
9 #include "platform/heap/Handle.h"
10 #include "wtf/text/WTFString.h"
11 #include <v8.h>
12
13 namespace blink {
14
15 class ScriptState;
16 class ScriptValue;
17
18 class V8ObjectBuilder final {
19 STACK_ALLOCATED();
20 public:
21 explicit V8ObjectBuilder(ScriptState*);
22
23 ScriptState* scriptState() const { return m_scriptState.get(); }
24
25 V8ObjectBuilder& add(const String& name, const V8ObjectBuilder&);
26
27 V8ObjectBuilder& addNull(const String& name);
28 V8ObjectBuilder& addBoolean(const String& name, bool value);
29 V8ObjectBuilder& addNumber(const String& name, double value);
30 V8ObjectBuilder& addString(const String& name, const String& value);
31
32 template <typename T>
33 V8ObjectBuilder& add(const String& name, const T& value)
34 {
35 addInternal(name, v8::Local<v8::Value>(toV8(value, m_scriptState->contex t()->Global(), m_scriptState->isolate())));
36 return *this;
37 }
38
39 ScriptValue scriptValue() const;
40 v8::Local<v8::Object> v8Value() const { return m_object; }
41
42 private:
43 void addInternal(const String& name, v8::Local<v8::Value>);
44
45 RefPtr<ScriptState> m_scriptState;
46 v8::Local<v8::Object> m_object;
47 };
48
49 } // namespace blink
50
51 #endif // V8ObjectBuilder_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/Dictionary.cpp ('k') | Source/bindings/core/v8/V8ObjectBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698