[cleanup] Fix inspector classes, removing unnecessary copies.

Fixing clang-tidy warning.

Bug: v8:8015
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I641c72959470471747221f94da545a053dfcc0b0
Reviewed-on: https://chromium-review.googlesource.com/1228064
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Florian Sattler <sattlerf@google.com>
Cr-Commit-Position: refs/heads/master@{#55977}
This commit is contained in:
Florian Sattler 2018-09-17 19:17:53 +02:00 committed by Commit Bot
parent 0dd2a17121
commit 3f6d90b148
5 changed files with 15 additions and 11 deletions

View File

@ -63,6 +63,7 @@ class ConsoleHelper {
void reportCall(ConsoleAPIType type) { void reportCall(ConsoleAPIType type) {
if (!m_info.Length()) return; if (!m_info.Length()) return;
std::vector<v8::Local<v8::Value>> arguments; std::vector<v8::Local<v8::Value>> arguments;
arguments.reserve(m_info.Length());
for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]); for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]);
reportCall(type, arguments); reportCall(type, arguments);
} }
@ -143,7 +144,7 @@ class ConsoleHelper {
} }
void forEachSession(std::function<void(V8InspectorSessionImpl*)> callback) { void forEachSession(std::function<void(V8InspectorSessionImpl*)> callback) {
m_inspector->forEachSession(m_groupId, callback); m_inspector->forEachSession(m_groupId, std::move(callback));
} }
private: private:

View File

@ -359,7 +359,8 @@ V8Console* V8InspectorImpl::console() {
} }
void V8InspectorImpl::forEachContext( void V8InspectorImpl::forEachContext(
int contextGroupId, std::function<void(InspectedContext*)> callback) { int contextGroupId,
const std::function<void(InspectedContext*)>& callback) {
auto it = m_contexts.find(contextGroupId); auto it = m_contexts.find(contextGroupId);
if (it == m_contexts.end()) return; if (it == m_contexts.end()) return;
std::vector<int> ids; std::vector<int> ids;
@ -376,7 +377,8 @@ void V8InspectorImpl::forEachContext(
} }
void V8InspectorImpl::forEachSession( void V8InspectorImpl::forEachSession(
int contextGroupId, std::function<void(V8InspectorSessionImpl*)> callback) { int contextGroupId,
const std::function<void(V8InspectorSessionImpl*)>& callback) {
auto it = m_sessions.find(contextGroupId); auto it = m_sessions.find(contextGroupId);
if (it == m_sessions.end()) return; if (it == m_sessions.end()) return;
std::vector<int> ids; std::vector<int> ids;
@ -411,7 +413,7 @@ V8InspectorImpl::EvaluateScope::~EvaluateScope() {
class V8InspectorImpl::EvaluateScope::TerminateTask : public v8::Task { class V8InspectorImpl::EvaluateScope::TerminateTask : public v8::Task {
public: public:
TerminateTask(v8::Isolate* isolate, std::shared_ptr<CancelToken> token) TerminateTask(v8::Isolate* isolate, std::shared_ptr<CancelToken> token)
: m_isolate(isolate), m_token(token) {} : m_isolate(isolate), m_token(std::move(token)) {}
void Run() { void Run() {
// CancelToken contains m_canceled bool which may be changed from main // CancelToken contains m_canceled bool which may be changed from main

View File

@ -120,9 +120,10 @@ class V8InspectorImpl : public V8Inspector {
InspectedContext* getContext(int contextId) const; InspectedContext* getContext(int contextId) const;
V8Console* console(); V8Console* console();
void forEachContext(int contextGroupId, void forEachContext(int contextGroupId,
std::function<void(InspectedContext*)> callback); const std::function<void(InspectedContext*)>& callback);
void forEachSession(int contextGroupId, void forEachSession(
std::function<void(V8InspectorSessionImpl*)> callback); int contextGroupId,
const std::function<void(V8InspectorSessionImpl*)>& callback);
class EvaluateScope { class EvaluateScope {
public: public:

View File

@ -223,7 +223,7 @@ V8StackTraceImpl::V8StackTraceImpl(
const V8StackTraceId& externalParent) const V8StackTraceId& externalParent)
: m_frames(std::move(frames)), : m_frames(std::move(frames)),
m_maxAsyncDepth(maxAsyncDepth), m_maxAsyncDepth(maxAsyncDepth),
m_asyncParent(asyncParent), m_asyncParent(std::move(asyncParent)),
m_externalParent(externalParent) {} m_externalParent(externalParent) {}
V8StackTraceImpl::~V8StackTraceImpl() {} V8StackTraceImpl::~V8StackTraceImpl() {}
@ -392,7 +392,7 @@ AsyncStackTrace::AsyncStackTrace(
m_suspendedTaskId(nullptr), m_suspendedTaskId(nullptr),
m_description(description), m_description(description),
m_frames(std::move(frames)), m_frames(std::move(frames)),
m_asyncParent(asyncParent), m_asyncParent(std::move(asyncParent)),
m_externalParent(externalParent) { m_externalParent(externalParent) {
DCHECK(m_contextGroupId || (!externalParent.IsInvalid() && m_frames.empty())); DCHECK(m_contextGroupId || (!externalParent.IsInvalid() && m_frames.empty()));
} }

View File

@ -62,7 +62,7 @@ class WasmTranslation::TranslatorImpl {
TransLocation(WasmTranslation* translation, String16 script_id, int line, TransLocation(WasmTranslation* translation, String16 script_id, int line,
int column) int column)
: translation(translation), : translation(translation),
script_id(script_id), script_id(std::move(script_id)),
line(line), line(line),
column(column) {} column(column) {}
}; };
@ -238,7 +238,7 @@ class WasmTranslation::TranslatorImpl::DisassemblingTranslator
return builder.toString(); return builder.toString();
} }
String16 GetFakeScriptId(const String16 script_id, int func_index) { String16 GetFakeScriptId(const String16& script_id, int func_index) {
return String16::concat(script_id, '-', String16::fromInteger(func_index)); return String16::concat(script_id, '-', String16::fromInteger(func_index));
} }
String16 GetFakeScriptId(const TransLocation* loc) { String16 GetFakeScriptId(const TransLocation* loc) {