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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.cpp

Issue 2218533002: Backporting JSONValues from protocol::Values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch back to partition allocator Created 4 years, 4 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/bindings/core/v8/JSONValuesForV8.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.cpp b/third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.cpp
index 9dbf7f57d091a57739a12ce9e64c5061e73216ad..48157b92c3c60db0a5023add5b5f54cfc69ce07c 100644
--- a/third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.cpp
@@ -19,7 +19,7 @@ static String coreString(v8::Local<v8::String> v8String)
return result;
}
-PassRefPtr<JSONValue> toJSONValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth)
+std::unique_ptr<JSONValue> toJSONValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth)
{
if (value.IsEmpty()) {
ASSERT_NOT_REACHED();
@@ -40,21 +40,21 @@ PassRefPtr<JSONValue> toJSONValue(v8::Local<v8::Context> context, v8::Local<v8::
return JSONString::create(coreString(value.As<v8::String>()));
if (value->IsArray()) {
v8::Local<v8::Array> array = value.As<v8::Array>();
- RefPtr<JSONArray> inspectorArray = JSONArray::create();
+ std::unique_ptr<JSONArray> inspectorArray = JSONArray::create();
uint32_t length = array->Length();
for (uint32_t i = 0; i < length; i++) {
v8::Local<v8::Value> value;
if (!array->Get(context, i).ToLocal(&value))
return nullptr;
- RefPtr<JSONValue> element = toJSONValue(context, value, maxDepth);
+ std::unique_ptr<JSONValue> element = toJSONValue(context, value, maxDepth);
if (!element)
return nullptr;
- inspectorArray->pushValue(element);
+ inspectorArray->pushValue(std::move(element));
}
- return inspectorArray;
+ return std::move(inspectorArray);
}
if (value->IsObject()) {
- RefPtr<JSONObject> jsonObject = JSONObject::create();
+ std::unique_ptr<JSONObject> jsonObject = JSONObject::create();
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
v8::Local<v8::Array> propertyNames;
if (!object->GetPropertyNames(context).ToLocal(&propertyNames))
@@ -76,12 +76,12 @@ PassRefPtr<JSONValue> toJSONValue(v8::Local<v8::Context> context, v8::Local<v8::
v8::Local<v8::Value> property;
if (!object->Get(context, name).ToLocal(&property))
return nullptr;
- RefPtr<JSONValue> propertyValue = toJSONValue(context, property, maxDepth);
+ std::unique_ptr<JSONValue> propertyValue = toJSONValue(context, property, maxDepth);
if (!propertyValue)
return nullptr;
- jsonObject->setValue(coreString(propertyName), propertyValue);
+ jsonObject->setValue(coreString(propertyName), std::move(propertyValue));
}
- return jsonObject;
+ return std::move(jsonObject);
}
ASSERT_NOT_REACHED();
return nullptr;
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.h ('k') | third_party/WebKit/Source/core/frame/FrameView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698