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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 namespace V8RuntimeAgentImplState { | 45 namespace V8RuntimeAgentImplState { |
46 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
"; | 46 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
"; |
47 }; | 47 }; |
48 | 48 |
49 using protocol::Runtime::ExceptionDetails; | 49 using protocol::Runtime::ExceptionDetails; |
50 using protocol::Runtime::RemoteObject; | 50 using protocol::Runtime::RemoteObject; |
51 | 51 |
52 static bool checkInternalError(ErrorString* errorString, bool success) | |
53 { | |
54 if (!success) | |
55 *errorString = "Internal error"; | |
56 return success; | |
57 } | |
58 | |
59 PassOwnPtr<V8RuntimeAgent> V8RuntimeAgent::create(V8Debugger* debugger, int cont
extGroupId) | 52 PassOwnPtr<V8RuntimeAgent> V8RuntimeAgent::create(V8Debugger* debugger, int cont
extGroupId) |
60 { | 53 { |
61 return adoptPtr(new V8RuntimeAgentImpl(static_cast<V8DebuggerImpl*>(debugger
), contextGroupId)); | 54 return adoptPtr(new V8RuntimeAgentImpl(static_cast<V8DebuggerImpl*>(debugger
), contextGroupId)); |
62 } | 55 } |
63 | 56 |
64 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8DebuggerImpl* debugger, int contextGrou
pId) | 57 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8DebuggerImpl* debugger, int contextGrou
pId) |
65 : m_contextGroupId(contextGroupId) | 58 : m_contextGroupId(contextGroupId) |
66 , m_state(nullptr) | 59 , m_state(nullptr) |
67 , m_frontend(nullptr) | 60 , m_frontend(nullptr) |
68 , m_injectedScriptManager(InjectedScriptManager::create(debugger)) | 61 , m_injectedScriptManager(InjectedScriptManager::create(debugger)) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 if (!injectedScript->findObject(errorString, *remoteId, &object)) | 236 if (!injectedScript->findObject(errorString, *remoteId, &object)) |
244 return; | 237 return; |
245 String16 objectGroupName = injectedScript->objectGroupName(*remoteId); | 238 String16 objectGroupName = injectedScript->objectGroupName(*remoteId); |
246 | 239 |
247 injectedScript->getProperties(errorString, objectId, ownProperties.fromMaybe
(false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(fals
e), result, exceptionDetails); | 240 injectedScript->getProperties(errorString, objectId, ownProperties.fromMaybe
(false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(fals
e), result, exceptionDetails); |
248 if (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropert
iesOnly.fromMaybe(false)) | 241 if (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropert
iesOnly.fromMaybe(false)) |
249 return; | 242 return; |
250 if (object->IsSymbol()) | 243 if (object->IsSymbol()) |
251 return; | 244 return; |
252 v8::Local<v8::Array> propertiesArray; | 245 v8::Local<v8::Array> propertiesArray; |
253 if (!checkInternalError(errorString, v8::Debug::GetInternalProperties(inject
edScript->isolate(), object).ToLocal(&propertiesArray))) | 246 if (hasInternalError(errorString, !v8::Debug::GetInternalProperties(injected
Script->isolate(), object).ToLocal(&propertiesArray))) |
254 return; | 247 return; |
255 OwnPtr<protocol::Array<InternalPropertyDescriptor>> propertiesProtocolArray
= protocol::Array<InternalPropertyDescriptor>::create(); | 248 OwnPtr<protocol::Array<InternalPropertyDescriptor>> propertiesProtocolArray
= protocol::Array<InternalPropertyDescriptor>::create(); |
256 for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) { | 249 for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) { |
257 v8::Local<v8::Value> name; | 250 v8::Local<v8::Value> name; |
258 if (!checkInternalError(errorString, propertiesArray->Get(injectedScript
->context(), i).ToLocal(&name)) && name->IsString()) | 251 if (hasInternalError(errorString, !propertiesArray->Get(injectedScript->
context(), i).ToLocal(&name)) || !name->IsString()) |
259 return; | 252 return; |
260 v8::Local<v8::Value> value; | 253 v8::Local<v8::Value> value; |
261 if (!checkInternalError(errorString, propertiesArray->Get(injectedScript
->context(), i + 1).ToLocal(&value))) | 254 if (hasInternalError(errorString, !propertiesArray->Get(injectedScript->
context(), i + 1).ToLocal(&value))) |
262 return; | 255 return; |
263 OwnPtr<RemoteObject> wrappedValue = injectedScript->wrapObject(errorStri
ng, value, objectGroupName); | 256 OwnPtr<RemoteObject> wrappedValue = injectedScript->wrapObject(errorStri
ng, value, objectGroupName); |
264 if (!wrappedValue) | 257 if (!wrappedValue) |
265 return; | 258 return; |
266 propertiesProtocolArray->addItem(InternalPropertyDescriptor::create() | 259 propertiesProtocolArray->addItem(InternalPropertyDescriptor::create() |
267 .setName(toProtocolString(name.As<v8::String>())) | 260 .setName(toProtocolString(name.As<v8::String>())) |
268 .setValue(wrappedValue.release()).build()); | 261 .setValue(wrappedValue.release()).build()); |
269 } | 262 } |
270 if (!propertiesProtocolArray->length()) | 263 if (!propertiesProtocolArray->length()) |
271 return; | 264 return; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 injectedScript->setOrigin(info.origin); | 527 injectedScript->setOrigin(info.origin); |
535 } | 528 } |
536 | 529 |
537 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context>
context) | 530 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context>
context) |
538 { | 531 { |
539 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context); | 532 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context); |
540 if (m_enabled && contextId) | 533 if (m_enabled && contextId) |
541 m_frontend->executionContextDestroyed(contextId); | 534 m_frontend->executionContextDestroyed(contextId); |
542 } | 535 } |
543 | 536 |
| 537 bool V8RuntimeAgentImpl::hasInternalError(ErrorString* errorString, bool isError
) |
| 538 { |
| 539 if (isError) |
| 540 *errorString = "Internal error"; |
| 541 return isError; |
| 542 } |
| 543 |
544 } // namespace blink | 544 } // namespace blink |
OLD | NEW |