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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp

Issue 2687943004: Abstract out ThreadDebugger from V8PerIsolateData (Closed)
Patch Set: Initialize HiddenValue and PrivateProperty in V8Initializer Created 3 years, 10 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
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "bindings/core/v8/V8PerIsolateData.h" 26 #include "bindings/core/v8/V8PerIsolateData.h"
27 27
28 #include <v8-debug.h>
29 #include <memory>
28 #include "bindings/core/v8/DOMDataStore.h" 30 #include "bindings/core/v8/DOMDataStore.h"
29 #include "bindings/core/v8/ScriptSourceCode.h"
30 #include "bindings/core/v8/V8Binding.h" 31 #include "bindings/core/v8/V8Binding.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"
34 #include "bindings/core/v8/V8ScriptRunner.h" 33 #include "bindings/core/v8/V8ScriptRunner.h"
35 #include "core/frame/Deprecation.h" 34 #include "core/frame/Deprecation.h"
36 #include "core/inspector/MainThreadDebugger.h"
37 #include "platform/ScriptForbiddenScope.h" 35 #include "platform/ScriptForbiddenScope.h"
36 #include "platform/WebTaskRunner.h"
38 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
39 #include "wtf/LeakAnnotations.h" 38 #include "wtf/LeakAnnotations.h"
40 #include "wtf/PtrUtil.h" 39 #include "wtf/PtrUtil.h"
41 #include <memory>
42 #include <v8-debug.h>
43 40
44 namespace blink { 41 namespace blink {
45 42
46 static V8PerIsolateData* mainThreadPerIsolateData = 0; 43 static V8PerIsolateData* mainThreadPerIsolateData = 0;
47 44
48 static void beforeCallEnteredCallback(v8::Isolate* isolate) { 45 static void beforeCallEnteredCallback(v8::Isolate* isolate) {
49 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); 46 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden());
50 } 47 }
51 48
52 static void microtasksCompletedCallback(v8::Isolate* isolate) { 49 static void microtasksCompletedCallback(v8::Isolate* isolate) {
53 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); 50 V8PerIsolateData::from(isolate)->runEndOfScopeTasks();
54 } 51 }
55 52
56 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner) 53 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner)
57 : m_isolateHolder(WTF::makeUnique<gin::IsolateHolder>( 54 : m_isolateHolder(WTF::makeUnique<gin::IsolateHolder>(
58 taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr, 55 taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr,
59 gin::IsolateHolder::kSingleThread, 56 gin::IsolateHolder::kSingleThread,
60 isMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait 57 isMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait
61 : gin::IsolateHolder::kAllowAtomicsWait)), 58 : gin::IsolateHolder::kAllowAtomicsWait)),
62 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))), 59 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))),
63 m_hiddenValue(V8HiddenValue::create()),
64 m_privateProperty(V8PrivateProperty::create()),
65 m_constructorMode(ConstructorMode::CreateNewObject), 60 m_constructorMode(ConstructorMode::CreateNewObject),
66 m_useCounterDisabled(false), 61 m_useCounterDisabled(false),
67 m_isHandlingRecursionLevelError(false), 62 m_isHandlingRecursionLevelError(false),
68 m_isReportingException(false) { 63 m_isReportingException(false) {
69 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. 64 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone.
70 isolate()->Enter(); 65 isolate()->Enter();
71 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); 66 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback);
72 isolate()->AddMicrotasksCompletedCallback(&microtasksCompletedCallback); 67 isolate()->AddMicrotasksCompletedCallback(&microtasksCompletedCallback);
73 if (isMainThread()) 68 if (isMainThread())
74 mainThreadPerIsolateData = this; 69 mainThreadPerIsolateData = this;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 tasks.swap(m_endOfScopeTasks); 379 tasks.swap(m_endOfScopeTasks);
385 for (const auto& task : tasks) 380 for (const auto& task : tasks)
386 task->run(); 381 task->run();
387 ASSERT(m_endOfScopeTasks.isEmpty()); 382 ASSERT(m_endOfScopeTasks.isEmpty());
388 } 383 }
389 384
390 void V8PerIsolateData::clearEndOfScopeTasks() { 385 void V8PerIsolateData::clearEndOfScopeTasks() {
391 m_endOfScopeTasks.clear(); 386 m_endOfScopeTasks.clear();
392 } 387 }
393 388
394 void V8PerIsolateData::setThreadDebugger(
395 std::unique_ptr<ThreadDebugger> threadDebugger) {
396 ASSERT(!m_threadDebugger);
397 m_threadDebugger = std::move(threadDebugger);
398 }
399
400 ThreadDebugger* V8PerIsolateData::threadDebugger() {
401 return m_threadDebugger.get();
402 }
403
404 void V8PerIsolateData::addActiveScriptWrappable( 389 void V8PerIsolateData::addActiveScriptWrappable(
405 ActiveScriptWrappableBase* wrappable) { 390 ActiveScriptWrappableBase* wrappable) {
406 if (!m_activeScriptWrappables) 391 if (!m_activeScriptWrappables)
407 m_activeScriptWrappables = new ActiveScriptWrappableSet(); 392 m_activeScriptWrappables = new ActiveScriptWrappableSet();
408 393
409 m_activeScriptWrappables->insert(wrappable); 394 m_activeScriptWrappables->insert(wrappable);
410 } 395 }
411 396
412 void V8PerIsolateData::TemporaryScriptWrappableVisitorScope:: 397 void V8PerIsolateData::TemporaryScriptWrappableVisitorScope::
413 swapWithV8PerIsolateDataVisitor( 398 swapWithV8PerIsolateDataVisitor(
414 std::unique_ptr<ScriptWrappableVisitor>& visitor) { 399 std::unique_ptr<ScriptWrappableVisitor>& visitor) {
415 ScriptWrappableVisitor* current = currentVisitor(); 400 ScriptWrappableVisitor* current = currentVisitor();
416 if (current) 401 if (current)
417 current->performCleanup(); 402 current->performCleanup();
418 403
419 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( 404 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap(
420 m_savedVisitor); 405 m_savedVisitor);
421 m_isolate->SetEmbedderHeapTracer(currentVisitor()); 406 m_isolate->SetEmbedderHeapTracer(currentVisitor());
422 } 407 }
423 408
424 } // namespace blink 409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698