Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 #endif | 141 #endif |
| 142 | 142 |
| 143 void TimelineRecordStack::send(PassRefPtr<JSONObject> record) | 143 void TimelineRecordStack::send(PassRefPtr<JSONObject> record) |
| 144 { | 144 { |
| 145 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); | 145 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); |
| 146 if (!timelineAgent) | 146 if (!timelineAgent) |
| 147 return; | 147 return; |
| 148 timelineAgent->sendEvent(record); | 148 timelineAgent->sendEvent(record); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimeli neAgent> timelineAgent, InspectorClient *client) | 151 TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimeli neAgent> timelineAgent, InspectorClient *client, bool collectGpuEvents) |
| 152 : m_timelineAgent(timelineAgent) | 152 : m_timelineAgent(timelineAgent) |
| 153 , m_timeConverter(timelineAgent.get()->timeConverter()) | 153 , m_timeConverter(timelineAgent.get()->timeConverter()) |
| 154 , m_inspectorClient(client) | 154 , m_inspectorClient(client) |
| 155 , m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page( ))) | 155 , m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page( ))) |
| 156 , m_layerTreeId(m_timelineAgent.get()->layerTreeId()) | 156 , m_layerTreeId(m_timelineAgent.get()->layerTreeId()) |
| 157 , m_lastEventProcessingTime(0) | 157 , m_lastEventProcessingTime(0) |
| 158 , m_processEventsTaskInFlight(false) | 158 , m_processEventsTaskInFlight(false) |
| 159 , m_layerId(0) | 159 , m_layerId(0) |
| 160 , m_paintSetupStart(0) | 160 , m_paintSetupStart(0) |
| 161 , m_paintSetupEnd(0) | 161 , m_paintSetupEnd(0) |
| 162 , m_gpuTaskStart(0) | |
| 162 { | 163 { |
| 163 registerHandler(InstrumentationEvents::BeginFrame, TRACE_EVENT_PHASE_INSTANT , &TimelineTraceEventProcessor::onBeginFrame); | 164 registerHandler(InstrumentationEvents::BeginFrame, TRACE_EVENT_PHASE_INSTANT , &TimelineTraceEventProcessor::onBeginFrame); |
| 164 registerHandler(InstrumentationEvents::UpdateLayer, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onUpdateLayerBegin); | 165 registerHandler(InstrumentationEvents::UpdateLayer, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onUpdateLayerBegin); |
| 165 registerHandler(InstrumentationEvents::UpdateLayer, TRACE_EVENT_PHASE_END, & TimelineTraceEventProcessor::onUpdateLayerEnd); | 166 registerHandler(InstrumentationEvents::UpdateLayer, TRACE_EVENT_PHASE_END, & TimelineTraceEventProcessor::onUpdateLayerEnd); |
| 166 registerHandler(InstrumentationEvents::PaintLayer, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onPaintLayerBegin); | 167 registerHandler(InstrumentationEvents::PaintLayer, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onPaintLayerBegin); |
| 167 registerHandler(InstrumentationEvents::PaintLayer, TRACE_EVENT_PHASE_END, &T imelineTraceEventProcessor::onPaintLayerEnd); | 168 registerHandler(InstrumentationEvents::PaintLayer, TRACE_EVENT_PHASE_END, &T imelineTraceEventProcessor::onPaintLayerEnd); |
| 168 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onPaintSetupBegin); | 169 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onPaintSetupBegin); |
| 169 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_END, &T imelineTraceEventProcessor::onPaintSetupEnd); | 170 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_END, &T imelineTraceEventProcessor::onPaintSetupEnd); |
| 170 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onRasterTaskBegin); | 171 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_BEGIN, &TimelineTraceEventProcessor::onRasterTaskBegin); |
| 171 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_END, &T imelineTraceEventProcessor::onRasterTaskEnd); | 172 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_END, &T imelineTraceEventProcessor::onRasterTaskEnd); |
| 172 registerHandler(InstrumentationEvents::ImageDecodeTask, TRACE_EVENT_PHASE_BE GIN, &TimelineTraceEventProcessor::onImageDecodeTaskBegin); | 173 registerHandler(InstrumentationEvents::ImageDecodeTask, TRACE_EVENT_PHASE_BE GIN, &TimelineTraceEventProcessor::onImageDecodeTaskBegin); |
| 173 registerHandler(InstrumentationEvents::ImageDecodeTask, TRACE_EVENT_PHASE_EN D, &TimelineTraceEventProcessor::onImageDecodeTaskEnd); | 174 registerHandler(InstrumentationEvents::ImageDecodeTask, TRACE_EVENT_PHASE_EN D, &TimelineTraceEventProcessor::onImageDecodeTaskEnd); |
| 174 registerHandler(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_DELETE_OBJEC T, &TimelineTraceEventProcessor::onLayerDeleted); | 175 registerHandler(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_DELETE_OBJEC T, &TimelineTraceEventProcessor::onLayerDeleted); |
| 175 registerHandler(InstrumentationEvents::Paint, TRACE_EVENT_PHASE_INSTANT, &Ti melineTraceEventProcessor::onPaint); | 176 registerHandler(InstrumentationEvents::Paint, TRACE_EVENT_PHASE_INSTANT, &Ti melineTraceEventProcessor::onPaint); |
| 176 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE _BEGIN, &TimelineTraceEventProcessor::onImageDecodeBegin); | 177 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE _BEGIN, &TimelineTraceEventProcessor::onImageDecodeBegin); |
| 177 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE _END, &TimelineTraceEventProcessor::onImageDecodeEnd); | 178 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE _END, &TimelineTraceEventProcessor::onImageDecodeEnd); |
| 178 registerHandler(PlatformInstrumentation::DrawLazyPixelRefEvent, TRACE_EVENT_ PHASE_INSTANT, &TimelineTraceEventProcessor::onDrawLazyPixelRef); | 179 registerHandler(PlatformInstrumentation::DrawLazyPixelRefEvent, TRACE_EVENT_ PHASE_INSTANT, &TimelineTraceEventProcessor::onDrawLazyPixelRef); |
| 179 registerHandler(PlatformInstrumentation::LazyPixelRef, TRACE_EVENT_PHASE_DEL ETE_OBJECT, &TimelineTraceEventProcessor::onLazyPixelRefDeleted); | 180 registerHandler(PlatformInstrumentation::LazyPixelRef, TRACE_EVENT_PHASE_DEL ETE_OBJECT, &TimelineTraceEventProcessor::onLazyPixelRefDeleted); |
| 181 if (collectGpuEvents) { | |
| 182 // FIXME: Instead of filtering GPU events here on the client side | |
| 183 // just don't enable collection in the GPU process. | |
| 184 // Make sure GPU process agent can handle both client types connected | |
| 185 // simultaneously: ones that need GPU events and ones that do not. | |
| 186 registerHandler(PlatformInstrumentation::GpuTask, TRACE_EVENT_PHASE_BEGI N, &TimelineTraceEventProcessor::onGpuTaskBegin); | |
| 187 registerHandler(PlatformInstrumentation::GpuTask, TRACE_EVENT_PHASE_END, &TimelineTraceEventProcessor::onGpuTaskEnd); | |
| 188 } | |
| 180 | 189 |
| 181 TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient); | 190 TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient); |
| 182 } | 191 } |
| 183 | 192 |
| 184 TimelineTraceEventProcessor::~TimelineTraceEventProcessor() | 193 TimelineTraceEventProcessor::~TimelineTraceEventProcessor() |
| 185 { | 194 { |
| 186 } | 195 } |
| 187 | 196 |
| 188 void TimelineTraceEventProcessor::registerHandler(const char* name, char phase, TraceEventHandler handler) | 197 void TimelineTraceEventProcessor::registerHandler(const char* name, char phase, TraceEventHandler handler) |
| 189 { | 198 { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 if (const ImageResource* resource = renderImage->cachedImage()) | 419 if (const ImageResource* resource = renderImage->cachedImage()) |
| 411 url = resource->url().string(); | 420 url = resource->url().string(); |
| 412 m_pixelRefToImageInfo.set(pixelRefId, ImageInfo(nodeId, url)); | 421 m_pixelRefToImageInfo.set(pixelRefId, ImageInfo(nodeId, url)); |
| 413 } | 422 } |
| 414 | 423 |
| 415 void TimelineTraceEventProcessor::onLazyPixelRefDeleted(const TraceEvent& event) | 424 void TimelineTraceEventProcessor::onLazyPixelRefDeleted(const TraceEvent& event) |
| 416 { | 425 { |
| 417 m_pixelRefToImageInfo.remove(event.id()); | 426 m_pixelRefToImageInfo.remove(event.id()); |
| 418 } | 427 } |
| 419 | 428 |
| 429 void TimelineTraceEventProcessor::onGpuTaskBegin(const TraceEvent& event) | |
| 430 { | |
| 431 m_gpuTaskStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.times tamp()); | |
| 432 m_gpuTaskRendererPid = event.asUInt(PlatformInstrumentation::GpuTaskRenderer Pid); | |
|
caseq
2013/11/01 13:04:20
nit: m_gpuTask(Initiator|Owner)Pid
alph
2013/11/01 16:40:19
Done.
| |
| 433 } | |
| 434 | |
| 435 void TimelineTraceEventProcessor::onGpuTaskEnd(const TraceEvent& event) | |
| 436 { | |
| 437 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); | |
| 438 if (!timelineAgent || !m_gpuTaskStart) | |
| 439 return; | |
| 440 RefPtr<JSONObject> gpuEvent = TimelineRecordFactory::createBackgroundRecord( m_gpuTaskStart, "gpu"); | |
|
caseq
2013/11/01 13:04:20
Use TimelineTraceProcessor::createRecord() instead
alph
2013/11/01 16:40:19
Done.
| |
| 441 RefPtr<JSONObject> data = JSONObject::create(); | |
| 442 gpuEvent->setString("type", TimelineRecordType::GpuTask); | |
| 443 gpuEvent->setNumber("endTime", m_timeConverter.fromMonotonicallyIncreasingTi me(event.timestamp())); | |
| 444 gpuEvent->setObject("data", data); | |
| 445 data->setString("name", event.name()); | |
| 446 data->setNumber("rendererPid", m_gpuTaskRendererPid); | |
| 447 timelineAgent->sendEvent(gpuEvent); | |
| 448 m_gpuTaskStart = 0; | |
| 449 } | |
| 450 | |
| 420 PassRefPtr<JSONObject> TimelineTraceEventProcessor::createRecord(const TraceEven t& event, const String& recordType, PassRefPtr<JSONObject> data) | 451 PassRefPtr<JSONObject> TimelineTraceEventProcessor::createRecord(const TraceEven t& event, const String& recordType, PassRefPtr<JSONObject> data) |
| 421 { | 452 { |
| 422 double startTime = m_timeConverter.fromMonotonicallyIncreasingTime(event.tim estamp()); | 453 double startTime = m_timeConverter.fromMonotonicallyIncreasingTime(event.tim estamp()); |
| 423 RefPtr<JSONObject> record = TimelineRecordFactory::createBackgroundRecord(st artTime, String::number(event.threadIdentifier())); | 454 RefPtr<JSONObject> record = TimelineRecordFactory::createBackgroundRecord(st artTime, String::number(event.threadIdentifier())); |
| 424 record->setString("type", recordType); | 455 record->setString("type", recordType); |
| 425 record->setObject("data", data ? data : JSONObject::create()); | 456 record->setObject("data", data ? data : JSONObject::create()); |
| 426 return record.release(); | 457 return record.release(); |
| 427 } | 458 } |
| 428 | 459 |
| 429 void TimelineTraceEventProcessor::processBackgroundEvents() | 460 void TimelineTraceEventProcessor::processBackgroundEvents() |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 447 } | 478 } |
| 448 | 479 |
| 449 void TimelineTraceEventProcessor::processBackgroundEventsTask() | 480 void TimelineTraceEventProcessor::processBackgroundEventsTask() |
| 450 { | 481 { |
| 451 m_processEventsTaskInFlight = false; | 482 m_processEventsTaskInFlight = false; |
| 452 processBackgroundEvents(); | 483 processBackgroundEvents(); |
| 453 } | 484 } |
| 454 | 485 |
| 455 } // namespace WebCore | 486 } // namespace WebCore |
| 456 | 487 |
| OLD | NEW |