| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/v8_inspector/RemoteObjectId.h" | 5 #include "platform/v8_inspector/RemoteObjectId.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/Parser.h" | 7 #include "platform/inspector_protocol/Parser.h" |
| 8 #include "platform/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
| 9 #include "wtf/PassOwnPtr.h" | 9 #include "wtf/PassOwnPtr.h" |
| 10 #include "wtf/RefPtr.h" | 10 #include "wtf/RefPtr.h" |
| 11 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) { } | 15 RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) { } |
| 16 | 16 |
| 17 PassRefPtr<protocol::DictionaryValue> RemoteObjectIdBase::parseInjectedScriptId(
const String& objectId) | 17 PassOwnPtr<protocol::DictionaryValue> RemoteObjectIdBase::parseInjectedScriptId(
const String& objectId) |
| 18 { | 18 { |
| 19 RefPtr<protocol::Value> parsedValue = protocol::parseJSON(objectId); | 19 OwnPtr<protocol::Value> parsedValue = protocol::parseJSON(objectId); |
| 20 if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject) | 20 if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject) |
| 21 return nullptr; | 21 return nullptr; |
| 22 | 22 |
| 23 RefPtr<protocol::DictionaryValue> parsedObjectId = protocol::DictionaryValue
::cast(parsedValue.release()); | 23 OwnPtr<protocol::DictionaryValue> parsedObjectId = adoptPtr(protocol::Dictio
naryValue::cast(parsedValue.leakPtr())); |
| 24 bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScri
ptId); | 24 bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScri
ptId); |
| 25 if (success) | 25 if (success) |
| 26 return parsedObjectId.release(); | 26 return parsedObjectId.release(); |
| 27 return nullptr; | 27 return nullptr; |
| 28 } | 28 } |
| 29 | 29 |
| 30 RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) { } | 30 RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) { } |
| 31 | 31 |
| 32 PassOwnPtr<RemoteObjectId> RemoteObjectId::parse(const String& objectId) | 32 PassOwnPtr<RemoteObjectId> RemoteObjectId::parse(const String& objectId) |
| 33 { | 33 { |
| 34 OwnPtr<RemoteObjectId> result = adoptPtr(new RemoteObjectId()); | 34 OwnPtr<RemoteObjectId> result = adoptPtr(new RemoteObjectId()); |
| 35 RefPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri
ptId(objectId); | 35 OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri
ptId(objectId); |
| 36 if (!parsedObjectId) | 36 if (!parsedObjectId) |
| 37 return nullptr; | 37 return nullptr; |
| 38 | 38 |
| 39 bool success = parsedObjectId->getNumber("id", &result->m_id); | 39 bool success = parsedObjectId->getNumber("id", &result->m_id); |
| 40 if (success) | 40 if (success) |
| 41 return result.release(); | 41 return result.release(); |
| 42 return nullptr; | 42 return nullptr; |
| 43 } | 43 } |
| 44 | 44 |
| 45 RemoteCallFrameId::RemoteCallFrameId() : RemoteObjectIdBase(), m_frameOrdinal(0)
, m_asyncStackOrdinal(0) { } | 45 RemoteCallFrameId::RemoteCallFrameId() : RemoteObjectIdBase(), m_frameOrdinal(0)
, m_asyncStackOrdinal(0) { } |
| 46 | 46 |
| 47 PassOwnPtr<RemoteCallFrameId> RemoteCallFrameId::parse(const String& objectId) | 47 PassOwnPtr<RemoteCallFrameId> RemoteCallFrameId::parse(const String& objectId) |
| 48 { | 48 { |
| 49 OwnPtr<RemoteCallFrameId> result = adoptPtr(new RemoteCallFrameId()); | 49 OwnPtr<RemoteCallFrameId> result = adoptPtr(new RemoteCallFrameId()); |
| 50 RefPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri
ptId(objectId); | 50 OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri
ptId(objectId); |
| 51 if (!parsedObjectId) | 51 if (!parsedObjectId) |
| 52 return nullptr; | 52 return nullptr; |
| 53 | 53 |
| 54 bool success = parsedObjectId->getNumber("ordinal", &result->m_frameOrdinal)
; | 54 bool success = parsedObjectId->getNumber("ordinal", &result->m_frameOrdinal)
; |
| 55 if (!success) | 55 if (!success) |
| 56 return nullptr; | 56 return nullptr; |
| 57 | 57 |
| 58 RefPtr<protocol::Value> value = parsedObjectId->get("asyncOrdinal"); | 58 protocol::Value* value = parsedObjectId->get("asyncOrdinal"); |
| 59 if (value &&!value->asNumber(&result->m_asyncStackOrdinal)) | 59 if (value &&!value->asNumber(&result->m_asyncStackOrdinal)) |
| 60 return nullptr; | 60 return nullptr; |
| 61 return result.release(); | 61 return result.release(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace blink | 64 } // namespace blink |
| OLD | NEW |