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

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

Issue 1728873002: DevTools: simplify JSONValues API, prepare to the OwnPtr migration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselines 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/Dispatcher_cpp.template
diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template
index f25e8718ba9c12bfe5b37d1e35e47ee52272ac76..a82b0eadd229078daa5ea9bd98bcefcefec486c4 100644
--- a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template
+++ b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template
@@ -71,7 +71,7 @@ private:
{% endfor %}
template<typename R, typename V, typename V0>
- static R getPropertyValueImpl(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(JSONValue*, V*), const char* type_name);
+ static R getPropertyValueImpl(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(PassRefPtr<JSONValue>, V*), const char* type_name);
static Maybe<int> getInteger(JSONObject* object, const char* name, bool isOptional, JSONArray* protocolErrors);
static Maybe<double> getNumber(JSONObject* object, const char* name, bool isOptional, JSONArray* protocolErrors);
@@ -212,7 +212,7 @@ void DispatcherImpl::dispatch(int sessionId, const String& message)
int callId = 0;
RefPtr<JSONValue> parsedMessage = parseJSON(message);
ASSERT(parsedMessage);
- RefPtr<JSONObject> messageObject = parsedMessage->asObject();
+ RefPtr<JSONObject> messageObject = JSONObject::cast(parsedMessage.release());
ASSERT(messageObject);
RefPtr<JSONValue> callIdValue = messageObject->get("id");
@@ -272,7 +272,7 @@ void DispatcherImpl::reportProtocolError(int sessionId, int callId, CommonErrorC
}
template<typename R, typename V, typename V0>
-R DispatcherImpl::getPropertyValueImpl(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(JSONValue*, V*), const char* type_name)
+R DispatcherImpl::getPropertyValueImpl(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(PassRefPtr<JSONValue>, V*), const char* type_name)
{
ASSERT(protocolErrors);
@@ -307,12 +307,12 @@ R DispatcherImpl::getPropertyValueImpl(JSONObject* object, const char* name, boo
}
struct AsMethodBridges {
- static bool asInteger(JSONValue* value, int* output) { return value->asNumber(output); }
- static bool asNumber(JSONValue* value, double* output) { return value->asNumber(output); }
- static bool asString(JSONValue* value, String* output) { return value->asString(output); }
- static bool asBoolean(JSONValue* value, bool* output) { return value->asBoolean(output); }
- static bool asObject(JSONValue* value, RefPtr<JSONObject>* output) { return value->asObject(output); }
- static bool asArray(JSONValue* value, RefPtr<JSONArray>* output) { return value->asArray(output); }
+ static bool asInteger(PassRefPtr<JSONValue> value, int* output) { return value->asNumber(output); }
+ static bool asNumber(PassRefPtr<JSONValue> value, double* output) { return value->asNumber(output); }
+ static bool asString(PassRefPtr<JSONValue> value, String* output) { return value->asString(output); }
+ static bool asBoolean(PassRefPtr<JSONValue> value, bool* output) { return value->asBoolean(output); }
+ static bool asObject(PassRefPtr<JSONValue> value, RefPtr<JSONObject>* output) { *output = JSONObject::cast(value); return *output; }
+ static bool asArray(PassRefPtr<JSONValue> value, RefPtr<JSONArray>* output) { *output = JSONArray::cast(value); return *output; }
};
Maybe<int> DispatcherImpl::getInteger(JSONObject* object, const char* name, bool isOptional, JSONArray* protocolErrors)
@@ -361,7 +361,7 @@ bool Dispatcher::getCommandName(const String& message, String* result)
if (!value)
return false;
- RefPtr<JSONObject> object = value->asObject();
+ RefPtr<JSONObject> object = JSONObject::cast(value.release());
if (!object)
return false;

Powered by Google App Engine
This is Rietveld 408576698