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