Index: third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
diff --git a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
index fc37c46f214a10926bf334b7d450451e7ec744d2..10ce09906af82d01c134971d7bc9e0ed659b84b8 100644 |
--- a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
+++ b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
@@ -112,12 +112,7 @@ struct FromValue |
{ |
static PassOwnPtr<T> convert(RefPtr<JSONValue> value) |
{ |
- if (!value) |
- return nullptr; |
- RefPtr<JSONObject> object; |
- bool success = value->asObject(&object); |
- ASSERT_UNUSED(success, success); |
- return T::runtimeCast(object.release()); |
+ return T::runtimeCast(JSONObject::cast(value.release())); |
} |
}; |
@@ -183,9 +178,7 @@ struct FromValue<protocol::Array<T>> |
{ |
static PassOwnPtr<protocol::Array<T>> convert(RefPtr<JSONValue> value) |
{ |
- RefPtr<JSONArray> array = value->asArray(); |
- ASSERT_UNUSED(array, array); |
- return protocol::Array<T>::runtimeCast(array); |
+ return protocol::Array<T>::runtimeCast(JSONArray::cast(value)); |
} |
}; |
@@ -199,12 +192,12 @@ public: |
return result.release(); |
} |
- static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONArray> array) |
+ static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONValue> array) |
{ |
- if (!array) |
+ if (!array || array->type() != JSONValue::TypeArray) |
return nullptr; |
OwnPtr<Array<T>> result = adoptPtr(new Array<T>()); |
- result->m_array = array; |
+ result->m_array = JSONArray::cast(array); |
return result.release(); |
} |
@@ -238,12 +231,12 @@ public: |
return result.release(); |
} |
- static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONArray> array) |
+ static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONValue> array) |
{ |
- if (!array) |
+ if (!array || array->type() != JSONValue::TypeArray) |
return nullptr; |
OwnPtr<Array<T>> result = adoptPtr(new Array<T>()); |
- result->m_array = array; |
+ result->m_array = JSONArray::cast(array); |
return result.release(); |
} |
@@ -325,9 +318,11 @@ namespace {{domain.domain}} { |
// {{type.description}} |
class PLATFORM_EXPORT {{type.id}} { |
public: |
- static PassOwnPtr<{{type.id}}> runtimeCast(PassRefPtr<JSONObject> object) |
+ static PassOwnPtr<{{type.id}}> runtimeCast(PassRefPtr<JSONValue> value) |
{ |
- return adoptPtr(new {{type.id}}(object)); |
+ if (!value || value->type() != JSONValue::TypeObject) |
+ return nullptr; |
+ return adoptPtr(new {{type.id}}(JSONObject::cast(value))); |
} |
{{type.id}}() : m_object(JSONObject::create()) { } |