Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 v8::TryCatch tryCatch(m_context->isolate()); | 138 v8::TryCatch tryCatch(m_context->isolate()); |
| 139 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); | 139 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); |
| 140 if (tryCatch.HasCaught()) { | 140 if (tryCatch.HasCaught()) { |
| 141 *exceptionDetails = createExceptionDetails(errorString, tryCatch, groupName, | 141 *exceptionDetails = createExceptionDetails(errorString, tryCatch, groupName, |
| 142 generatePreview); | 142 generatePreview); |
| 143 // FIXME: make properties optional | 143 // FIXME: make properties optional |
| 144 *properties = Array<PropertyDescriptor>::create(); | 144 *properties = Array<PropertyDescriptor>::create(); |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 | 147 |
| 148 std::unique_ptr<protocol::Value> protocolValue = | 148 std::unique_ptr<protocol::Value> protocolValue = |
|
dgozman
2016/09/19 17:35:05
Looks like resultValue could be empty here?
kozy
2016/09/20 15:34:27
Added check. I think that it should be not empty i
| |
| 149 toProtocolValue(context, resultValue); | 149 toProtocolValue(errorString, context, resultValue); |
| 150 if (hasInternalError(errorString, !protocolValue)) return; | 150 if (!protocolValue) return; |
| 151 protocol::ErrorSupport errors(errorString); | 151 protocol::ErrorSupport errors(errorString); |
| 152 std::unique_ptr<Array<PropertyDescriptor>> result = | 152 std::unique_ptr<Array<PropertyDescriptor>> result = |
| 153 Array<PropertyDescriptor>::parse(protocolValue.get(), &errors); | 153 Array<PropertyDescriptor>::parse(protocolValue.get(), &errors); |
| 154 if (!hasInternalError(errorString, errors.hasErrors())) | 154 if (!hasInternalError(errorString, errors.hasErrors())) |
| 155 *properties = std::move(result); | 155 *properties = std::move(result); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void InjectedScript::releaseObject(const String16& objectId) { | 158 void InjectedScript::releaseObject(const String16& objectId) { |
| 159 std::unique_ptr<protocol::Value> parsedObjectId = | 159 std::unique_ptr<protocol::Value> parsedObjectId = |
| 160 protocol::parseJSON(objectId); | 160 protocol::parseJSON(objectId); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 173 bool generatePreview) const { | 173 bool generatePreview) const { |
| 174 v8::HandleScope handles(m_context->isolate()); | 174 v8::HandleScope handles(m_context->isolate()); |
| 175 v8::Local<v8::Value> wrappedObject; | 175 v8::Local<v8::Value> wrappedObject; |
| 176 v8::Local<v8::Context> context = m_context->context(); | 176 v8::Local<v8::Context> context = m_context->context(); |
| 177 if (!wrapValue(errorString, value, groupName, forceValueType, generatePreview) | 177 if (!wrapValue(errorString, value, groupName, forceValueType, generatePreview) |
| 178 .ToLocal(&wrappedObject)) | 178 .ToLocal(&wrappedObject)) |
| 179 return nullptr; | 179 return nullptr; |
| 180 protocol::ErrorSupport errors; | 180 protocol::ErrorSupport errors; |
| 181 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = | 181 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = |
| 182 protocol::Runtime::RemoteObject::parse( | 182 protocol::Runtime::RemoteObject::parse( |
| 183 toProtocolValue(context, wrappedObject).get(), &errors); | 183 toProtocolValue(errorString, context, wrappedObject).get(), &errors); |
|
dgozman
2016/09/19 17:35:05
Should check return value of toProtocolValue and u
kozy
2016/09/20 15:34:27
Done.
| |
| 184 if (!remoteObject) *errorString = "Object has too long reference chain"; | |
| 185 return remoteObject; | 184 return remoteObject; |
| 186 } | 185 } |
| 187 | 186 |
| 188 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, | 187 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, |
| 189 v8::Local<v8::Object> object, | 188 v8::Local<v8::Object> object, |
| 190 v8::Local<v8::Name> key, | 189 v8::Local<v8::Name> key, |
| 191 const String16& groupName, | 190 const String16& groupName, |
| 192 bool forceValueType, | 191 bool forceValueType, |
| 193 bool generatePreview) const { | 192 bool generatePreview) const { |
| 194 v8::Local<v8::Value> property; | 193 v8::Local<v8::Value> property; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 v8::HandleScope handles(m_context->isolate()); | 263 v8::HandleScope handles(m_context->isolate()); |
| 265 v8::Local<v8::Context> context = m_context->context(); | 264 v8::Local<v8::Context> context = m_context->context(); |
| 266 V8FunctionCall function(m_context->inspector(), context, v8Value(), | 265 V8FunctionCall function(m_context->inspector(), context, v8Value(), |
| 267 "wrapTable"); | 266 "wrapTable"); |
| 268 function.appendArgument(table); | 267 function.appendArgument(table); |
| 269 if (columns.IsEmpty()) | 268 if (columns.IsEmpty()) |
| 270 function.appendArgument(false); | 269 function.appendArgument(false); |
| 271 else | 270 else |
| 272 function.appendArgument(columns); | 271 function.appendArgument(columns); |
| 273 bool hadException = false; | 272 bool hadException = false; |
| 274 v8::Local<v8::Value> r = function.call(hadException); | 273 v8::Local<v8::Value> r = function.call(hadException); |
|
dgozman
2016/09/19 17:35:05
Looks like r could be empty here?
kozy
2016/09/20 15:34:27
Done.
| |
| 275 if (hadException) return nullptr; | 274 if (hadException) return nullptr; |
| 276 protocol::ErrorSupport errors; | 275 protocol::ErrorSupport errors; |
| 276 protocol::ErrorString errorString; | |
| 277 return protocol::Runtime::RemoteObject::parse( | 277 return protocol::Runtime::RemoteObject::parse( |
| 278 toProtocolValue(context, r).get(), &errors); | 278 toProtocolValue(&errorString, context, r).get(), &errors); |
|
dgozman
2016/09/19 17:35:05
Should check return value of toProtocolValue and u
kozy
2016/09/20 15:34:27
Done.
| |
| 279 } | 279 } |
| 280 | 280 |
| 281 bool InjectedScript::findObject(ErrorString* errorString, | 281 bool InjectedScript::findObject(ErrorString* errorString, |
| 282 const RemoteObjectId& objectId, | 282 const RemoteObjectId& objectId, |
| 283 v8::Local<v8::Value>* outObject) const { | 283 v8::Local<v8::Value>* outObject) const { |
| 284 *outObject = m_native->objectForId(objectId.id()); | 284 *outObject = m_native->objectForId(objectId.id()); |
| 285 if (outObject->IsEmpty()) | 285 if (outObject->IsEmpty()) |
| 286 *errorString = "Could not find object with given id"; | 286 *errorString = "Could not find object with given id"; |
| 287 return !outObject->IsEmpty(); | 287 return !outObject->IsEmpty(); |
| 288 } | 288 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 void InjectedScript::CallFrameScope::findInjectedScript( | 562 void InjectedScript::CallFrameScope::findInjectedScript( |
| 563 V8InspectorSessionImpl* session) { | 563 V8InspectorSessionImpl* session) { |
| 564 std::unique_ptr<RemoteCallFrameId> remoteId = | 564 std::unique_ptr<RemoteCallFrameId> remoteId = |
| 565 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); | 565 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); |
| 566 if (!remoteId) return; | 566 if (!remoteId) return; |
| 567 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 567 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
| 568 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()); | 568 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()); |
| 569 } | 569 } |
| 570 | 570 |
| 571 } // namespace v8_inspector | 571 } // namespace v8_inspector |
| OLD | NEW |