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

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

Issue 2260233002: [DevTools] Migrate v8_inspector/public from String16 to String{View,Buffer}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using WTF::StringView 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/platform/v8_inspector/V8InspectorSessionImpl.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp
index 26b5607e93724ed1b27914bb54499b7b59cb43dd..27518e5cd2d06351775372eef3afd612d76067a4 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp
@@ -21,21 +21,21 @@
namespace v8_inspector {
// static
-bool V8InspectorSession::canDispatchMethod(const String16& method)
+bool V8InspectorSession::canDispatchMethod(const StringView& method)
{
- return method.startsWith(protocol::Runtime::Metainfo::commandPrefix)
- || method.startsWith(protocol::Debugger::Metainfo::commandPrefix)
- || method.startsWith(protocol::Profiler::Metainfo::commandPrefix)
- || method.startsWith(protocol::HeapProfiler::Metainfo::commandPrefix)
- || method.startsWith(protocol::Console::Metainfo::commandPrefix);
+ return stringViewStartsWith(method, protocol::Runtime::Metainfo::commandPrefix)
+ || stringViewStartsWith(method, protocol::Debugger::Metainfo::commandPrefix)
+ || stringViewStartsWith(method, protocol::Profiler::Metainfo::commandPrefix)
+ || stringViewStartsWith(method, protocol::HeapProfiler::Metainfo::commandPrefix)
+ || stringViewStartsWith(method, protocol::Console::Metainfo::commandPrefix);
}
-std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8InspectorImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const String16* state)
+std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8InspectorImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const StringView& state)
{
return wrapUnique(new V8InspectorSessionImpl(inspector, contextGroupId, channel, state));
}
-V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const String16* savedState)
+V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const StringView& savedState)
: m_contextGroupId(contextGroupId)
, m_inspector(inspector)
, m_customObjectFormatterEnabled(false)
@@ -47,8 +47,8 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int c
, m_profilerAgent(nullptr)
, m_consoleAgent(nullptr)
{
- if (savedState) {
- std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState);
+ if (savedState.length()) {
+ std::unique_ptr<protocol::Value> state = protocol::parseJSON(toString16(savedState));
if (state)
m_state = protocol::DictionaryValue::cast(std::move(state));
if (!m_state)
@@ -72,7 +72,7 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int c
m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl(this, channel, agentState(protocol::Console::Metainfo::domainName)));
protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get());
- if (savedState) {
+ if (savedState.length()) {
m_runtimeAgent->restore();
m_debuggerAgent->restore();
m_heapProfilerAgent->restore();
@@ -170,6 +170,11 @@ InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr
return objectId ? findInjectedScript(errorString, objectId->contextId()) : nullptr;
}
+void V8InspectorSessionImpl::releaseObjectGroup(const StringView& objectGroup)
+{
+ releaseObjectGroup(toString16(objectGroup));
+}
+
void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup)
{
const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup(m_contextGroupId);
@@ -192,6 +197,14 @@ void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup)
}
}
+bool V8InspectorSessionImpl::unwrapObject(ErrorString* errorString, const StringView& objectId, v8::Local<v8::Value>* object, v8::Local<v8::Context>* context, StringView* objectGroup)
+{
+ String16 group;
+ bool result = unwrapObject(errorString, toString16(objectId), object, context, &group);
+ *objectGroup = toStringView(group);
caseq 2016/08/19 21:57:02 This does not look good -- you're returning to the
dgozman 2016/08/20 02:04:51 Right! Added simple StringBuffer for this.
+ return result;
+}
+
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);
@@ -207,9 +220,9 @@ bool V8InspectorSessionImpl::unwrapObject(ErrorString* errorString, const String
return true;
}
-std::unique_ptr<protocol::Runtime::API::RemoteObject> V8InspectorSessionImpl::wrapObject(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& groupName)
+std::unique_ptr<protocol::Runtime::API::RemoteObject> V8InspectorSessionImpl::wrapObject(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const StringView& groupName)
{
- return wrapObject(context, value, groupName, false);
+ return wrapObject(context, value, toString16(groupName), false);
}
std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapObject(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& groupName, bool generatePreview)
@@ -252,14 +265,15 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent)
agent->reportExecutionContextCreated(idContext.second.get());
}
-void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message)
+void V8InspectorSessionImpl::dispatchProtocolMessage(const StringView& message)
{
- m_dispatcher.dispatch(message);
+ m_dispatcher.dispatch(parseJSON(message));
}
-String16 V8InspectorSessionImpl::stateJSON()
+StringView V8InspectorSessionImpl::stateJSON()
{
- return m_state->toJSONString();
+ String16 json = m_state->toJSONString();
+ return toStringView(json);
caseq 2016/08/19 21:57:02 I'm sure we must have some very different understa
}
void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSession::Inspectable> inspectable)
@@ -276,9 +290,9 @@ V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(unsigne
return m_inspectedObjects[num].get();
}
-void V8InspectorSessionImpl::schedulePauseOnNextStatement(const String16& breakReason, const String16& breakDetails)
+void V8InspectorSessionImpl::schedulePauseOnNextStatement(const StringView& breakReason, const StringView& breakDetails)
{
- m_debuggerAgent->schedulePauseOnNextStatement(breakReason, protocol::DictionaryValue::cast(parseJSON(breakDetails)));
+ m_debuggerAgent->schedulePauseOnNextStatement(toString16(breakReason), protocol::DictionaryValue::cast(parseJSON(breakDetails)));
}
void V8InspectorSessionImpl::cancelPauseOnNextStatement()
@@ -286,9 +300,9 @@ void V8InspectorSessionImpl::cancelPauseOnNextStatement()
m_debuggerAgent->cancelPauseOnNextStatement();
}
-void V8InspectorSessionImpl::breakProgram(const String16& breakReason, const String16& breakDetails)
+void V8InspectorSessionImpl::breakProgram(const StringView& breakReason, const StringView& breakDetails)
{
- m_debuggerAgent->breakProgram(breakReason, protocol::DictionaryValue::cast(parseJSON(breakDetails)));
+ m_debuggerAgent->breakProgram(toString16(breakReason), protocol::DictionaryValue::cast(parseJSON(breakDetails)));
}
void V8InspectorSessionImpl::setSkipAllPauses(bool skip)
@@ -309,9 +323,10 @@ void V8InspectorSessionImpl::stepOver()
m_debuggerAgent->stepOver(&errorString);
}
-std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> V8InspectorSessionImpl::searchInTextByLines(const String16& text, const String16& query, bool caseSensitive, bool isRegex)
+std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> V8InspectorSessionImpl::searchInTextByLines(const StringView& text, const StringView& query, bool caseSensitive, bool isRegex)
{
- std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = searchInTextByLinesImpl(this, text, query, caseSensitive, isRegex);
+ // TODO(dgozman): search may operate on StringView and avoid copying |text|.
+ std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = searchInTextByLinesImpl(this, toString16(text), toString16(query), caseSensitive, isRegex);
std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> result = protocol::Array<protocol::Debugger::API::SearchMatch>::create();
for (size_t i = 0; i < matches.size(); ++i)
result->addItem(std::move(matches[i]));

Powered by Google App Engine
This is Rietveld 408576698