OLD | NEW |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 private: | 109 private: |
110 static void thenCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 110 static void thenCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
111 ProtocolPromiseHandler<Callback>* handler = | 111 ProtocolPromiseHandler<Callback>* handler = |
112 static_cast<ProtocolPromiseHandler<Callback>*>( | 112 static_cast<ProtocolPromiseHandler<Callback>*>( |
113 info.Data().As<v8::External>()->Value()); | 113 info.Data().As<v8::External>()->Value()); |
114 DCHECK(handler); | 114 DCHECK(handler); |
115 v8::Local<v8::Value> value = | 115 v8::Local<v8::Value> value = |
116 info.Length() > 0 | 116 info.Length() > 0 |
117 ? info[0] | 117 ? info[0] |
118 : v8::Local<v8::Value>::Cast(v8::Undefined(info.GetIsolate())); | 118 : v8::Local<v8::Value>::Cast(v8::Undefined(info.GetIsolate())); |
| 119 std::unique_ptr<protocol::Runtime::RemoteObject> wrappedValue( |
| 120 handler->wrapObject(value)); |
| 121 if (!wrappedValue) return; |
119 handler->m_callback->sendSuccess( | 122 handler->m_callback->sendSuccess( |
120 handler->wrapObject(value), | 123 std::move(wrappedValue), Maybe<protocol::Runtime::ExceptionDetails>()); |
121 Maybe<protocol::Runtime::ExceptionDetails>()); | |
122 } | 124 } |
123 | 125 |
124 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 126 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
125 ProtocolPromiseHandler<Callback>* handler = | 127 ProtocolPromiseHandler<Callback>* handler = |
126 static_cast<ProtocolPromiseHandler<Callback>*>( | 128 static_cast<ProtocolPromiseHandler<Callback>*>( |
127 info.Data().As<v8::External>()->Value()); | 129 info.Data().As<v8::External>()->Value()); |
128 DCHECK(handler); | 130 DCHECK(handler); |
129 v8::Local<v8::Value> value = | 131 v8::Local<v8::Value> value = |
130 info.Length() > 0 | 132 info.Length() > 0 |
131 ? info[0] | 133 ? info[0] |
132 : v8::Local<v8::Value>::Cast(v8::Undefined(info.GetIsolate())); | 134 : v8::Local<v8::Value>::Cast(v8::Undefined(info.GetIsolate())); |
133 | 135 |
| 136 std::unique_ptr<protocol::Runtime::RemoteObject> wrappedValue( |
| 137 handler->wrapObject(value)); |
| 138 if (!wrappedValue) return; |
| 139 |
134 std::unique_ptr<V8StackTraceImpl> stack = | 140 std::unique_ptr<V8StackTraceImpl> stack = |
135 handler->m_inspector->debugger()->captureStackTrace(true); | 141 handler->m_inspector->debugger()->captureStackTrace(true); |
136 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails = | 142 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails = |
137 protocol::Runtime::ExceptionDetails::create() | 143 protocol::Runtime::ExceptionDetails::create() |
138 .setExceptionId(handler->m_inspector->nextExceptionId()) | 144 .setExceptionId(handler->m_inspector->nextExceptionId()) |
139 .setText("Uncaught (in promise)") | 145 .setText("Uncaught (in promise)") |
140 .setLineNumber(stack && !stack->isEmpty() ? stack->topLineNumber() | 146 .setLineNumber(stack && !stack->isEmpty() ? stack->topLineNumber() |
141 : 0) | 147 : 0) |
142 .setColumnNumber( | 148 .setColumnNumber( |
143 stack && !stack->isEmpty() ? stack->topColumnNumber() : 0) | 149 stack && !stack->isEmpty() ? stack->topColumnNumber() : 0) |
144 .setException(handler->wrapObject(value)) | 150 .setException(wrappedValue->clone()) |
145 .build(); | 151 .build(); |
146 if (stack) | 152 if (stack) |
147 exceptionDetails->setStackTrace(stack->buildInspectorObjectImpl()); | 153 exceptionDetails->setStackTrace(stack->buildInspectorObjectImpl()); |
148 if (stack && !stack->isEmpty()) | 154 if (stack && !stack->isEmpty()) |
149 exceptionDetails->setScriptId(toString16(stack->topScriptId())); | 155 exceptionDetails->setScriptId(toString16(stack->topScriptId())); |
150 handler->m_callback->sendSuccess(handler->wrapObject(value), | 156 handler->m_callback->sendSuccess(std::move(wrappedValue), |
151 std::move(exceptionDetails)); | 157 std::move(exceptionDetails)); |
152 } | 158 } |
153 | 159 |
154 ProtocolPromiseHandler(V8InspectorImpl* inspector, int contextGroupId, | 160 ProtocolPromiseHandler(V8InspectorImpl* inspector, int contextGroupId, |
155 int executionContextId, const String16& objectGroup, | 161 int executionContextId, const String16& objectGroup, |
156 bool returnByValue, bool generatePreview, | 162 bool returnByValue, bool generatePreview, |
157 std::unique_ptr<Callback> callback) | 163 std::unique_ptr<Callback> callback) |
158 : m_inspector(inspector), | 164 : m_inspector(inspector), |
159 m_contextGroupId(contextGroupId), | 165 m_contextGroupId(contextGroupId), |
160 m_executionContextId(executionContextId), | 166 m_executionContextId(executionContextId), |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 } | 729 } |
724 | 730 |
725 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, | 731 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, |
726 bool generatePreview) { | 732 bool generatePreview) { |
727 message->reportToFrontend(&m_frontend, m_session, generatePreview); | 733 message->reportToFrontend(&m_frontend, m_session, generatePreview); |
728 m_frontend.flush(); | 734 m_frontend.flush(); |
729 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId()); | 735 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId()); |
730 } | 736 } |
731 | 737 |
732 } // namespace v8_inspector | 738 } // namespace v8_inspector |
OLD | NEW |