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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp

Issue 1838523004: Initialize debugger together with isolate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unnecessary assert hitting in unit tests Created 4 years, 8 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) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 m_debuggerScript.Reset(); 98 m_debuggerScript.Reset();
99 m_debuggerContext.Reset(); 99 m_debuggerContext.Reset();
100 v8::Debug::SetDebugEventListener(m_isolate, nullptr); 100 v8::Debug::SetDebugEventListener(m_isolate, nullptr);
101 } 101 }
102 102
103 bool V8DebuggerImpl::enabled() const 103 bool V8DebuggerImpl::enabled() const
104 { 104 {
105 return !m_debuggerScript.IsEmpty(); 105 return !m_debuggerScript.IsEmpty();
106 } 106 }
107 107
108 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin g16& type, int contextGroupId)
109 {
110 int contextId = atomicIncrement(&s_lastContextId);
111 String16 debugData = String16::number(contextGroupId) + "," + String16::numb er(contextId) + "," + type;
112 v8::HandleScope scope(context->GetIsolate());
113 v8::Context::Scope contextScope(context);
114 context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8S tring(context->GetIsolate(), debugData));
115 }
116
117 int V8Debugger::contextId(v8::Local<v8::Context> context) 108 int V8Debugger::contextId(v8::Local<v8::Context> context)
118 { 109 {
119 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co ntext::kDebugIdIndex)); 110 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co ntext::kDebugIdIndex));
120 if (data.IsEmpty() || !data->IsString()) 111 if (data.IsEmpty() || !data->IsString())
121 return 0; 112 return 0;
122 String16 dataString = toProtocolString(data.As<v8::String>()); 113 String16 dataString = toProtocolString(data.As<v8::String>());
123 if (dataString.isEmpty()) 114 if (dataString.isEmpty())
124 return 0; 115 return 0;
125 size_t commaPos = dataString.find(","); 116 size_t commaPos = dataString.find(",");
126 if (commaPos == kNotFound) 117 if (commaPos == kNotFound)
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 770 }
780 771
781 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra ce> stackTrace, size_t maxStackSize) 772 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra ce> stackTrace, size_t maxStackSize)
782 { 773 {
783 V8DebuggerAgentImpl* agent = getDebuggerAgentForContext(m_isolate->GetCurren tContext()); 774 V8DebuggerAgentImpl* agent = getDebuggerAgentForContext(m_isolate->GetCurren tContext());
784 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); 775 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize);
785 } 776 }
786 777
787 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) 778 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info)
788 { 779 {
780 ASSERT(info.context->GetIsolate() == m_isolate);
781 // TODO(dgozman): make s_lastContextId non-static.
782 int contextId = atomicIncrement(&s_lastContextId);
783 String16 debugData = String16::number(info.contextGroupId) + "," + String16: :number(contextId) + "," + (info.isDefault ? "default" : "nondefault");
784 v8::HandleScope scope(m_isolate);
785 v8::Context::Scope contextScope(info.context);
786 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData));
787
789 V8RuntimeAgentImpl* agent = getRuntimeAgentForContext(info.context); 788 V8RuntimeAgentImpl* agent = getRuntimeAgentForContext(info.context);
790 if (agent) 789 if (agent)
791 agent->reportExecutionContextCreated(info); 790 agent->reportExecutionContextCreated(info);
792 } 791 }
793 792
794 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) 793 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context)
795 { 794 {
796 V8RuntimeAgentImpl* agent = getRuntimeAgentForContext(context); 795 V8RuntimeAgentImpl* agent = getRuntimeAgentForContext(context);
797 if (agent) 796 if (agent)
798 agent->reportExecutionContextDestroyed(context); 797 agent->reportExecutionContextDestroyed(context);
(...skipping 16 matching lines...) Expand all
815 } 814 }
816 815
817 v8::Local<v8::Context> V8DebuggerImpl::regexContext() 816 v8::Local<v8::Context> V8DebuggerImpl::regexContext()
818 { 817 {
819 if (m_regexContext.IsEmpty()) 818 if (m_regexContext.IsEmpty())
820 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); 819 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate));
821 return m_regexContext.Get(m_isolate); 820 return m_regexContext.Get(m_isolate);
822 } 821 }
823 822
824 } // namespace blink 823 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698