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

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

Issue 1020233002: [bindings] [devtools] Migrate the usage of ScriptValue.toJSONValue() to ScriptValue::to<JSONValuePt… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing 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/ScriptDebugServer.cpp ('k') | Source/bindings/core/v8/ScriptValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 class CORE_EXPORT ScriptValue final { 47 class CORE_EXPORT ScriptValue final {
48 public: 48 public:
49 template<typename T> 49 template<typename T>
50 static ScriptValue from(ScriptState* scriptState, T value) 50 static ScriptValue from(ScriptState* scriptState, T value)
51 { 51 {
52 return ScriptValue(scriptState, toV8(value, scriptState->context()->Glob al(), scriptState->isolate())); 52 return ScriptValue(scriptState, toV8(value, scriptState->context()->Glob al(), scriptState->isolate()));
53 } 53 }
54 54
55 template<typename T, typename... Arguments> 55 template<typename T, typename... Arguments>
56 static inline T to(v8::Isolate* isolate, v8::Local<v8::Value> value, Excepti onState& exceptionState, Arguments const&... arguments)
57 {
58 return NativeValueTraits<T>::nativeValue(isolate, value, exceptionState, arguments...);
59 }
60
61 template<typename T, typename... Arguments>
56 static inline T to(v8::Isolate* isolate, const ScriptValue& value, Exception State& exceptionState, Arguments const&... arguments) 62 static inline T to(v8::Isolate* isolate, const ScriptValue& value, Exception State& exceptionState, Arguments const&... arguments)
57 { 63 {
58 return NativeValueTraits<T>::nativeValue(isolate, value.v8Value(), excep tionState, arguments...); 64 return to<T>(isolate, value.v8Value(), exceptionState, arguments...);
59 } 65 }
60 66
61 ScriptValue() { } 67 ScriptValue() { }
62 68
63 ScriptValue(ScriptState* scriptState, v8::Handle<v8::Value> value) 69 ScriptValue(ScriptState* scriptState, v8::Handle<v8::Value> value)
64 : m_scriptState(scriptState) 70 : m_scriptState(scriptState)
65 , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::creat e(value, scriptState->isolate())) 71 , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::creat e(value, scriptState->isolate()))
66 { 72 {
67 ASSERT(isEmpty() || m_scriptState); 73 ASSERT(isEmpty() || m_scriptState);
68 } 74 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 152
147 void clear() 153 void clear()
148 { 154 {
149 m_value = nullptr; 155 m_value = nullptr;
150 } 156 }
151 157
152 v8::Handle<v8::Value> v8Value() const; 158 v8::Handle<v8::Value> v8Value() const;
153 v8::Handle<v8::Value> v8ValueUnsafe() const; 159 v8::Handle<v8::Value> v8ValueUnsafe() const;
154 160
155 bool toString(String&) const; 161 bool toString(String&) const;
156 PassRefPtr<JSONValue> toJSONValue(ScriptState*) const;
157 162
158 static ScriptValue createNull(ScriptState*); 163 static ScriptValue createNull(ScriptState*);
159 164
160 private: 165 private:
161 RefPtr<ScriptState> m_scriptState; 166 RefPtr<ScriptState> m_scriptState;
162 RefPtr<SharedPersistent<v8::Value>> m_value; 167 RefPtr<SharedPersistent<v8::Value>> m_value;
163 }; 168 };
164 169
165 } // namespace blink 170 } // namespace blink
166 171
167 #endif // ScriptValue_h 172 #endif // ScriptValue_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptDebugServer.cpp ('k') | Source/bindings/core/v8/ScriptValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698