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

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

Issue 2381113003: [DevTools] fix crash in wrapping result for async Runtime.evaluate (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 rawCallback->sendFailure("Internal error"); 89 rawCallback->sendFailure("Internal error");
90 return; 90 return;
91 } 91 }
92 } 92 }
93 private: 93 private:
94 static void thenCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 94 static void thenCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
95 { 95 {
96 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH andler<Callback>*>(info.Data().As<v8::External>()->Value()); 96 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH andler<Callback>*>(info.Data().As<v8::External>()->Value());
97 DCHECK(handler); 97 DCHECK(handler);
98 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8: :Value>::Cast(v8::Undefined(info.GetIsolate())); 98 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8: :Value>::Cast(v8::Undefined(info.GetIsolate()));
99 handler->m_callback->sendSuccess(handler->wrapObject(value), Maybe<proto col::Runtime::ExceptionDetails>()); 99 std::unique_ptr<protocol::Runtime::RemoteObject> wrappedValue(handler->w rapObject(value));
100 if (!wrappedValue)
101 return;
102 handler->m_callback->sendSuccess(std::move(wrappedValue), Maybe<protocol ::Runtime::ExceptionDetails>());
100 } 103 }
101 104
102 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 105 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
103 { 106 {
104 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH andler<Callback>*>(info.Data().As<v8::External>()->Value()); 107 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH andler<Callback>*>(info.Data().As<v8::External>()->Value());
105 DCHECK(handler); 108 DCHECK(handler);
106 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8: :Value>::Cast(v8::Undefined(info.GetIsolate())); 109 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8: :Value>::Cast(v8::Undefined(info.GetIsolate()));
107 110
111 std::unique_ptr<protocol::Runtime::RemoteObject> wrappedValue(handler->w rapObject(value));
112 if (!wrappedValue)
113 return;
108 std::unique_ptr<V8StackTraceImpl> stack = handler->m_inspector->debugger ()->captureStackTrace(true); 114 std::unique_ptr<V8StackTraceImpl> stack = handler->m_inspector->debugger ()->captureStackTrace(true);
109 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails = protocol::Runtime::ExceptionDetails::create() 115 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails = protocol::Runtime::ExceptionDetails::create()
110 .setExceptionId(handler->m_inspector->nextExceptionId()) 116 .setExceptionId(handler->m_inspector->nextExceptionId())
111 .setText("Uncaught (in promise)") 117 .setText("Uncaught (in promise)")
112 .setLineNumber(stack && !stack->isEmpty() ? stack->topLineNumber() : 0) 118 .setLineNumber(stack && !stack->isEmpty() ? stack->topLineNumber() : 0)
113 .setColumnNumber(stack && !stack->isEmpty() ? stack->topColumnNumber () : 0) 119 .setColumnNumber(stack && !stack->isEmpty() ? stack->topColumnNumber () : 0)
114 .setException(handler->wrapObject(value)) 120 .setException(wrappedValue->clone())
115 .build(); 121 .build();
116 if (stack) 122 if (stack)
117 exceptionDetails->setStackTrace(stack->buildInspectorObjectImpl()); 123 exceptionDetails->setStackTrace(stack->buildInspectorObjectImpl());
118 if (stack && !stack->isEmpty()) 124 if (stack && !stack->isEmpty())
119 exceptionDetails->setScriptId(stack->topScriptId()); 125 exceptionDetails->setScriptId(stack->topScriptId());
120 handler->m_callback->sendSuccess(handler->wrapObject(value), std::move(e xceptionDetails)); 126 handler->m_callback->sendSuccess(std::move(wrappedValue), std::move(exce ptionDetails));
121 } 127 }
122 128
123 ProtocolPromiseHandler(V8InspectorImpl* inspector, int contextGroupId, int e xecutionContextId, const String16& objectGroup, bool returnByValue, bool generat ePreview, std::unique_ptr<Callback> callback) 129 ProtocolPromiseHandler(V8InspectorImpl* inspector, int contextGroupId, int e xecutionContextId, const String16& objectGroup, bool returnByValue, bool generat ePreview, std::unique_ptr<Callback> callback)
124 : m_inspector(inspector) 130 : m_inspector(inspector)
125 , m_contextGroupId(contextGroupId) 131 , m_contextGroupId(contextGroupId)
126 , m_executionContextId(executionContextId) 132 , m_executionContextId(executionContextId)
127 , m_objectGroup(objectGroup) 133 , m_objectGroup(objectGroup)
128 , m_returnByValue(returnByValue) 134 , m_returnByValue(returnByValue)
129 , m_generatePreview(generatePreview) 135 , m_generatePreview(generatePreview)
130 , m_callback(std::move(callback)) 136 , m_callback(std::move(callback))
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 687 }
682 688
683 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP review) 689 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP review)
684 { 690 {
685 message->reportToFrontend(&m_frontend, m_session, generatePreview); 691 message->reportToFrontend(&m_frontend, m_session, generatePreview);
686 m_frontend.flush(); 692 m_frontend.flush();
687 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId()); 693 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId());
688 } 694 }
689 695
690 } // namespace v8_inspector 696 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698