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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp

Issue 1979963002: Remove OwnPtr::release() calls in platform/ (part inspector). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 ASSERT(value->IsFunction()); 91 ASSERT(value->IsFunction());
92 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); 92 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
93 v8::Local<v8::Object> windowGlobal = context->Global(); 93 v8::Local<v8::Object> windowGlobal = context->Global();
94 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number: :New(isolate, inspectedContext->contextId()) }; 94 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number: :New(isolate, inspectedContext->contextId()) };
95 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks); 95 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
96 v8::Local<v8::Value> injectedScriptValue; 96 v8::Local<v8::Value> injectedScriptValue;
97 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL ocal(&injectedScriptValue)) 97 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL ocal(&injectedScriptValue))
98 return nullptr; 98 return nullptr;
99 if (!injectedScriptValue->IsObject()) 99 if (!injectedScriptValue->IsObject())
100 return nullptr; 100 return nullptr;
101 return adoptPtr(new InjectedScript(inspectedContext, injectedScriptValue.As< v8::Object>(), injectedScriptNative.release())); 101 return adoptPtr(new InjectedScript(inspectedContext, injectedScriptValue.As< v8::Object>(), std::move(injectedScriptNative)));
102 } 102 }
103 103
104 InjectedScript::InjectedScript(InspectedContext* context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> injectedScriptNative) 104 InjectedScript::InjectedScript(InspectedContext* context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> injectedScriptNative)
105 : m_context(context) 105 : m_context(context)
106 , m_value(context->isolate(), object) 106 , m_value(context->isolate(), object)
107 , m_native(std::move(injectedScriptNative)) 107 , m_native(std::move(injectedScriptNative))
108 { 108 {
109 } 109 }
110 110
111 InjectedScript::~InjectedScript() 111 InjectedScript::~InjectedScript()
(...skipping 18 matching lines...) Expand all
130 *properties = Array<PropertyDescriptor>::create(); 130 *properties = Array<PropertyDescriptor>::create();
131 return; 131 return;
132 } 132 }
133 133
134 OwnPtr<protocol::Value> protocolValue = toProtocolValue(function.context(), resultValue); 134 OwnPtr<protocol::Value> protocolValue = toProtocolValue(function.context(), resultValue);
135 if (hasInternalError(errorString, !protocolValue)) 135 if (hasInternalError(errorString, !protocolValue))
136 return; 136 return;
137 protocol::ErrorSupport errors(errorString); 137 protocol::ErrorSupport errors(errorString);
138 OwnPtr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor>::parse( protocolValue.get(), &errors); 138 OwnPtr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor>::parse( protocolValue.get(), &errors);
139 if (!hasInternalError(errorString, errors.hasErrors())) 139 if (!hasInternalError(errorString, errors.hasErrors()))
140 *properties = result.release(); 140 *properties = std::move(result);
141 } 141 }
142 142
143 void InjectedScript::releaseObject(const String16& objectId) 143 void InjectedScript::releaseObject(const String16& objectId)
144 { 144 {
145 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); 145 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId);
146 if (!parsedObjectId) 146 if (!parsedObjectId)
147 return; 147 return;
148 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb jectId.get()); 148 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb jectId.get());
149 if (!object) 149 if (!object)
150 return; 150 return;
151 int boundId = 0; 151 int boundId = 0;
152 if (!object->getNumber("id", &boundId)) 152 if (!object->getNumber("id", &boundId))
153 return; 153 return;
154 m_native->unbind(boundId); 154 m_native->unbind(boundId);
155 } 155 }
156 156
157 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(ErrorStri ng* errorString, v8::Local<v8::Value> value, const String16& groupName, bool for ceValueType, bool generatePreview) const 157 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(ErrorStri ng* errorString, v8::Local<v8::Value> value, const String16& groupName, bool for ceValueType, bool generatePreview) const
158 { 158 {
159 v8::HandleScope handles(m_context->isolate()); 159 v8::HandleScope handles(m_context->isolate());
160 v8::Local<v8::Value> wrappedObject; 160 v8::Local<v8::Value> wrappedObject;
161 if (!wrapValue(errorString, value, groupName, forceValueType, generatePrevie w).ToLocal(&wrappedObject)) 161 if (!wrapValue(errorString, value, groupName, forceValueType, generatePrevie w).ToLocal(&wrappedObject))
162 return nullptr; 162 return nullptr;
163 protocol::ErrorSupport errors; 163 protocol::ErrorSupport errors;
164 OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::Re moteObject::parse(toProtocolValue(m_context->context(), wrappedObject).get(), &e rrors); 164 OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::Re moteObject::parse(toProtocolValue(m_context->context(), wrappedObject).get(), &e rrors);
165 if (!remoteObject) 165 if (!remoteObject)
166 *errorString = "Object has too long reference chain"; 166 *errorString = "Object has too long reference chain";
167 return remoteObject.release(); 167 return remoteObject;
168 } 168 }
169 169
170 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, v8::Local<v8:: Object> object, v8::Local<v8::Value> key, const String16& groupName, bool forceV alueType, bool generatePreview) const 170 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, v8::Local<v8:: Object> object, v8::Local<v8::Value> key, const String16& groupName, bool forceV alueType, bool generatePreview) const
171 { 171 {
172 v8::Local<v8::Value> property; 172 v8::Local<v8::Value> property;
173 if (hasInternalError(errorString, !object->Get(m_context->context(), key).To Local(&property))) 173 if (hasInternalError(errorString, !object->Get(m_context->context(), key).To Local(&property)))
174 return false; 174 return false;
175 v8::Local<v8::Value> wrappedProperty; 175 v8::Local<v8::Value> wrappedProperty;
176 if (!wrapValue(errorString, property, groupName, forceValueType, generatePre view).ToLocal(&wrappedProperty)) 176 if (!wrapValue(errorString, property, groupName, forceValueType, generatePre view).ToLocal(&wrappedProperty))
177 return false; 177 return false;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 v8::Maybe<int> lineNumber = message->GetLineNumber(m_context->context()); 329 v8::Maybe<int> lineNumber = message->GetLineNumber(m_context->context());
330 if (lineNumber.IsJust()) 330 if (lineNumber.IsJust())
331 exceptionDetailsObject->setLine(lineNumber.FromJust()); 331 exceptionDetailsObject->setLine(lineNumber.FromJust());
332 v8::Maybe<int> columnNumber = message->GetStartColumn(m_context->context()); 332 v8::Maybe<int> columnNumber = message->GetStartColumn(m_context->context());
333 if (columnNumber.IsJust()) 333 if (columnNumber.IsJust())
334 exceptionDetailsObject->setColumn(columnNumber.FromJust()); 334 exceptionDetailsObject->setColumn(columnNumber.FromJust());
335 335
336 v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace(); 336 v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
337 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) 337 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
338 exceptionDetailsObject->setStack(m_context->debugger()->createStackTrace (stackTrace, stackTrace->GetFrameCount())->buildInspectorObject()); 338 exceptionDetailsObject->setStack(m_context->debugger()->createStackTrace (stackTrace, stackTrace->GetFrameCount())->buildInspectorObject());
339 return exceptionDetailsObject.release(); 339 return exceptionDetailsObject;
340 } 340 }
341 341
342 void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal <v8::Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& obje ctGroup, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::Rem oteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDe tails>* exceptionDetails) 342 void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal <v8::Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& obje ctGroup, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::Rem oteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDe tails>* exceptionDetails)
343 { 343 {
344 v8::Local<v8::Value> resultValue; 344 v8::Local<v8::Value> resultValue;
345 if (!tryCatch.HasCaught()) { 345 if (!tryCatch.HasCaught()) {
346 if (hasInternalError(errorString, !maybeResultValue.ToLocal(&resultValue ))) 346 if (hasInternalError(errorString, !maybeResultValue.ToLocal(&resultValue )))
347 return; 347 return;
348 OwnPtr<RemoteObject> remoteObject = wrapObject(errorString, resultValue, objectGroup, returnByValue, generatePreview); 348 OwnPtr<RemoteObject> remoteObject = wrapObject(errorString, resultValue, objectGroup, returnByValue, generatePreview);
349 if (!remoteObject) 349 if (!remoteObject)
350 return; 350 return;
351 if (objectGroup == "console") 351 if (objectGroup == "console")
352 m_lastEvaluationResult.Reset(m_context->isolate(), resultValue); 352 m_lastEvaluationResult.Reset(m_context->isolate(), resultValue);
353 *result = remoteObject.release(); 353 *result = std::move(remoteObject);
354 if (wasThrown) 354 if (wasThrown)
355 *wasThrown = false; 355 *wasThrown = false;
356 } else { 356 } else {
357 v8::Local<v8::Value> exception = tryCatch.Exception(); 357 v8::Local<v8::Value> exception = tryCatch.Exception();
358 OwnPtr<RemoteObject> remoteObject = wrapObject(errorString, exception, o bjectGroup, false, generatePreview && !exception->IsNativeError()); 358 OwnPtr<RemoteObject> remoteObject = wrapObject(errorString, exception, o bjectGroup, false, generatePreview && !exception->IsNativeError());
359 if (!remoteObject) 359 if (!remoteObject)
360 return; 360 return;
361 *result = remoteObject.release(); 361 *result = std::move(remoteObject);
362 if (exceptionDetails) 362 if (exceptionDetails)
363 *exceptionDetails = createExceptionDetails(tryCatch.Message()); 363 *exceptionDetails = createExceptionDetails(tryCatch.Message());
364 if (wasThrown) 364 if (wasThrown)
365 *wasThrown = true; 365 *wasThrown = true;
366 } 366 }
367 } 367 }
368 368
369 v8::MaybeLocal<v8::Object> InjectedScript::commandLineAPI(ErrorString* errorStri ng) 369 v8::MaybeLocal<v8::Object> InjectedScript::commandLineAPI(ErrorString* errorStri ng)
370 { 370 {
371 v8::Isolate* isolate = m_context->isolate(); 371 v8::Isolate* isolate = m_context->isolate();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session) 550 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session)
551 { 551 {
552 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); 552 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId);
553 if (!remoteId) 553 if (!remoteId)
554 return; 554 return;
555 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); 555 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
556 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() ); 556 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() );
557 } 557 }
558 558
559 } // namespace blink 559 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698