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