| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 rawCallback->sendFailure("Internal error"); | 92 rawCallback->sendFailure("Internal error"); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 private: | 96 private: |
| 97 static void thenCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | 97 static void thenCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 98 { | 98 { |
| 99 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH
andler<Callback>*>(info.Data().As<v8::External>()->Value()); | 99 ProtocolPromiseHandler<Callback>* handler = static_cast<ProtocolPromiseH
andler<Callback>*>(info.Data().As<v8::External>()->Value()); |
| 100 DCHECK(handler); | 100 DCHECK(handler); |
| 101 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8:
:Value>::Cast(v8::Undefined(info.GetIsolate())); | 101 v8::Local<v8::Value> value = info.Length() > 0 ? info[0] : v8::Local<v8:
:Value>::Cast(v8::Undefined(info.GetIsolate())); |
| 102 handler->m_callback->sendSuccess(handler->wrapObject(value), Maybe<bool>
(), Maybe<protocol::Runtime::ExceptionDetails>()); | 102 handler->m_callback->sendSuccess(handler->wrapObject(value), Maybe<proto
col::Runtime::ExceptionDetails>()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | 105 static void catchCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 106 { | 106 { |
| 107 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()); |
| 108 DCHECK(handler); | 108 DCHECK(handler); |
| 109 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())); |
| 110 | 110 |
| 111 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails; | 111 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails; |
| 112 std::unique_ptr<V8StackTraceImpl> stack = handler->m_inspector->debugger
()->captureStackTrace(true); | 112 std::unique_ptr<V8StackTraceImpl> stack = handler->m_inspector->debugger
()->captureStackTrace(true); |
| 113 if (stack) { | 113 if (stack) { |
| 114 exceptionDetails = protocol::Runtime::ExceptionDetails::create() | 114 exceptionDetails = protocol::Runtime::ExceptionDetails::create() |
| 115 .setText("Promise was rejected") | 115 .setText("Promise was rejected") |
| 116 .setLineNumber(!stack->isEmpty() ? stack->topLineNumber() : 0) | 116 .setLineNumber(!stack->isEmpty() ? stack->topLineNumber() : 0) |
| 117 .setColumnNumber(!stack->isEmpty() ? stack->topColumnNumber() :
0) | 117 .setColumnNumber(!stack->isEmpty() ? stack->topColumnNumber() :
0) |
| 118 .setScriptId(!stack->isEmpty() ? stack->topScriptId() : String16
()) | 118 .setScriptId(!stack->isEmpty() ? stack->topScriptId() : String16
()) |
| 119 .setStackTrace(stack->buildInspectorObjectImpl()) | 119 .setStackTrace(stack->buildInspectorObjectImpl()) |
| 120 .build(); | 120 .build(); |
| 121 } | 121 } |
| 122 handler->m_callback->sendSuccess(handler->wrapObject(value), true, std::
move(exceptionDetails)); | 122 handler->m_callback->sendSuccess(handler->wrapObject(value), std::move(e
xceptionDetails)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 ProtocolPromiseHandler(V8InspectorImpl* inspector, int contextGroupId, int e
xecutionContextId, const String16& objectGroup, bool returnByValue, bool generat
ePreview, std::unique_ptr<Callback> callback) | 125 ProtocolPromiseHandler(V8InspectorImpl* inspector, int contextGroupId, int e
xecutionContextId, const String16& objectGroup, bool returnByValue, bool generat
ePreview, std::unique_ptr<Callback> callback) |
| 126 : m_inspector(inspector) | 126 : m_inspector(inspector) |
| 127 , m_contextGroupId(contextGroupId) | 127 , m_contextGroupId(contextGroupId) |
| 128 , m_executionContextId(executionContextId) | 128 , m_executionContextId(executionContextId) |
| 129 , m_objectGroup(objectGroup) | 129 , m_objectGroup(objectGroup) |
| 130 , m_returnByValue(returnByValue) | 130 , m_returnByValue(returnByValue) |
| 131 , m_generatePreview(generatePreview) | 131 , m_generatePreview(generatePreview) |
| 132 , m_callback(std::move(callback)) | 132 , m_callback(std::move(callback)) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 bool m_returnByValue; | 169 bool m_returnByValue; |
| 170 bool m_generatePreview; | 170 bool m_generatePreview; |
| 171 std::unique_ptr<Callback> m_callback; | 171 std::unique_ptr<Callback> m_callback; |
| 172 v8::Global<v8::External> m_wrapper; | 172 v8::Global<v8::External> m_wrapper; |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 template<typename Callback> | 175 template<typename Callback> |
| 176 bool wrapEvaluateResultAsync(InjectedScript* injectedScript, v8::MaybeLocal<v8::
Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& objectGro
up, bool returnByValue, bool generatePreview, Callback* callback) | 176 bool wrapEvaluateResultAsync(InjectedScript* injectedScript, v8::MaybeLocal<v8::
Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& objectGro
up, bool returnByValue, bool generatePreview, Callback* callback) |
| 177 { | 177 { |
| 178 std::unique_ptr<RemoteObject> result; | 178 std::unique_ptr<RemoteObject> result; |
| 179 Maybe<bool> wasThrown; | |
| 180 Maybe<protocol::Runtime::ExceptionDetails> exceptionDetails; | 179 Maybe<protocol::Runtime::ExceptionDetails> exceptionDetails; |
| 181 | 180 |
| 182 ErrorString errorString; | 181 ErrorString errorString; |
| 183 injectedScript->wrapEvaluateResult(&errorString, | 182 injectedScript->wrapEvaluateResult(&errorString, |
| 184 maybeResultValue, | 183 maybeResultValue, |
| 185 tryCatch, | 184 tryCatch, |
| 186 objectGroup, | 185 objectGroup, |
| 187 returnByValue, | 186 returnByValue, |
| 188 generatePreview, | 187 generatePreview, |
| 189 &result, | 188 &result, |
| 190 &wasThrown, | |
| 191 &exceptionDetails); | 189 &exceptionDetails); |
| 192 if (errorString.isEmpty()) { | 190 if (errorString.isEmpty()) { |
| 193 callback->sendSuccess(std::move(result), wasThrown, exceptionDetails); | 191 callback->sendSuccess(std::move(result), exceptionDetails); |
| 194 return true; | 192 return true; |
| 195 } | 193 } |
| 196 callback->sendFailure(errorString); | 194 callback->sendFailure(errorString); |
| 197 return false; | 195 return false; |
| 198 } | 196 } |
| 199 | 197 |
| 200 int ensureContext(ErrorString* errorString, V8InspectorImpl* inspector, int cont
extGroupId, const Maybe<int>& executionContextId) | 198 int ensureContext(ErrorString* errorString, V8InspectorImpl* inspector, int cont
extGroupId, const Maybe<int>& executionContextId) |
| 201 { | 199 { |
| 202 int contextId; | 200 int contextId; |
| 203 if (executionContextId.isJust()) { | 201 if (executionContextId.isJust()) { |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 reportMessage(message, true); | 681 reportMessage(message, true); |
| 684 } | 682 } |
| 685 | 683 |
| 686 void V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP
review) | 684 void V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP
review) |
| 687 { | 685 { |
| 688 message->reportToFrontend(&m_frontend, m_session, generatePreview); | 686 message->reportToFrontend(&m_frontend, m_session, generatePreview); |
| 689 m_frontend.flush(); | 687 m_frontend.flush(); |
| 690 } | 688 } |
| 691 | 689 |
| 692 } // namespace blink | 690 } // namespace blink |
| OLD | NEW |