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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp

Issue 2004313003: DevTools: migrate from OwnPtr to std::unique_ptr for inspector protocol classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined Created 4 years, 7 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/v8_inspector/InjectedScript.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp
index 2c4e66abdb5f8b16f2379f2de19b3dec99a80677..0dfb7a95ff3a504e2fcecb2db59275fff848270f 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp
@@ -68,14 +68,14 @@ static bool hasInternalError(ErrorString* errorString, bool hasError)
return hasError;
}
-PassOwnPtr<InjectedScript> InjectedScript::create(InspectedContext* inspectedContext)
+std::unique_ptr<InjectedScript> InjectedScript::create(InspectedContext* inspectedContext)
{
v8::Isolate* isolate = inspectedContext->isolate();
v8::HandleScope handles(isolate);
v8::Local<v8::Context> context = inspectedContext->context();
v8::Context::Scope scope(context);
- OwnPtr<InjectedScriptNative> injectedScriptNative = adoptPtr(new InjectedScriptNative(isolate));
+ std::unique_ptr<InjectedScriptNative> injectedScriptNative(new InjectedScriptNative(isolate));
v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::create(context, inspectedContext->debugger());
injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper);
@@ -98,10 +98,10 @@ PassOwnPtr<InjectedScript> InjectedScript::create(InspectedContext* inspectedCon
return nullptr;
if (!injectedScriptValue->IsObject())
return nullptr;
- return adoptPtr(new InjectedScript(inspectedContext, injectedScriptValue.As<v8::Object>(), std::move(injectedScriptNative)));
+ return wrapUnique(new InjectedScript(inspectedContext, injectedScriptValue.As<v8::Object>(), std::move(injectedScriptNative)));
}
-InjectedScript::InjectedScript(InspectedContext* context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> injectedScriptNative)
+InjectedScript::InjectedScript(InspectedContext* context, v8::Local<v8::Object> object, std::unique_ptr<InjectedScriptNative> injectedScriptNative)
: m_context(context)
, m_value(context->isolate(), object)
, m_native(std::move(injectedScriptNative))
@@ -112,7 +112,7 @@ InjectedScript::~InjectedScript()
{
}
-void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Object> object, const String16& groupName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, OwnPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
+void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Object> object, const String16& groupName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, std::unique_ptr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
{
v8::HandleScope handles(m_context->isolate());
V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "getProperties");
@@ -131,18 +131,18 @@ void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Objec
return;
}
- OwnPtr<protocol::Value> protocolValue = toProtocolValue(function.context(), resultValue);
+ std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(function.context(), resultValue);
if (hasInternalError(errorString, !protocolValue))
return;
protocol::ErrorSupport errors(errorString);
- OwnPtr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor>::parse(protocolValue.get(), &errors);
+ std::unique_ptr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor>::parse(protocolValue.get(), &errors);
if (!hasInternalError(errorString, errors.hasErrors()))
*properties = std::move(result);
}
void InjectedScript::releaseObject(const String16& objectId)
{
- OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId);
+ std::unique_ptr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId);
if (!parsedObjectId)
return;
protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedObjectId.get());
@@ -154,14 +154,14 @@ void InjectedScript::releaseObject(const String16& objectId)
m_native->unbind(boundId);
}
-PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(ErrorString* errorString, v8::Local<v8::Value> value, const String16& groupName, bool forceValueType, bool generatePreview) const
+std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(ErrorString* errorString, v8::Local<v8::Value> value, const String16& groupName, bool forceValueType, bool generatePreview) const
{
v8::HandleScope handles(m_context->isolate());
v8::Local<v8::Value> wrappedObject;
if (!wrapValue(errorString, value, groupName, forceValueType, generatePreview).ToLocal(&wrappedObject))
return nullptr;
protocol::ErrorSupport errors;
- OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::RemoteObject::parse(toProtocolValue(m_context->context(), wrappedObject).get(), &errors);
+ std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::RemoteObject::parse(toProtocolValue(m_context->context(), wrappedObject).get(), &errors);
if (!remoteObject)
*errorString = "Object has too long reference chain";
return remoteObject;
@@ -223,7 +223,7 @@ v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* errorString, v8
return r;
}
-PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const
+std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const
{
v8::HandleScope handles(m_context->isolate());
V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapTable");
@@ -294,7 +294,7 @@ v8::Local<v8::Value> InjectedScript::lastEvaluationResult() const
v8::MaybeLocal<v8::Value> InjectedScript::resolveCallArgument(ErrorString* errorString, protocol::Runtime::CallArgument* callArgument)
{
if (callArgument->hasObjectId()) {
- OwnPtr<RemoteObjectId> remoteObjectId = RemoteObjectId::parse(errorString, callArgument->getObjectId(""));
+ std::unique_ptr<RemoteObjectId> remoteObjectId = RemoteObjectId::parse(errorString, callArgument->getObjectId(""));
if (!remoteObjectId)
return v8::MaybeLocal<v8::Value>();
if (remoteObjectId->contextId() != m_context->contextId()) {
@@ -320,9 +320,9 @@ v8::MaybeLocal<v8::Value> InjectedScript::resolveCallArgument(ErrorString* error
return v8::Undefined(m_context->isolate());
}
-PassOwnPtr<protocol::Runtime::ExceptionDetails> InjectedScript::createExceptionDetails(v8::Local<v8::Message> message)
+std::unique_ptr<protocol::Runtime::ExceptionDetails> InjectedScript::createExceptionDetails(v8::Local<v8::Message> message)
{
- OwnPtr<protocol::Runtime::ExceptionDetails> exceptionDetailsObject = protocol::Runtime::ExceptionDetails::create().setText(toProtocolString(message->Get())).build();
+ std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetailsObject = protocol::Runtime::ExceptionDetails::create().setText(toProtocolString(message->Get())).build();
exceptionDetailsObject->setUrl(toProtocolStringWithTypeCheck(message->GetScriptResourceName()));
exceptionDetailsObject->setScriptId(String16::number(message->GetScriptOrigin().ScriptID()->Value()));
@@ -339,13 +339,13 @@ PassOwnPtr<protocol::Runtime::ExceptionDetails> InjectedScript::createExceptionD
return exceptionDetailsObject;
}
-void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal<v8::Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& objectGroup, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
+void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal<v8::Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& objectGroup, bool returnByValue, bool generatePreview, std::unique_ptr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
{
v8::Local<v8::Value> resultValue;
if (!tryCatch.HasCaught()) {
if (hasInternalError(errorString, !maybeResultValue.ToLocal(&resultValue)))
return;
- OwnPtr<RemoteObject> remoteObject = wrapObject(errorString, resultValue, objectGroup, returnByValue, generatePreview);
+ std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, resultValue, objectGroup, returnByValue, generatePreview);
if (!remoteObject)
return;
if (objectGroup == "console")
@@ -355,7 +355,7 @@ void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal
*wasThrown = false;
} else {
v8::Local<v8::Value> exception = tryCatch.Exception();
- OwnPtr<RemoteObject> remoteObject = wrapObject(errorString, exception, objectGroup, false, generatePreview && !exception->IsNativeError());
+ std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, exception, objectGroup, false, generatePreview && !exception->IsNativeError());
if (!remoteObject)
return;
*result = std::move(remoteObject);
@@ -493,7 +493,7 @@ InjectedScript::ObjectScope::~ObjectScope()
void InjectedScript::ObjectScope::findInjectedScript(V8InspectorSessionImpl* session)
{
- OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(m_errorString, m_remoteObjectId);
+ std::unique_ptr<RemoteObjectId> remoteId = RemoteObjectId::parse(m_errorString, m_remoteObjectId);
if (!remoteId)
return;
InjectedScript* injectedScript = session->findInjectedScript(m_errorString, remoteId.get());
@@ -517,7 +517,7 @@ InjectedScript::CallFrameScope::~CallFrameScope()
void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session)
{
- OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId);
+ std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId);
if (!remoteId)
return;
m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());

Powered by Google App Engine
This is Rietveld 408576698