| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 if (!timelineAgent) | 145 if (!timelineAgent) |
| 146 return; | 146 return; |
| 147 timelineAgent->sendEvent(record); | 147 timelineAgent->sendEvent(record); |
| 148 } | 148 } |
| 149 | 149 |
| 150 TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimeli
neAgent> timelineAgent, InspectorClient *client) | 150 TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimeli
neAgent> timelineAgent, InspectorClient *client) |
| 151 : m_timelineAgent(timelineAgent) | 151 : m_timelineAgent(timelineAgent) |
| 152 , m_timeConverter(timelineAgent.get()->timeConverter()) | 152 , m_timeConverter(timelineAgent.get()->timeConverter()) |
| 153 , m_inspectorClient(client) | 153 , m_inspectorClient(client) |
| 154 , m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page(
))) | 154 , m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page(
))) |
| 155 , m_layerTreeId(m_timelineAgent.get()->layerTreeId()) |
| 155 , m_layerId(0) | 156 , m_layerId(0) |
| 156 , m_paintSetupStart(0) | 157 , m_paintSetupStart(0) |
| 157 , m_paintSetupEnd(0) | 158 , m_paintSetupEnd(0) |
| 158 { | 159 { |
| 159 registerHandler(InstrumentationEvents::BeginFrame, TracePhaseInstant, &Timel
ineTraceEventProcessor::onBeginFrame); | 160 registerHandler(InstrumentationEvents::BeginFrame, TracePhaseInstant, &Timel
ineTraceEventProcessor::onBeginFrame); |
| 161 registerHandler(InstrumentationEvents::UpdateLayer, TracePhaseBegin, &Timeli
neTraceEventProcessor::onUpdateLayerBegin); |
| 162 registerHandler(InstrumentationEvents::UpdateLayer, TracePhaseEnd, &Timeline
TraceEventProcessor::onUpdateLayerEnd); |
| 160 registerHandler(InstrumentationEvents::PaintSetup, TracePhaseBegin, &Timelin
eTraceEventProcessor::onPaintSetupBegin); | 163 registerHandler(InstrumentationEvents::PaintSetup, TracePhaseBegin, &Timelin
eTraceEventProcessor::onPaintSetupBegin); |
| 161 registerHandler(InstrumentationEvents::PaintSetup, TracePhaseEnd, &TimelineT
raceEventProcessor::onPaintSetupEnd); | 164 registerHandler(InstrumentationEvents::PaintSetup, TracePhaseEnd, &TimelineT
raceEventProcessor::onPaintSetupEnd); |
| 162 registerHandler(InstrumentationEvents::PaintLayer, TracePhaseBegin, &Timelin
eTraceEventProcessor::onPaintLayerBegin); | |
| 163 registerHandler(InstrumentationEvents::PaintLayer, TracePhaseEnd, &TimelineT
raceEventProcessor::onPaintLayerEnd); | |
| 164 registerHandler(InstrumentationEvents::RasterTask, TracePhaseBegin, &Timelin
eTraceEventProcessor::onRasterTaskBegin); | 165 registerHandler(InstrumentationEvents::RasterTask, TracePhaseBegin, &Timelin
eTraceEventProcessor::onRasterTaskBegin); |
| 165 registerHandler(InstrumentationEvents::RasterTask, TracePhaseEnd, &TimelineT
raceEventProcessor::onRasterTaskEnd); | 166 registerHandler(InstrumentationEvents::RasterTask, TracePhaseEnd, &TimelineT
raceEventProcessor::onRasterTaskEnd); |
| 166 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseBegin, &Ti
melineTraceEventProcessor::onImageDecodeTaskBegin); | 167 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseBegin, &Ti
melineTraceEventProcessor::onImageDecodeTaskBegin); |
| 167 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseEnd, &Time
lineTraceEventProcessor::onImageDecodeTaskEnd); | 168 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseEnd, &Time
lineTraceEventProcessor::onImageDecodeTaskEnd); |
| 168 registerHandler(InstrumentationEvents::Layer, TracePhaseDeleteObject, &Timel
ineTraceEventProcessor::onLayerDeleted); | 169 registerHandler(InstrumentationEvents::Layer, TracePhaseDeleteObject, &Timel
ineTraceEventProcessor::onLayerDeleted); |
| 169 registerHandler(InstrumentationEvents::Paint, TracePhaseInstant, &TimelineTr
aceEventProcessor::onPaint); | 170 registerHandler(InstrumentationEvents::Paint, TracePhaseInstant, &TimelineTr
aceEventProcessor::onPaint); |
| 170 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseBegin,
&TimelineTraceEventProcessor::onImageDecodeBegin); | 171 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseBegin,
&TimelineTraceEventProcessor::onImageDecodeBegin); |
| 171 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseEnd, &T
imelineTraceEventProcessor::onImageDecodeEnd); | 172 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseEnd, &T
imelineTraceEventProcessor::onImageDecodeEnd); |
| 173 registerHandler(PlatformInstrumentation::RasterizeCanvasEvent, TracePhaseBeg
in, &TimelineTraceEventProcessor::onRasterizeCanvasBegin); |
| 174 registerHandler(PlatformInstrumentation::RasterizeCanvasEvent, TracePhaseEnd
, &TimelineTraceEventProcessor::onRasterizeCanvasEnd); |
| 172 | 175 |
| 173 TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient); | 176 TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient); |
| 174 } | 177 } |
| 175 | 178 |
| 176 TimelineTraceEventProcessor::~TimelineTraceEventProcessor() | 179 TimelineTraceEventProcessor::~TimelineTraceEventProcessor() |
| 177 { | 180 { |
| 178 } | 181 } |
| 179 | 182 |
| 180 void TimelineTraceEventProcessor::registerHandler(const char* name, TraceEventPh
ase phase, TraceEventHandler handler) | 183 void TimelineTraceEventProcessor::registerHandler(const char* name, TraceEventPh
ase phase, TraceEventHandler handler) |
| 181 { | 184 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return; | 226 return; |
| 224 } | 227 } |
| 225 (this->*(it->value))(event); | 228 (this->*(it->value))(event); |
| 226 } | 229 } |
| 227 | 230 |
| 228 void TimelineTraceEventProcessor::onBeginFrame(const TraceEvent&) | 231 void TimelineTraceEventProcessor::onBeginFrame(const TraceEvent&) |
| 229 { | 232 { |
| 230 processBackgroundEvents(); | 233 processBackgroundEvents(); |
| 231 } | 234 } |
| 232 | 235 |
| 236 void TimelineTraceEventProcessor::onUpdateLayerBegin(const TraceEvent& event) |
| 237 { |
| 238 unsigned long long layerTreeId = event.asUInt(InstrumentationEventArguments:
:LayerTreeId); |
| 239 if (layerTreeId != m_layerTreeId) |
| 240 return; |
| 241 m_layerId = event.asUInt(InstrumentationEventArguments::LayerId); |
| 242 // We don't know the node yet. For content layers, the node will be updated |
| 243 // by paint. For others, let it remain 0 -- we just need the fact that |
| 244 // the layer belongs to the page (see cookie check). |
| 245 m_layerToNodeMap.add(m_layerId, 0); |
| 246 } |
| 247 |
| 248 void TimelineTraceEventProcessor::onUpdateLayerEnd(const TraceEvent& event) |
| 249 { |
| 250 m_layerId = 0; |
| 251 } |
| 252 |
| 233 void TimelineTraceEventProcessor::onPaintSetupBegin(const TraceEvent& event) | 253 void TimelineTraceEventProcessor::onPaintSetupBegin(const TraceEvent& event) |
| 234 { | 254 { |
| 235 ASSERT(!m_paintSetupStart); | 255 ASSERT(!m_paintSetupStart); |
| 236 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti
mestamp()); | 256 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti
mestamp()); |
| 237 } | 257 } |
| 238 | 258 |
| 239 void TimelineTraceEventProcessor::onPaintSetupEnd(const TraceEvent& event) | 259 void TimelineTraceEventProcessor::onPaintSetupEnd(const TraceEvent& event) |
| 240 { | 260 { |
| 241 ASSERT(m_paintSetupStart); | 261 ASSERT(m_paintSetupStart); |
| 242 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time
stamp()); | 262 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time
stamp()); |
| 243 } | 263 } |
| 244 | 264 |
| 245 void TimelineTraceEventProcessor::onPaintLayerBegin(const TraceEvent& event) | |
| 246 { | |
| 247 m_layerId = event.asUInt(InstrumentationEventArguments::LayerId); | |
| 248 ASSERT(m_layerId); | |
| 249 } | |
| 250 | |
| 251 void TimelineTraceEventProcessor::onPaintLayerEnd(const TraceEvent&) | |
| 252 { | |
| 253 m_layerId = 0; | |
| 254 } | |
| 255 | |
| 256 void TimelineTraceEventProcessor::onRasterTaskBegin(const TraceEvent& event) | 265 void TimelineTraceEventProcessor::onRasterTaskBegin(const TraceEvent& event) |
| 257 { | 266 { |
| 258 TimelineThreadState& state = threadState(event.threadIdentifier()); | 267 TimelineThreadState& state = threadState(event.threadIdentifier()); |
| 259 if (!maybeEnterLayerTask(event, state)) | 268 if (!maybeEnterLayerTask(event, state)) |
| 260 return; | 269 return; |
| 261 unsigned long long layerId = event.asUInt(InstrumentationEventArguments::Lay
erId); | 270 unsigned long long layerId = event.asUInt(InstrumentationEventArguments::Lay
erId); |
| 262 ASSERT(layerId); | 271 ASSERT(layerId); |
| 263 RefPtr<JSONObject> record = createRecord(event, TimelineRecordType::Rasteriz
e); | 272 RefPtr<JSONObject> record = createRecord(event, TimelineRecordType::Rasteriz
e); |
| 264 record->setObject("data", TimelineRecordFactory::createLayerData(m_layerToNo
deMap.get(layerId))); | 273 record->setObject("data", TimelineRecordFactory::createLayerData(m_layerToNo
deMap.get(layerId))); |
| 265 state.recordStack.addScopedRecord(record.release()); | 274 state.recordStack.addScopedRecord(record.release()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 unsigned long long id = event.id(); | 331 unsigned long long id = event.id(); |
| 323 ASSERT(id); | 332 ASSERT(id); |
| 324 processBackgroundEvents(); | 333 processBackgroundEvents(); |
| 325 m_layerToNodeMap.remove(id); | 334 m_layerToNodeMap.remove(id); |
| 326 } | 335 } |
| 327 | 336 |
| 328 void TimelineTraceEventProcessor::onPaint(const TraceEvent& event) | 337 void TimelineTraceEventProcessor::onPaint(const TraceEvent& event) |
| 329 { | 338 { |
| 330 double paintSetupStart = m_paintSetupStart; | 339 double paintSetupStart = m_paintSetupStart; |
| 331 m_paintSetupStart = 0; | 340 m_paintSetupStart = 0; |
| 332 if (!m_layerId) | |
| 333 return; | |
| 334 unsigned long long pageId = event.asUInt(InstrumentationEventArguments::Page
Id); | 341 unsigned long long pageId = event.asUInt(InstrumentationEventArguments::Page
Id); |
| 335 if (pageId != m_pageId) | 342 if (pageId != m_pageId) |
| 336 return; | 343 return; |
| 344 ASSERT(m_layerId); |
| 337 long long nodeId = event.asInt(InstrumentationEventArguments::NodeId); | 345 long long nodeId = event.asInt(InstrumentationEventArguments::NodeId); |
| 338 ASSERT(nodeId); | 346 ASSERT(nodeId); |
| 339 m_layerToNodeMap.set(m_layerId, nodeId); | 347 m_layerToNodeMap.set(m_layerId, nodeId); |
| 340 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); | 348 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); |
| 341 if (timelineAgent && paintSetupStart) { | 349 if (timelineAgent && paintSetupStart) { |
| 342 RefPtr<JSONObject> paintSetupRecord = TimelineRecordFactory::createGener
icRecord(paintSetupStart, 0, TimelineRecordType::PaintSetup); | 350 RefPtr<JSONObject> paintSetupRecord = TimelineRecordFactory::createGener
icRecord(paintSetupStart, 0, TimelineRecordType::PaintSetup); |
| 343 paintSetupRecord->setNumber("endTime", m_paintSetupEnd); | 351 paintSetupRecord->setNumber("endTime", m_paintSetupEnd); |
| 344 paintSetupRecord->setObject("data", TimelineRecordFactory::createLayerDa
ta(nodeId)); | 352 paintSetupRecord->setObject("data", TimelineRecordFactory::createLayerDa
ta(nodeId)); |
| 345 timelineAgent->addRecordToTimeline(paintSetupRecord); | 353 timelineAgent->addRecordToTimeline(paintSetupRecord); |
| 346 } | 354 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 367 for (size_t i = 0, size = events.size(); i < size; ++i) { | 375 for (size_t i = 0, size = events.size(); i < size; ++i) { |
| 368 const TraceEvent& event = events[i]; | 376 const TraceEvent& event = events[i]; |
| 369 HandlersMap::iterator it = m_handlersByType.find(std::make_pair(event.na
me(), event.phase())); | 377 HandlersMap::iterator it = m_handlersByType.find(std::make_pair(event.na
me(), event.phase())); |
| 370 ASSERT(it != m_handlersByType.end() && it->value); | 378 ASSERT(it != m_handlersByType.end() && it->value); |
| 371 (this->*(it->value))(event); | 379 (this->*(it->value))(event); |
| 372 } | 380 } |
| 373 } | 381 } |
| 374 | 382 |
| 375 } // namespace WebCore | 383 } // namespace WebCore |
| 376 | 384 |
| OLD | NEW |