OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 { | 263 { |
264 // visitNodeWrappers() should receive a ScriptState and retrieve an Isolate | 264 // visitNodeWrappers() should receive a ScriptState and retrieve an Isolate |
265 // from the ScriptState. | 265 // from the ScriptState. |
266 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 266 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
267 v8::HandleScope handleScope(isolate); | 267 v8::HandleScope handleScope(isolate); |
268 | 268 |
269 class DOMNodeWrapperVisitor : public v8::PersistentHandleVisitor { | 269 class DOMNodeWrapperVisitor : public v8::PersistentHandleVisitor { |
270 public: | 270 public: |
271 DOMNodeWrapperVisitor(WrappedNodeVisitor* visitor, v8::Isolate* isolate) | 271 DOMNodeWrapperVisitor(WrappedNodeVisitor* visitor, v8::Isolate* isolate) |
272 : m_visitor(visitor) | 272 : m_visitor(visitor) |
| 273 #if ENABLE(ASSERT) |
273 , m_isolate(isolate) | 274 , m_isolate(isolate) |
| 275 #endif |
274 { | 276 { |
275 } | 277 } |
276 | 278 |
277 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uin
t16_t classId) override | 279 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uin
t16_t classId) override |
278 { | 280 { |
279 if (classId != WrapperTypeInfo::NodeClassId) | 281 if (classId != WrapperTypeInfo::NodeClassId) |
280 return; | 282 return; |
281 // Casting to Handle is safe here, since the Persistent cannot get | 283 |
282 // GCd during visiting. | 284 #if ENABLE(ASSERT) |
283 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Ob
ject>*>(value); | 285 { |
284 ASSERT_UNUSED(m_isolate, V8Node::hasInstance(*wrapper, m_isolate)); | 286 v8::HandleScope scope(m_isolate); |
285 ASSERT((*wrapper)->IsObject()); | 287 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_iso
late, v8::Persistent<v8::Object>::Cast(*value)); |
286 m_visitor->visitNode(V8Node::toImpl(*wrapper)); | 288 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); |
| 289 ASSERT(wrapper->IsObject()); |
| 290 } |
| 291 #endif |
| 292 m_visitor->visitNode(toScriptWrappableBase(v8::Persistent<v8::Object
>::Cast(*value))->toImpl<Node>()); |
287 } | 293 } |
288 | 294 |
289 private: | 295 private: |
290 WrappedNodeVisitor* m_visitor; | 296 WrappedNodeVisitor* m_visitor; |
| 297 #if ENABLE(ASSERT) |
291 v8::Isolate* m_isolate; | 298 v8::Isolate* m_isolate; |
| 299 #endif |
292 } wrapperVisitor(visitor, isolate); | 300 } wrapperVisitor(visitor, isolate); |
293 | 301 |
294 v8::V8::VisitHandlesWithClassIds(isolate, &wrapperVisitor); | 302 v8::V8::VisitHandlesWithClassIds(isolate, &wrapperVisitor); |
295 } | 303 } |
296 | 304 |
297 ProfileNameIdleTimeMap* ScriptProfiler::currentProfileNameIdleTimeMap() | 305 ProfileNameIdleTimeMap* ScriptProfiler::currentProfileNameIdleTimeMap() |
298 { | 306 { |
299 AtomicallyInitializedStatic(WTF::ThreadSpecific<ProfileNameIdleTimeMap>*, ma
p = new WTF::ThreadSpecific<ProfileNameIdleTimeMap>); | 307 AtomicallyInitializedStatic(WTF::ThreadSpecific<ProfileNameIdleTimeMap>*, ma
p = new WTF::ThreadSpecific<ProfileNameIdleTimeMap>); |
300 return *map; | 308 return *map; |
301 } | 309 } |
302 | 310 |
303 void ScriptProfiler::setIdle(bool isIdle) | 311 void ScriptProfiler::setIdle(bool isIdle) |
304 { | 312 { |
305 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 313 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
306 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) | 314 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) |
307 profiler->SetIdle(isIdle); | 315 profiler->SetIdle(isIdle); |
308 } | 316 } |
309 | 317 |
310 } // namespace blink | 318 } // namespace blink |
OLD | NEW |