mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix up strings Sky passes to base/trace_event
String parameters passed to the trace macros in base/trace_event must either be std::string (which Sky doesn't use very much), pointers to null terminated C-style strings that live forever (like a string literal) pointers to C-style strings that are annotated by macro as needing to be copied. This fixes up a few instances that passed pointers to temporary strings without the copying annotation or pointers to non-null-terminated strings so the trace data doesn't have random garbage memory in it. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1107853003
This commit is contained in:
parent
3507c90d4b
commit
209153d192
@ -56,7 +56,9 @@ bool GenericEventQueue::enqueueEvent(PassRefPtr<Event> event)
|
||||
if (event->target() == m_owner)
|
||||
event->setTarget(nullptr);
|
||||
|
||||
TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.get(), "type", event->type().ascii().data());
|
||||
TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent",
|
||||
event.get(), "type",
|
||||
TRACE_STR_COPY(event->type().ascii().data()));
|
||||
m_pendingEvents.append(event);
|
||||
|
||||
if (!m_timer.isActive())
|
||||
@ -71,7 +73,10 @@ bool GenericEventQueue::cancelEvent(Event* event)
|
||||
|
||||
if (found) {
|
||||
m_pendingEvents.remove(m_pendingEvents.find(event));
|
||||
TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii().data(), "status", "cancelled");
|
||||
TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event,
|
||||
"type",
|
||||
TRACE_STR_COPY(event->type().ascii().data()),
|
||||
"status", "cancelled");
|
||||
}
|
||||
|
||||
if (m_pendingEvents.isEmpty())
|
||||
@ -111,7 +116,10 @@ void GenericEventQueue::cancelAllEvents()
|
||||
|
||||
for (size_t i = 0; i < m_pendingEvents.size(); ++i) {
|
||||
Event* event = m_pendingEvents[i].get();
|
||||
TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii().data(), "status", "cancelled");
|
||||
TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event,
|
||||
"type",
|
||||
TRACE_STR_COPY(event->type().ascii().data()),
|
||||
"status", "cancelled");
|
||||
}
|
||||
m_pendingEvents.clear();
|
||||
}
|
||||
|
||||
@ -694,7 +694,10 @@ void ResourceFetcher::willTerminateResourceLoader(ResourceLoader* loader)
|
||||
|
||||
void ResourceFetcher::willStartLoadingResource(Resource* resource, ResourceRequest& request)
|
||||
{
|
||||
TRACE_EVENT_ASYNC_BEGIN2("net", "Resource", resource, "url", resource->url().string().ascii().data(), "priority", resource->resourceRequest().priority());
|
||||
TRACE_EVENT_ASYNC_BEGIN2(
|
||||
"net", "Resource", resource, "url",
|
||||
TRACE_STR_COPY(resource->url().string().ascii().data()), "priority",
|
||||
resource->resourceRequest().priority());
|
||||
}
|
||||
|
||||
void ResourceFetcher::stopFetching()
|
||||
|
||||
@ -21,13 +21,17 @@ Tracing::~Tracing()
|
||||
void Tracing::begin(const String& name)
|
||||
{
|
||||
StringUTF8Adaptor utf8(name);
|
||||
TRACE_EVENT_COPY_BEGIN0("script", utf8.data());
|
||||
// TRACE_EVENT_COPY_BEGIN0 needs a c-style null-terminated string.
|
||||
CString cstring(utf8.data(), utf8.length());
|
||||
TRACE_EVENT_COPY_BEGIN0("script", cstring.data());
|
||||
}
|
||||
|
||||
void Tracing::end(const String& name)
|
||||
{
|
||||
StringUTF8Adaptor utf8(name);
|
||||
TRACE_EVENT_COPY_END0("script", utf8.data());
|
||||
// TRACE_EVENT_COPY_END0 needs a c-style null-terminated string.
|
||||
CString cstring(utf8.data(), utf8.length());
|
||||
TRACE_EVENT_COPY_END0("script", cstring.data());
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@ -311,7 +311,8 @@ static String inputTypeToName(WebInputEvent::Type type)
|
||||
|
||||
bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
|
||||
{
|
||||
TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToName(inputEvent.type).ascii().data());
|
||||
TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type",
|
||||
TRACE_STR_COPY(inputTypeToName(inputEvent.type).ascii().data()));
|
||||
|
||||
if (WebInputEvent::isPointerEventType(inputEvent.type)) {
|
||||
const WebPointerEvent& event = static_cast<const WebPointerEvent&>(inputEvent);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user