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

Side by Side Diff: Source/core/inspector/ScriptArguments.cpp

Issue 766103003: [Inspector] Deprecate usage of v8::Handle with v8::Local as replacement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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/core/inspector/PromiseTracker.cpp ('k') | Source/core/inspector/ScriptDebugListener.h » ('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) 2010 Google Inc. All rights reserved. 2 * Copyright (c) 2010 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 27 matching lines...) Expand all
38 38
39 namespace blink { 39 namespace blink {
40 40
41 namespace { 41 namespace {
42 42
43 static const unsigned maxArrayItemsLimit = 10000; 43 static const unsigned maxArrayItemsLimit = 10000;
44 static const unsigned maxStackDepthLimit = 32; 44 static const unsigned maxStackDepthLimit = 32;
45 45
46 class V8ValueStringBuilder { 46 class V8ValueStringBuilder {
47 public: 47 public:
48 static String toString(v8::Handle<v8::Value> value, v8::Isolate* isolate) 48 static String toString(v8::Local<v8::Value> value, v8::Isolate* isolate)
49 { 49 {
50 V8ValueStringBuilder builder(isolate); 50 V8ValueStringBuilder builder(isolate);
51 if (!builder.append(value)) 51 if (!builder.append(value))
52 return String(); 52 return String();
53 return builder.toString(); 53 return builder.toString();
54 } 54 }
55 55
56 private: 56 private:
57 enum { 57 enum {
58 IgnoreNull = 1 << 0, 58 IgnoreNull = 1 << 0,
59 IgnoreUndefined = 1 << 1, 59 IgnoreUndefined = 1 << 1,
60 }; 60 };
61 61
62 V8ValueStringBuilder(v8::Isolate* isolate) 62 V8ValueStringBuilder(v8::Isolate* isolate)
63 : m_arrayLimit(maxArrayItemsLimit) 63 : m_arrayLimit(maxArrayItemsLimit)
64 , m_isolate(isolate) 64 , m_isolate(isolate)
65 { 65 {
66 } 66 }
67 67
68 bool append(v8::Handle<v8::Value> value, unsigned ignoreOptions = 0) 68 bool append(v8::Local<v8::Value> value, unsigned ignoreOptions = 0)
69 { 69 {
70 if (value.IsEmpty()) 70 if (value.IsEmpty())
71 return true; 71 return true;
72 if ((ignoreOptions & IgnoreNull) && value->IsNull()) 72 if ((ignoreOptions & IgnoreNull) && value->IsNull())
73 return true; 73 return true;
74 if ((ignoreOptions & IgnoreUndefined) && value->IsUndefined()) 74 if ((ignoreOptions & IgnoreUndefined) && value->IsUndefined())
75 return true; 75 return true;
76 if (value->IsString()) 76 if (value->IsString())
77 return append(v8::Handle<v8::String>::Cast(value)); 77 return append(v8::Local<v8::String>::Cast(value));
78 if (value->IsStringObject()) 78 if (value->IsStringObject())
79 return append(v8::Handle<v8::StringObject>::Cast(value)->ValueOf()); 79 return append(v8::Local<v8::StringObject>::Cast(value)->ValueOf());
80 if (value->IsSymbol()) 80 if (value->IsSymbol())
81 return append(v8::Handle<v8::Symbol>::Cast(value)); 81 return append(v8::Local<v8::Symbol>::Cast(value));
82 if (value->IsSymbolObject()) 82 if (value->IsSymbolObject())
83 return append(v8::Handle<v8::SymbolObject>::Cast(value)->ValueOf()); 83 return append(v8::Local<v8::SymbolObject>::Cast(value)->ValueOf());
84 if (value->IsNumberObject()) { 84 if (value->IsNumberObject()) {
85 m_builder.appendNumber(v8::Handle<v8::NumberObject>::Cast(value)->Va lueOf()); 85 m_builder.appendNumber(v8::Local<v8::NumberObject>::Cast(value)->Val ueOf());
86 return true; 86 return true;
87 } 87 }
88 if (value->IsBooleanObject()) { 88 if (value->IsBooleanObject()) {
89 m_builder.append(v8::Handle<v8::BooleanObject>::Cast(value)->ValueOf () ? "true" : "false"); 89 m_builder.append(v8::Local<v8::BooleanObject>::Cast(value)->ValueOf( ) ? "true" : "false");
90 return true; 90 return true;
91 } 91 }
92 if (value->IsArray()) 92 if (value->IsArray())
93 return append(v8::Handle<v8::Array>::Cast(value)); 93 return append(v8::Local<v8::Array>::Cast(value));
94 if (toDOMWindow(m_isolate, value)) { 94 if (toDOMWindow(m_isolate, value)) {
95 m_builder.append("[object Window]"); 95 m_builder.append("[object Window]");
96 return true; 96 return true;
97 } 97 }
98 if (value->IsObject() 98 if (value->IsObject()
99 && !value->IsDate() 99 && !value->IsDate()
100 && !value->IsFunction() 100 && !value->IsFunction()
101 && !value->IsNativeError() 101 && !value->IsNativeError()
102 && !value->IsRegExp()) 102 && !value->IsRegExp())
103 return append(v8::Handle<v8::Object>::Cast(value)->ObjectProtoToStri ng()); 103 return append(v8::Local<v8::Object>::Cast(value)->ObjectProtoToStrin g());
104 return append(value->ToString(m_isolate)); 104 return append(value->ToString(m_isolate));
105 } 105 }
106 106
107 bool append(v8::Handle<v8::Array> array) 107 bool append(v8::Local<v8::Array> array)
108 { 108 {
109 if (m_visitedArrays.contains(array)) 109 if (m_visitedArrays.contains(array))
110 return true; 110 return true;
111 uint32_t length = array->Length(); 111 uint32_t length = array->Length();
112 if (length > m_arrayLimit) 112 if (length > m_arrayLimit)
113 return false; 113 return false;
114 if (m_visitedArrays.size() > maxStackDepthLimit) 114 if (m_visitedArrays.size() > maxStackDepthLimit)
115 return false; 115 return false;
116 116
117 bool result = true; 117 bool result = true;
118 m_arrayLimit -= length; 118 m_arrayLimit -= length;
119 m_visitedArrays.append(array); 119 m_visitedArrays.append(array);
120 for (uint32_t i = 0; i < length; ++i) { 120 for (uint32_t i = 0; i < length; ++i) {
121 if (i) 121 if (i)
122 m_builder.append(','); 122 m_builder.append(',');
123 if (!append(array->Get(i), IgnoreNull | IgnoreUndefined)) { 123 if (!append(array->Get(i), IgnoreNull | IgnoreUndefined)) {
124 result = false; 124 result = false;
125 break; 125 break;
126 } 126 }
127 } 127 }
128 m_visitedArrays.removeLast(); 128 m_visitedArrays.removeLast();
129 return result; 129 return result;
130 } 130 }
131 131
132 bool append(v8::Handle<v8::Symbol> symbol) 132 bool append(v8::Local<v8::Symbol> symbol)
133 { 133 {
134 m_builder.appendLiteral("Symbol("); 134 m_builder.appendLiteral("Symbol(");
135 bool result = append(symbol->Name(), IgnoreUndefined); 135 bool result = append(symbol->Name(), IgnoreUndefined);
136 m_builder.append(')'); 136 m_builder.append(')');
137 return result; 137 return result;
138 } 138 }
139 139
140 bool append(v8::Handle<v8::String> string) 140 bool append(v8::Local<v8::String> string)
141 { 141 {
142 if (m_tryCatch.HasCaught()) 142 if (m_tryCatch.HasCaught())
143 return false; 143 return false;
144 if (!string.IsEmpty()) 144 if (!string.IsEmpty())
145 m_builder.append(toCoreString(string)); 145 m_builder.append(toCoreString(string));
146 return true; 146 return true;
147 } 147 }
148 148
149 String toString() 149 String toString()
150 { 150 {
151 if (m_tryCatch.HasCaught()) 151 if (m_tryCatch.HasCaught())
152 return String(); 152 return String();
153 return m_builder.toString(); 153 return m_builder.toString();
154 } 154 }
155 155
156 uint32_t m_arrayLimit; 156 uint32_t m_arrayLimit;
157 v8::Isolate* m_isolate; 157 v8::Isolate* m_isolate;
158 StringBuilder m_builder; 158 StringBuilder m_builder;
159 Vector<v8::Handle<v8::Array> > m_visitedArrays; 159 Vector<v8::Local<v8::Array> > m_visitedArrays;
160 v8::TryCatch m_tryCatch; 160 v8::TryCatch m_tryCatch;
161 }; 161 };
162 162
163 } // namespace 163 } // namespace
164 164
165 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ScriptArguments) 165 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ScriptArguments)
166 166
167 PassRefPtrWillBeRawPtr<ScriptArguments> ScriptArguments::create(ScriptState* scr iptState, Vector<ScriptValue>& arguments) 167 PassRefPtrWillBeRawPtr<ScriptArguments> ScriptArguments::create(ScriptState* scr iptState, Vector<ScriptValue>& arguments)
168 { 168 {
169 return adoptRefWillBeNoop(new ScriptArguments(scriptState, arguments)); 169 return adoptRefWillBeNoop(new ScriptArguments(scriptState, arguments));
(...skipping 16 matching lines...) Expand all
186 if (!argumentCount()) 186 if (!argumentCount())
187 return false; 187 return false;
188 188
189 const ScriptValue& value = argumentAt(0); 189 const ScriptValue& value = argumentAt(0);
190 ScriptState::Scope scope(m_scriptState.get()); 190 ScriptState::Scope scope(m_scriptState.get());
191 result = V8ValueStringBuilder::toString(value.v8Value(), value.isolate()); 191 result = V8ValueStringBuilder::toString(value.v8Value(), value.isolate());
192 return true; 192 return true;
193 } 193 }
194 194
195 } // namespace blink 195 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/PromiseTracker.cpp ('k') | Source/core/inspector/ScriptDebugListener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698