| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // FIXME: make properties optional | 143 // FIXME: make properties optional |
| 144 *properties = Array<PropertyDescriptor>::create(); | 144 *properties = Array<PropertyDescriptor>::create(); |
| 145 return Response::OK(); | 145 return Response::OK(); |
| 146 } | 146 } |
| 147 if (resultValue.IsEmpty()) return Response::InternalError(); | 147 if (resultValue.IsEmpty()) return Response::InternalError(); |
| 148 std::unique_ptr<protocol::Value> protocolValue; | 148 std::unique_ptr<protocol::Value> protocolValue; |
| 149 Response response = toProtocolValue(context, resultValue, &protocolValue); | 149 Response response = toProtocolValue(context, resultValue, &protocolValue); |
| 150 if (!response.isSuccess()) return response; | 150 if (!response.isSuccess()) return response; |
| 151 protocol::ErrorSupport errors; | 151 protocol::ErrorSupport errors; |
| 152 std::unique_ptr<Array<PropertyDescriptor>> result = | 152 std::unique_ptr<Array<PropertyDescriptor>> result = |
| 153 Array<PropertyDescriptor>::parse(protocolValue.get(), &errors); | 153 Array<PropertyDescriptor>::fromValue(protocolValue.get(), &errors); |
| 154 if (errors.hasErrors()) return Response::Error(errors.errors()); | 154 if (errors.hasErrors()) return Response::Error(errors.errors()); |
| 155 *properties = std::move(result); | 155 *properties = std::move(result); |
| 156 return Response::OK(); | 156 return Response::OK(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void InjectedScript::releaseObject(const String16& objectId) { | 159 void InjectedScript::releaseObject(const String16& objectId) { |
| 160 std::unique_ptr<protocol::Value> parsedObjectId = | 160 std::unique_ptr<protocol::Value> parsedObjectId = |
| 161 protocol::StringUtil::parseJSON(objectId); | 161 protocol::StringUtil::parseJSON(objectId); |
| 162 if (!parsedObjectId) return; | 162 if (!parsedObjectId) return; |
| 163 protocol::DictionaryValue* object = | 163 protocol::DictionaryValue* object = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 177 v8::Local<v8::Context> context = m_context->context(); | 177 v8::Local<v8::Context> context = m_context->context(); |
| 178 Response response = wrapValue(value, groupName, forceValueType, | 178 Response response = wrapValue(value, groupName, forceValueType, |
| 179 generatePreview, &wrappedObject); | 179 generatePreview, &wrappedObject); |
| 180 if (!response.isSuccess()) return response; | 180 if (!response.isSuccess()) return response; |
| 181 protocol::ErrorSupport errors; | 181 protocol::ErrorSupport errors; |
| 182 std::unique_ptr<protocol::Value> protocolValue; | 182 std::unique_ptr<protocol::Value> protocolValue; |
| 183 response = toProtocolValue(context, wrappedObject, &protocolValue); | 183 response = toProtocolValue(context, wrappedObject, &protocolValue); |
| 184 if (!response.isSuccess()) return response; | 184 if (!response.isSuccess()) return response; |
| 185 | 185 |
| 186 *result = | 186 *result = |
| 187 protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); | 187 protocol::Runtime::RemoteObject::fromValue(protocolValue.get(), &errors); |
| 188 if (!result->get()) return Response::Error(errors.errors()); | 188 if (!result->get()) return Response::Error(errors.errors()); |
| 189 return Response::OK(); | 189 return Response::OK(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 Response InjectedScript::wrapObjectProperty(v8::Local<v8::Object> object, | 192 Response InjectedScript::wrapObjectProperty(v8::Local<v8::Object> object, |
| 193 v8::Local<v8::Name> key, | 193 v8::Local<v8::Name> key, |
| 194 const String16& groupName, | 194 const String16& groupName, |
| 195 bool forceValueType, | 195 bool forceValueType, |
| 196 bool generatePreview) const { | 196 bool generatePreview) const { |
| 197 v8::Local<v8::Value> property; | 197 v8::Local<v8::Value> property; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 function.appendArgument(false); | 253 function.appendArgument(false); |
| 254 else | 254 else |
| 255 function.appendArgument(columns); | 255 function.appendArgument(columns); |
| 256 bool hadException = false; | 256 bool hadException = false; |
| 257 v8::Local<v8::Value> r = function.call(hadException); | 257 v8::Local<v8::Value> r = function.call(hadException); |
| 258 if (hadException || r.IsEmpty()) return nullptr; | 258 if (hadException || r.IsEmpty()) return nullptr; |
| 259 std::unique_ptr<protocol::Value> protocolValue; | 259 std::unique_ptr<protocol::Value> protocolValue; |
| 260 Response response = toProtocolValue(context, r, &protocolValue); | 260 Response response = toProtocolValue(context, r, &protocolValue); |
| 261 if (!response.isSuccess()) return nullptr; | 261 if (!response.isSuccess()) return nullptr; |
| 262 protocol::ErrorSupport errors; | 262 protocol::ErrorSupport errors; |
| 263 return protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); | 263 return protocol::Runtime::RemoteObject::fromValue(protocolValue.get(), |
| 264 &errors); |
| 264 } | 265 } |
| 265 | 266 |
| 266 Response InjectedScript::findObject(const RemoteObjectId& objectId, | 267 Response InjectedScript::findObject(const RemoteObjectId& objectId, |
| 267 v8::Local<v8::Value>* outObject) const { | 268 v8::Local<v8::Value>* outObject) const { |
| 268 *outObject = m_native->objectForId(objectId.id()); | 269 *outObject = m_native->objectForId(objectId.id()); |
| 269 if (outObject->IsEmpty()) | 270 if (outObject->IsEmpty()) |
| 270 return Response::Error("Could not find object with given id"); | 271 return Response::Error("Could not find object with given id"); |
| 271 return Response::OK(); | 272 return Response::OK(); |
| 272 } | 273 } |
| 273 | 274 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 if (!response.isSuccess()) return response; | 311 if (!response.isSuccess()) return response; |
| 311 if (remoteObjectId->contextId() != m_context->contextId()) | 312 if (remoteObjectId->contextId() != m_context->contextId()) |
| 312 return Response::Error( | 313 return Response::Error( |
| 313 "Argument should belong to the same JavaScript world as target " | 314 "Argument should belong to the same JavaScript world as target " |
| 314 "object"); | 315 "object"); |
| 315 return findObject(*remoteObjectId, result); | 316 return findObject(*remoteObjectId, result); |
| 316 } | 317 } |
| 317 if (callArgument->hasValue() || callArgument->hasUnserializableValue()) { | 318 if (callArgument->hasValue() || callArgument->hasUnserializableValue()) { |
| 318 String16 value = | 319 String16 value = |
| 319 callArgument->hasValue() | 320 callArgument->hasValue() |
| 320 ? callArgument->getValue(nullptr)->toJSONString() | 321 ? callArgument->getValue(nullptr)->serialize() |
| 321 : "Number(\"" + callArgument->getUnserializableValue("") + "\")"; | 322 : "Number(\"" + callArgument->getUnserializableValue("") + "\")"; |
| 322 if (!m_context->inspector() | 323 if (!m_context->inspector() |
| 323 ->compileAndRunInternalScript( | 324 ->compileAndRunInternalScript( |
| 324 m_context->context(), toV8String(m_context->isolate(), value)) | 325 m_context->context(), toV8String(m_context->isolate(), value)) |
| 325 .ToLocal(result)) { | 326 .ToLocal(result)) { |
| 326 return Response::Error("Couldn't parse value object in call argument"); | 327 return Response::Error("Couldn't parse value object in call argument"); |
| 327 } | 328 } |
| 328 return Response::OK(); | 329 return Response::OK(); |
| 329 } | 330 } |
| 330 *result = v8::Undefined(m_context->isolate()); | 331 *result = v8::Undefined(m_context->isolate()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 Response InjectedScript::CallFrameScope::findInjectedScript( | 534 Response InjectedScript::CallFrameScope::findInjectedScript( |
| 534 V8InspectorSessionImpl* session) { | 535 V8InspectorSessionImpl* session) { |
| 535 std::unique_ptr<RemoteCallFrameId> remoteId; | 536 std::unique_ptr<RemoteCallFrameId> remoteId; |
| 536 Response response = RemoteCallFrameId::parse(m_remoteCallFrameId, &remoteId); | 537 Response response = RemoteCallFrameId::parse(m_remoteCallFrameId, &remoteId); |
| 537 if (!response.isSuccess()) return response; | 538 if (!response.isSuccess()) return response; |
| 538 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 539 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
| 539 return session->findInjectedScript(remoteId.get(), m_injectedScript); | 540 return session->findInjectedScript(remoteId.get(), m_injectedScript); |
| 540 } | 541 } |
| 541 | 542 |
| 542 } // namespace v8_inspector | 543 } // namespace v8_inspector |
| OLD | NEW |