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

Side by Side Diff: Source/bindings/v8/V8PerContextData.cpp

Issue 24118003: Pass isolate to v8::Undefined() function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/V8Binding.cpp ('k') | Source/bindings/v8/V8ThrowException.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 CustomElementBinding* V8PerContextData::customElementBinding(CustomElementDefini tion* definition) 162 CustomElementBinding* V8PerContextData::customElementBinding(CustomElementDefini tion* definition)
163 { 163 {
164 CustomElementBindingMap::const_iterator it = m_customElementBindings->find(d efinition); 164 CustomElementBindingMap::const_iterator it = m_customElementBindings->find(d efinition);
165 ASSERT(it != m_customElementBindings->end()); 165 ASSERT(it != m_customElementBindings->end());
166 return it->value.get(); 166 return it->value.get();
167 } 167 }
168 168
169 169
170 static v8::Handle<v8::Value> createDebugData(const char* worldName, int debugId) 170 static v8::Handle<v8::Value> createDebugData(const char* worldName, int debugId, v8::Isolate* isolate)
171 { 171 {
172 char buffer[32]; 172 char buffer[32];
173 unsigned wanted; 173 unsigned wanted;
174 if (debugId == -1) 174 if (debugId == -1)
175 wanted = snprintf(buffer, sizeof(buffer), "%s", worldName); 175 wanted = snprintf(buffer, sizeof(buffer), "%s", worldName);
176 else 176 else
177 wanted = snprintf(buffer, sizeof(buffer), "%s,%d", worldName, debugId); 177 wanted = snprintf(buffer, sizeof(buffer), "%s,%d", worldName, debugId);
178 178
179 if (wanted < sizeof(buffer)) 179 if (wanted < sizeof(buffer))
180 return v8::String::NewSymbol(buffer); 180 return v8::String::NewSymbol(buffer);
181 181
182 return v8::Undefined(); 182 return v8::Undefined(isolate);
183 }; 183 }
184 184
185 static v8::Handle<v8::Value> debugData(v8::Handle<v8::Context> context) 185 static v8::Handle<v8::Value> debugData(v8::Handle<v8::Context> context)
186 { 186 {
187 v8::Context::Scope contextScope(context); 187 v8::Context::Scope contextScope(context);
188 return context->GetEmbedderData(v8ContextDebugIdIndex); 188 return context->GetEmbedderData(v8ContextDebugIdIndex);
189 } 189 }
190 190
191 static void setDebugData(v8::Handle<v8::Context> context, v8::Handle<v8::Value> value) 191 static void setDebugData(v8::Handle<v8::Context> context, v8::Handle<v8::Value> value)
192 { 192 {
193 v8::Context::Scope contextScope(context); 193 v8::Context::Scope contextScope(context);
194 context->SetEmbedderData(v8ContextDebugIdIndex, value); 194 context->SetEmbedderData(v8ContextDebugIdIndex, value);
195 } 195 }
196 196
197 bool V8PerContextDebugData::setContextDebugData(v8::Handle<v8::Context> context, const char* worldName, int debugId) 197 bool V8PerContextDebugData::setContextDebugData(v8::Handle<v8::Context> context, const char* worldName, int debugId)
198 { 198 {
199 if (!debugData(context)->IsUndefined()) 199 if (!debugData(context)->IsUndefined())
200 return false; 200 return false;
201 v8::HandleScope scope(context->GetIsolate()); 201 v8::HandleScope scope(context->GetIsolate());
202 v8::Handle<v8::Value> debugData = createDebugData(worldName, debugId); 202 v8::Handle<v8::Value> debugData = createDebugData(worldName, debugId, contex t->GetIsolate());
203 setDebugData(context, debugData); 203 setDebugData(context, debugData);
204 return true; 204 return true;
205 } 205 }
206 206
207 int V8PerContextDebugData::contextDebugId(v8::Handle<v8::Context> context) 207 int V8PerContextDebugData::contextDebugId(v8::Handle<v8::Context> context)
208 { 208 {
209 v8::HandleScope scope(context->GetIsolate()); 209 v8::HandleScope scope(context->GetIsolate());
210 v8::Handle<v8::Value> data = debugData(context); 210 v8::Handle<v8::Value> data = debugData(context);
211 211
212 if (!data->IsString()) 212 if (!data->IsString())
213 return -1; 213 return -1;
214 v8::String::AsciiValue ascii(data); 214 v8::String::AsciiValue ascii(data);
215 char* comma = strnstr(*ascii, ",", ascii.length()); 215 char* comma = strnstr(*ascii, ",", ascii.length());
216 if (!comma) 216 if (!comma)
217 return -1; 217 return -1;
218 return atoi(comma + 1); 218 return atoi(comma + 1);
219 } 219 }
220 220
221 } // namespace WebCore 221 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Binding.cpp ('k') | Source/bindings/v8/V8ThrowException.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698