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

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

Issue 2205913002: [DevTools] Split a part of V8Inspector into V8Debugger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-inspector-rename
Patch Set: context scope! Created 4 years, 4 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) 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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 31 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
32 32
33 #include "platform/inspector_protocol/Values.h" 33 #include "platform/inspector_protocol/Values.h"
34 #include "platform/v8_inspector/InjectedScript.h" 34 #include "platform/v8_inspector/InjectedScript.h"
35 #include "platform/v8_inspector/InspectedContext.h" 35 #include "platform/v8_inspector/InspectedContext.h"
36 #include "platform/v8_inspector/RemoteObjectId.h" 36 #include "platform/v8_inspector/RemoteObjectId.h"
37 #include "platform/v8_inspector/V8ConsoleMessage.h" 37 #include "platform/v8_inspector/V8ConsoleMessage.h"
38 #include "platform/v8_inspector/V8Debugger.h"
38 #include "platform/v8_inspector/V8InspectorImpl.h" 39 #include "platform/v8_inspector/V8InspectorImpl.h"
39 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 40 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
40 #include "platform/v8_inspector/V8StackTraceImpl.h" 41 #include "platform/v8_inspector/V8StackTraceImpl.h"
41 #include "platform/v8_inspector/V8StringUtil.h" 42 #include "platform/v8_inspector/V8StringUtil.h"
42 #include "platform/v8_inspector/public/V8InspectorClient.h" 43 #include "platform/v8_inspector/public/V8InspectorClient.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 namespace V8RuntimeAgentImplState { 47 namespace V8RuntimeAgentImplState {
47 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled "; 48 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled ";
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 handler->m_callback->sendSuccess(handler->wrapObject(value), Maybe<bool> (), Maybe<protocol::Runtime::ExceptionDetails>()); 103 handler->m_callback->sendSuccess(handler->wrapObject(value), Maybe<bool> (), Maybe<protocol::Runtime::ExceptionDetails>());
103 } 104 }
104 105
105 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 106 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
106 { 107 {
107 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH andler<Callback>*>(info.Data().As<v8::External>()->Value()); 108 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH andler<Callback>*>(info.Data().As<v8::External>()->Value());
108 DCHECK(handler); 109 DCHECK(handler);
109 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8: :Value>::Cast(v8::Undefined(info.GetIsolate())); 110 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8: :Value>::Cast(v8::Undefined(info.GetIsolate()));
110 111
111 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails; 112 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails;
112 std::unique_ptr<V8StackTraceImpl> stack = handler->m_inspector->captureS tackTraceImpl(true); 113 std::unique_ptr<V8StackTraceImpl> stack = handler->m_inspector->debugger ()->captureStackTrace(true);
113 if (stack) { 114 if (stack) {
114 exceptionDetails = protocol::Runtime::ExceptionDetails::create() 115 exceptionDetails = protocol::Runtime::ExceptionDetails::create()
115 .setText("Promise was rejected") 116 .setText("Promise was rejected")
116 .setLineNumber(!stack->isEmpty() ? stack->topLineNumber() : 0) 117 .setLineNumber(!stack->isEmpty() ? stack->topLineNumber() : 0)
117 .setColumnNumber(!stack->isEmpty() ? stack->topColumnNumber() : 0) 118 .setColumnNumber(!stack->isEmpty() ? stack->topColumnNumber() : 0)
118 .setScriptId(!stack->isEmpty() ? stack->topScriptId() : String16 ()) 119 .setScriptId(!stack->isEmpty() ? stack->topScriptId() : String16 ())
119 .setStackTrace(stack->buildInspectorObjectImpl()) 120 .setStackTrace(stack->buildInspectorObjectImpl())
120 .build(); 121 .build();
121 } 122 }
122 handler->m_callback->sendSuccess(handler->wrapObject(value), true, std:: move(exceptionDetails)); 123 handler->m_callback->sendSuccess(handler->wrapObject(value), true, std:: move(exceptionDetails));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 int contextId; 202 int contextId;
202 if (executionContextId.isJust()) { 203 if (executionContextId.isJust()) {
203 contextId = executionContextId.fromJust(); 204 contextId = executionContextId.fromJust();
204 } else { 205 } else {
205 v8::HandleScope handles(m_inspector->isolate()); 206 v8::HandleScope handles(m_inspector->isolate());
206 v8::Local<v8::Context> defaultContext = m_inspector->client()->ensureDef aultContextInGroup(m_session->contextGroupId()); 207 v8::Local<v8::Context> defaultContext = m_inspector->client()->ensureDef aultContextInGroup(m_session->contextGroupId());
207 if (defaultContext.IsEmpty()) { 208 if (defaultContext.IsEmpty()) {
208 callback->sendFailure("Cannot find default execution context"); 209 callback->sendFailure("Cannot find default execution context");
209 return; 210 return;
210 } 211 }
211 contextId = V8InspectorImpl::contextId(defaultContext); 212 contextId = V8Debugger::contextId(defaultContext);
212 } 213 }
213 214
214 InjectedScript::ContextScope scope(errorString, m_inspector, m_session->cont extGroupId(), contextId); 215 InjectedScript::ContextScope scope(errorString, m_inspector, m_session->cont extGroupId(), contextId);
215 if (!scope.initialize()) { 216 if (!scope.initialize()) {
216 callback->sendFailure(*errorString); 217 callback->sendFailure(*errorString);
217 return; 218 return;
218 } 219 }
219 220
220 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) 221 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false))
221 scope.ignoreExceptionsAndMuteConsole(); 222 scope.ignoreExceptionsAndMuteConsole();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (!scope.object()->IsObject()) { 370 if (!scope.object()->IsObject()) {
370 *errorString = "Value with given id is not an object"; 371 *errorString = "Value with given id is not an object";
371 return; 372 return;
372 } 373 }
373 374
374 v8::Local<v8::Object> object = scope.object().As<v8::Object>(); 375 v8::Local<v8::Object> object = scope.object().As<v8::Object>();
375 scope.injectedScript()->getProperties(errorString, object, scope.objectGroup Name(), ownProperties.fromMaybe(false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(false), result, exceptionDetails); 376 scope.injectedScript()->getProperties(errorString, object, scope.objectGroup Name(), ownProperties.fromMaybe(false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(false), result, exceptionDetails);
376 if (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropert iesOnly.fromMaybe(false)) 377 if (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropert iesOnly.fromMaybe(false))
377 return; 378 return;
378 v8::Local<v8::Array> propertiesArray; 379 v8::Local<v8::Array> propertiesArray;
379 if (hasInternalError(errorString, !m_inspector->internalProperties(scope.con text(), scope.object()).ToLocal(&propertiesArray))) 380 if (hasInternalError(errorString, !m_inspector->debugger()->internalProperti es(scope.context(), scope.object()).ToLocal(&propertiesArray)))
380 return; 381 return;
381 std::unique_ptr<protocol::Array<InternalPropertyDescriptor>> propertiesProto colArray = protocol::Array<InternalPropertyDescriptor>::create(); 382 std::unique_ptr<protocol::Array<InternalPropertyDescriptor>> propertiesProto colArray = protocol::Array<InternalPropertyDescriptor>::create();
382 for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) { 383 for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) {
383 v8::Local<v8::Value> name; 384 v8::Local<v8::Value> name;
384 if (hasInternalError(errorString, !propertiesArray->Get(scope.context(), i).ToLocal(&name)) || !name->IsString()) 385 if (hasInternalError(errorString, !propertiesArray->Get(scope.context(), i).ToLocal(&name)) || !name->IsString())
385 return; 386 return;
386 v8::Local<v8::Value> value; 387 v8::Local<v8::Value> value;
387 if (hasInternalError(errorString, !propertiesArray->Get(scope.context(), i + 1).ToLocal(&value))) 388 if (hasInternalError(errorString, !propertiesArray->Get(scope.context(), i + 1).ToLocal(&value)))
388 return; 389 return;
389 std::unique_ptr<RemoteObject> wrappedValue = scope.injectedScript()->wra pObject(errorString, value, scope.objectGroupName()); 390 std::unique_ptr<RemoteObject> wrappedValue = scope.injectedScript()->wra pObject(errorString, value, scope.objectGroupName());
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 reportMessage(message, true); 593 reportMessage(message, true);
593 } 594 }
594 595
595 void V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP review) 596 void V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP review)
596 { 597 {
597 message->reportToFrontend(&m_frontend, m_session, generatePreview); 598 message->reportToFrontend(&m_frontend, m_session, generatePreview);
598 m_frontend.flush(); 599 m_frontend.flush();
599 } 600 }
600 601
601 } // namespace blink 602 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698