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