| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "bindings/core/v8/V8Binding.h" | 30 #include "bindings/core/v8/V8Binding.h" |
| 31 #include "bindings/core/v8/V8HiddenValue.h" | 31 #include "bindings/core/v8/V8HiddenValue.h" |
| 32 #include "bindings/core/v8/V8ObjectConstructor.h" | 32 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 33 #include "bindings/core/v8/V8PrivateProperty.h" | 33 #include "bindings/core/v8/V8PrivateProperty.h" |
| 34 #include "bindings/core/v8/V8ScriptRunner.h" | 34 #include "bindings/core/v8/V8ScriptRunner.h" |
| 35 #include "core/frame/Deprecation.h" | 35 #include "core/frame/Deprecation.h" |
| 36 #include "core/inspector/MainThreadDebugger.h" | 36 #include "core/inspector/MainThreadDebugger.h" |
| 37 #include "platform/ScriptForbiddenScope.h" | 37 #include "platform/ScriptForbiddenScope.h" |
| 38 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 39 #include "wtf/LeakAnnotations.h" | 39 #include "wtf/LeakAnnotations.h" |
| 40 #include "wtf/PtrUtil.h" | |
| 41 #include <memory> | 40 #include <memory> |
| 42 | 41 |
| 43 namespace blink { | 42 namespace blink { |
| 44 | 43 |
| 45 static V8PerIsolateData* mainThreadPerIsolateData = 0; | 44 static V8PerIsolateData* mainThreadPerIsolateData = 0; |
| 46 | 45 |
| 47 static void beforeCallEnteredCallback(v8::Isolate* isolate) | 46 static void beforeCallEnteredCallback(v8::Isolate* isolate) |
| 48 { | 47 { |
| 49 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); | 48 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
| 50 } | 49 } |
| 51 | 50 |
| 52 static void microtasksCompletedCallback(v8::Isolate* isolate) | 51 static void microtasksCompletedCallback(v8::Isolate* isolate) |
| 53 { | 52 { |
| 54 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); | 53 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); |
| 55 } | 54 } |
| 56 | 55 |
| 57 V8PerIsolateData::V8PerIsolateData() | 56 V8PerIsolateData::V8PerIsolateData() |
| 58 : m_isolateHolder(wrapUnique(new gin::IsolateHolder())) | 57 : m_isolateHolder(adoptPtr(new gin::IsolateHolder())) |
| 59 , m_stringCache(wrapUnique(new StringCache(isolate()))) | 58 , m_stringCache(adoptPtr(new StringCache(isolate()))) |
| 60 , m_hiddenValue(V8HiddenValue::create()) | 59 , m_hiddenValue(V8HiddenValue::create()) |
| 61 , m_privateProperty(V8PrivateProperty::create()) | 60 , m_privateProperty(V8PrivateProperty::create()) |
| 62 , m_constructorMode(ConstructorMode::CreateNewObject) | 61 , m_constructorMode(ConstructorMode::CreateNewObject) |
| 63 , m_useCounterDisabled(false) | 62 , m_useCounterDisabled(false) |
| 64 , m_isHandlingRecursionLevelError(false) | 63 , m_isHandlingRecursionLevelError(false) |
| 65 , m_isReportingException(false) | 64 , m_isReportingException(false) |
| 66 { | 65 { |
| 67 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | 66 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
| 68 isolate()->Enter(); | 67 isolate()->Enter(); |
| 69 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); | 68 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 84 } | 83 } |
| 85 | 84 |
| 86 v8::Isolate* V8PerIsolateData::initialize() | 85 v8::Isolate* V8PerIsolateData::initialize() |
| 87 { | 86 { |
| 88 V8PerIsolateData* data = new V8PerIsolateData(); | 87 V8PerIsolateData* data = new V8PerIsolateData(); |
| 89 v8::Isolate* isolate = data->isolate(); | 88 v8::Isolate* isolate = data->isolate(); |
| 90 isolate->SetData(gin::kEmbedderBlink, data); | 89 isolate->SetData(gin::kEmbedderBlink, data); |
| 91 return isolate; | 90 return isolate; |
| 92 } | 91 } |
| 93 | 92 |
| 94 void V8PerIsolateData::enableIdleTasks(v8::Isolate* isolate, std::unique_ptr<gin
::V8IdleTaskRunner> taskRunner) | 93 void V8PerIsolateData::enableIdleTasks(v8::Isolate* isolate, PassOwnPtr<gin::V8I
dleTaskRunner> taskRunner) |
| 95 { | 94 { |
| 96 from(isolate)->m_isolateHolder->EnableIdleTasks(std::unique_ptr<gin::V8IdleT
askRunner>(taskRunner.release())); | 95 from(isolate)->m_isolateHolder->EnableIdleTasks(std::unique_ptr<gin::V8IdleT
askRunner>(taskRunner.leakPtr())); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void V8PerIsolateData::useCounterCallback(v8::Isolate* isolate, v8::Isolate::Use
CounterFeature feature) | 98 void V8PerIsolateData::useCounterCallback(v8::Isolate* isolate, v8::Isolate::Use
CounterFeature feature) |
| 100 { | 99 { |
| 101 if (V8PerIsolateData::from(isolate)->m_useCounterDisabled) | 100 if (V8PerIsolateData::from(isolate)->m_useCounterDisabled) |
| 102 return; | 101 return; |
| 103 | 102 |
| 104 UseCounter::Feature blinkFeature; | 103 UseCounter::Feature blinkFeature; |
| 105 bool deprecated = false; | 104 bool deprecated = false; |
| 106 switch (feature) { | 105 switch (feature) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 { | 339 { |
| 341 if (value.IsEmpty() || !value->IsObject()) | 340 if (value.IsEmpty() || !value->IsObject()) |
| 342 return v8::Local<v8::Object>(); | 341 return v8::Local<v8::Object>(); |
| 343 auto result = map.find(info); | 342 auto result = map.find(info); |
| 344 if (result == map.end()) | 343 if (result == map.end()) |
| 345 return v8::Local<v8::Object>(); | 344 return v8::Local<v8::Object>(); |
| 346 v8::Local<v8::FunctionTemplate> templ = result->value.Get(isolate()); | 345 v8::Local<v8::FunctionTemplate> templ = result->value.Get(isolate()); |
| 347 return v8::Local<v8::Object>::Cast(value)->FindInstanceInPrototypeChain(temp
l); | 346 return v8::Local<v8::Object>::Cast(value)->FindInstanceInPrototypeChain(temp
l); |
| 348 } | 347 } |
| 349 | 348 |
| 350 void V8PerIsolateData::addEndOfScopeTask(std::unique_ptr<EndOfScopeTask> task) | 349 void V8PerIsolateData::addEndOfScopeTask(PassOwnPtr<EndOfScopeTask> task) |
| 351 { | 350 { |
| 352 m_endOfScopeTasks.append(std::move(task)); | 351 m_endOfScopeTasks.append(std::move(task)); |
| 353 } | 352 } |
| 354 | 353 |
| 355 void V8PerIsolateData::runEndOfScopeTasks() | 354 void V8PerIsolateData::runEndOfScopeTasks() |
| 356 { | 355 { |
| 357 Vector<std::unique_ptr<EndOfScopeTask>> tasks; | 356 Vector<OwnPtr<EndOfScopeTask>> tasks; |
| 358 tasks.swap(m_endOfScopeTasks); | 357 tasks.swap(m_endOfScopeTasks); |
| 359 for (const auto& task : tasks) | 358 for (const auto& task : tasks) |
| 360 task->run(); | 359 task->run(); |
| 361 ASSERT(m_endOfScopeTasks.isEmpty()); | 360 ASSERT(m_endOfScopeTasks.isEmpty()); |
| 362 } | 361 } |
| 363 | 362 |
| 364 void V8PerIsolateData::clearEndOfScopeTasks() | 363 void V8PerIsolateData::clearEndOfScopeTasks() |
| 365 { | 364 { |
| 366 m_endOfScopeTasks.clear(); | 365 m_endOfScopeTasks.clear(); |
| 367 } | 366 } |
| 368 | 367 |
| 369 void V8PerIsolateData::setThreadDebugger(std::unique_ptr<ThreadDebugger> threadD
ebugger) | 368 void V8PerIsolateData::setThreadDebugger(PassOwnPtr<ThreadDebugger> threadDebugg
er) |
| 370 { | 369 { |
| 371 ASSERT(!m_threadDebugger); | 370 ASSERT(!m_threadDebugger); |
| 372 m_threadDebugger = std::move(threadDebugger); | 371 m_threadDebugger = std::move(threadDebugger); |
| 373 } | 372 } |
| 374 | 373 |
| 375 ThreadDebugger* V8PerIsolateData::threadDebugger() | 374 ThreadDebugger* V8PerIsolateData::threadDebugger() |
| 376 { | 375 { |
| 377 return m_threadDebugger.get(); | 376 return m_threadDebugger.get(); |
| 378 } | 377 } |
| 379 | 378 |
| 380 void V8PerIsolateData::addActiveScriptWrappable(ActiveScriptWrappable* wrappable
) | 379 void V8PerIsolateData::addActiveScriptWrappable(ActiveScriptWrappable* wrappable
) |
| 381 { | 380 { |
| 382 if (!m_activeScriptWrappables) | 381 if (!m_activeScriptWrappables) |
| 383 m_activeScriptWrappables = new ActiveScriptWrappableSet(); | 382 m_activeScriptWrappables = new ActiveScriptWrappableSet(); |
| 384 | 383 |
| 385 m_activeScriptWrappables->add(wrappable); | 384 m_activeScriptWrappables->add(wrappable); |
| 386 } | 385 } |
| 387 | 386 |
| 388 } // namespace blink | 387 } // namespace blink |
| OLD | NEW |