Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template

Issue 1734693003: Revert of DevTools: simplify JSONValues API, prepare to the OwnPtr migration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 4589aab80680c82d520919ac66e3ae8f943f46d3..7374d9e56b17d5fa92e6afd94846ddf493a82c81 100644
--- a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template
+++ b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template
@@ -113,7 +113,12 @@
{
static PassOwnPtr<T> convert(RefPtr<JSONValue> value)
{
- return T::runtimeCast(JSONObject::cast(value.release()));
+ if (!value)
+ return nullptr;
+ RefPtr<JSONObject> object;
+ bool success = value->asObject(&object);
+ ASSERT_UNUSED(success, success);
+ return T::runtimeCast(object.release());
}
};
@@ -179,7 +184,9 @@
{
static PassOwnPtr<protocol::Array<T>> convert(RefPtr<JSONValue> value)
{
- return protocol::Array<T>::runtimeCast(JSONArray::cast(value));
+ RefPtr<JSONArray> array = value->asArray();
+ ASSERT_UNUSED(array, array);
+ return protocol::Array<T>::runtimeCast(array);
}
};
@@ -193,12 +200,12 @@
return result.release();
}
- static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONValue> array)
- {
- if (!array || array->type() != JSONValue::TypeArray)
+ static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONArray> array)
+ {
+ if (!array)
return nullptr;
OwnPtr<Array<T>> result = adoptPtr(new Array<T>());
- result->m_array = JSONArray::cast(array);
+ result->m_array = array;
return result.release();
}
@@ -232,12 +239,12 @@
return result.release();
}
- static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONValue> array)
- {
- if (!array || array->type() != JSONValue::TypeArray)
+ static PassOwnPtr<Array<T>> runtimeCast(PassRefPtr<JSONArray> array)
+ {
+ if (!array)
return nullptr;
OwnPtr<Array<T>> result = adoptPtr(new Array<T>());
- result->m_array = JSONArray::cast(array);
+ result->m_array = array;
return result.release();
}
@@ -319,11 +326,9 @@
// {{type.description}}
class PLATFORM_EXPORT {{type.id}} {
public:
- static PassOwnPtr<{{type.id}}> runtimeCast(PassRefPtr<JSONValue> value)
- {
- if (!value || value->type() != JSONValue::TypeObject)
- return nullptr;
- return adoptPtr(new {{type.id}}(JSONObject::cast(value)));
+ static PassOwnPtr<{{type.id}}> runtimeCast(PassRefPtr<JSONObject> object)
+ {
+ return adoptPtr(new {{type.id}}(object));
}
{{type.id}}() : m_object(JSONObject::create()) { }

Powered by Google App Engine
This is Rietveld 408576698