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

Unified Diff: src/inspector/v8-inspector-session-impl.cc

Issue 2467853003: [inspector] migrate Runtime to new style (Closed)
Patch Set: addressed comments Created 4 years, 1 month 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
« no previous file with comments | « src/inspector/v8-inspector-session-impl.h ('k') | src/inspector/v8-runtime-agent-impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/v8-inspector-session-impl.cc
diff --git a/src/inspector/v8-inspector-session-impl.cc b/src/inspector/v8-inspector-session-impl.cc
index 542fde734dce7f39c766dd34ae6718b17d600d25..76de18bb408c3a154541b3db60ff5b55517d1168 100644
--- a/src/inspector/v8-inspector-session-impl.cc
+++ b/src/inspector/v8-inspector-session-impl.cc
@@ -104,12 +104,12 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector,
}
V8InspectorSessionImpl::~V8InspectorSessionImpl() {
- ErrorString errorString;
+ protocol::ErrorString errorString;
m_consoleAgent->disable();
m_profilerAgent->disable();
m_heapProfilerAgent->disable();
m_debuggerAgent->disable(&errorString);
- m_runtimeAgent->disable(&errorString);
+ m_runtimeAgent->disable();
discardInjectedScripts();
m_inspector->disconnect(this);
@@ -165,42 +165,35 @@ void V8InspectorSessionImpl::discardInjectedScripts() {
}
}
-InjectedScript* V8InspectorSessionImpl::findInjectedScript(
- ErrorString* errorString, int contextId) {
- if (!contextId) {
- *errorString = "Cannot find context with specified id";
- return nullptr;
- }
+Response V8InspectorSessionImpl::findInjectedScript(
+ int contextId, InjectedScript*& injectedScript) {
+ injectedScript = nullptr;
+ if (!contextId)
+ return Response::Error("Cannot find context with specified id");
const V8InspectorImpl::ContextByIdMap* contexts =
m_inspector->contextGroup(m_contextGroupId);
- if (!contexts) {
- *errorString = "Cannot find context with specified id";
- return nullptr;
- }
+ if (!contexts)
+ return Response::Error("Cannot find context with specified id");
auto contextsIt = contexts->find(contextId);
- if (contextsIt == contexts->end()) {
- *errorString = "Cannot find context with specified id";
- return nullptr;
- }
+ if (contextsIt == contexts->end())
+ return Response::Error("Cannot find context with specified id");
const std::unique_ptr<InspectedContext>& context = contextsIt->second;
if (!context->getInjectedScript()) {
- if (!context->createInjectedScript()) {
- *errorString = "Cannot access specified execution context";
- return nullptr;
- }
+ if (!context->createInjectedScript())
+ return Response::Error("Cannot access specified execution context");
if (m_customObjectFormatterEnabled)
context->getInjectedScript()->setCustomObjectFormatterEnabled(true);
}
- return context->getInjectedScript();
+ injectedScript = context->getInjectedScript();
+ return Response::OK();
}
-InjectedScript* V8InspectorSessionImpl::findInjectedScript(
- ErrorString* errorString, RemoteObjectIdBase* objectId) {
- return objectId ? findInjectedScript(errorString, objectId->contextId())
- : nullptr;
+Response V8InspectorSessionImpl::findInjectedScript(
+ RemoteObjectIdBase* objectId, InjectedScript*& injectedScript) {
+ return findInjectedScript(objectId->contextId(), injectedScript);
}
void V8InspectorSessionImpl::releaseObjectGroup(const StringView& objectGroup) {
@@ -230,31 +223,35 @@ bool V8InspectorSessionImpl::unwrapObject(
std::unique_ptr<StringBuffer>* error, const StringView& objectId,
v8::Local<v8::Value>* object, v8::Local<v8::Context>* context,
std::unique_ptr<StringBuffer>* objectGroup) {
- ErrorString errorString;
String16 objectGroupString;
- bool result =
- unwrapObject(&errorString, toString16(objectId), object, context,
- objectGroup ? &objectGroupString : nullptr);
- if (error) *error = StringBufferImpl::adopt(errorString);
+ Response response = unwrapObject(toString16(objectId), object, context,
+ objectGroup ? &objectGroupString : nullptr);
+ if (!response.isSuccess()) {
+ if (error) {
+ String16 errorMessage = response.errorMessage();
+ *error = StringBufferImpl::adopt(errorMessage);
+ }
+ return false;
+ }
if (objectGroup) *objectGroup = StringBufferImpl::adopt(objectGroupString);
- return result;
+ return true;
}
-bool V8InspectorSessionImpl::unwrapObject(ErrorString* errorString,
- const String16& objectId,
- v8::Local<v8::Value>* object,
- v8::Local<v8::Context>* context,
- String16* objectGroup) {
- std::unique_ptr<RemoteObjectId> remoteId =
- RemoteObjectId::parse(errorString, objectId);
- if (!remoteId) return false;
- InjectedScript* injectedScript =
- findInjectedScript(errorString, remoteId.get());
- if (!injectedScript) return false;
- if (!injectedScript->findObject(errorString, *remoteId, object)) return false;
+Response V8InspectorSessionImpl::unwrapObject(const String16& objectId,
+ v8::Local<v8::Value>* object,
+ v8::Local<v8::Context>* context,
+ String16* objectGroup) {
+ std::unique_ptr<RemoteObjectId> remoteId;
+ Response response = RemoteObjectId::parse(objectId, &remoteId);
+ if (!response.isSuccess()) return response;
+ InjectedScript* injectedScript = nullptr;
+ response = findInjectedScript(remoteId.get(), injectedScript);
+ if (!response.isSuccess()) return response;
+ response = injectedScript->findObject(*remoteId, object);
+ if (!response.isSuccess()) return response;
*context = injectedScript->context()->context();
if (objectGroup) *objectGroup = injectedScript->objectGroupName(*remoteId);
- return true;
+ return Response::OK();
}
std::unique_ptr<protocol::Runtime::API::RemoteObject>
@@ -269,21 +266,20 @@ V8InspectorSessionImpl::wrapObject(v8::Local<v8::Context> context,
v8::Local<v8::Value> value,
const String16& groupName,
bool generatePreview) {
- ErrorString errorString;
- InjectedScript* injectedScript =
- findInjectedScript(&errorString, V8Debugger::contextId(context));
+ InjectedScript* injectedScript = nullptr;
+ findInjectedScript(V8Debugger::contextId(context), injectedScript);
if (!injectedScript) return nullptr;
- return injectedScript->wrapObject(&errorString, value, groupName, false,
- generatePreview);
+ std::unique_ptr<protocol::Runtime::RemoteObject> result;
+ injectedScript->wrapObject(value, groupName, false, generatePreview, &result);
+ return result;
}
std::unique_ptr<protocol::Runtime::RemoteObject>
V8InspectorSessionImpl::wrapTable(v8::Local<v8::Context> context,
v8::Local<v8::Value> table,
v8::Local<v8::Value> columns) {
- ErrorString errorString;
- InjectedScript* injectedScript =
- findInjectedScript(&errorString, V8Debugger::contextId(context));
+ InjectedScript* injectedScript = nullptr;
+ findInjectedScript(V8Debugger::contextId(context), injectedScript);
if (!injectedScript) return nullptr;
return injectedScript->wrapTable(table, columns);
}
@@ -386,17 +382,17 @@ void V8InspectorSessionImpl::breakProgram(const StringView& breakReason,
}
void V8InspectorSessionImpl::setSkipAllPauses(bool skip) {
- ErrorString errorString;
+ protocol::ErrorString errorString;
m_debuggerAgent->setSkipAllPauses(&errorString, skip);
}
void V8InspectorSessionImpl::resume() {
- ErrorString errorString;
+ protocol::ErrorString errorString;
m_debuggerAgent->resume(&errorString);
}
void V8InspectorSessionImpl::stepOver() {
- ErrorString errorString;
+ protocol::ErrorString errorString;
m_debuggerAgent->stepOver(&errorString);
}
« no previous file with comments | « src/inspector/v8-inspector-session-impl.h ('k') | src/inspector/v8-runtime-agent-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698