| 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); |
| 163 registerHandler(InstrumentationEvents::PaintLayer, TracePhaseBegin, &Timelin
eTraceEventProcessor::onPaintLayerBegin); |
| 164 registerHandler(InstrumentationEvents::PaintLayer, TracePhaseEnd, &TimelineT
raceEventProcessor::onPaintLayerEnd); |
| 160 registerHandler(InstrumentationEvents::PaintSetup, TracePhaseBegin, &Timelin
eTraceEventProcessor::onPaintSetupBegin); | 165 registerHandler(InstrumentationEvents::PaintSetup, TracePhaseBegin, &Timelin
eTraceEventProcessor::onPaintSetupBegin); |
| 161 registerHandler(InstrumentationEvents::PaintSetup, TracePhaseEnd, &TimelineT
raceEventProcessor::onPaintSetupEnd); | 166 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); | 167 registerHandler(InstrumentationEvents::RasterTask, TracePhaseBegin, &Timelin
eTraceEventProcessor::onRasterTaskBegin); |
| 165 registerHandler(InstrumentationEvents::RasterTask, TracePhaseEnd, &TimelineT
raceEventProcessor::onRasterTaskEnd); | 168 registerHandler(InstrumentationEvents::RasterTask, TracePhaseEnd, &TimelineT
raceEventProcessor::onRasterTaskEnd); |
| 166 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseBegin, &Ti
melineTraceEventProcessor::onImageDecodeTaskBegin); | 169 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseBegin, &Ti
melineTraceEventProcessor::onImageDecodeTaskBegin); |
| 167 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseEnd, &Time
lineTraceEventProcessor::onImageDecodeTaskEnd); | 170 registerHandler(InstrumentationEvents::ImageDecodeTask, TracePhaseEnd, &Time
lineTraceEventProcessor::onImageDecodeTaskEnd); |
| 168 registerHandler(InstrumentationEvents::Layer, TracePhaseDeleteObject, &Timel
ineTraceEventProcessor::onLayerDeleted); | 171 registerHandler(InstrumentationEvents::Layer, TracePhaseDeleteObject, &Timel
ineTraceEventProcessor::onLayerDeleted); |
| 169 registerHandler(InstrumentationEvents::Paint, TracePhaseInstant, &TimelineTr
aceEventProcessor::onPaint); | 172 registerHandler(InstrumentationEvents::Paint, TracePhaseInstant, &TimelineTr
aceEventProcessor::onPaint); |
| 170 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseBegin,
&TimelineTraceEventProcessor::onImageDecodeBegin); | 173 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseBegin,
&TimelineTraceEventProcessor::onImageDecodeBegin); |
| 171 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseEnd, &T
imelineTraceEventProcessor::onImageDecodeEnd); | 174 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseEnd, &T
imelineTraceEventProcessor::onImageDecodeEnd); |
| 172 | 175 |
| 173 TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient); | 176 TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient); |
| (...skipping 49 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 |
| 253 void TimelineTraceEventProcessor::onPaintLayerBegin(const TraceEvent& event) |
| 254 { |
| 255 m_layerId = event.asUInt(InstrumentationEventArguments::LayerId); |
| 256 ASSERT(m_layerId); |
| 257 ASSERT(!m_paintSetupStart); |
| 258 } |
| 259 |
| 260 void TimelineTraceEventProcessor::onPaintLayerEnd(const TraceEvent& event) |
| 261 { |
| 262 m_layerId = 0; |
| 263 ASSERT(m_paintSetupStart); |
| 264 } |
| 265 |
| 233 void TimelineTraceEventProcessor::onPaintSetupBegin(const TraceEvent& event) | 266 void TimelineTraceEventProcessor::onPaintSetupBegin(const TraceEvent& event) |
| 234 { | 267 { |
| 235 ASSERT(!m_paintSetupStart); | 268 ASSERT(!m_paintSetupStart); |
| 236 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti
mestamp()); | 269 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti
mestamp()); |
| 237 } | 270 } |
| 238 | 271 |
| 239 void TimelineTraceEventProcessor::onPaintSetupEnd(const TraceEvent& event) | 272 void TimelineTraceEventProcessor::onPaintSetupEnd(const TraceEvent& event) |
| 240 { | 273 { |
| 241 ASSERT(m_paintSetupStart); | 274 ASSERT(m_paintSetupStart); |
| 242 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time
stamp()); | 275 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time
stamp()); |
| 243 } | 276 } |
| 244 | 277 |
| 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) | 278 void TimelineTraceEventProcessor::onRasterTaskBegin(const TraceEvent& event) |
| 257 { | 279 { |
| 258 TimelineThreadState& state = threadState(event.threadIdentifier()); | 280 TimelineThreadState& state = threadState(event.threadIdentifier()); |
| 259 if (!maybeEnterLayerTask(event, state)) | 281 if (!maybeEnterLayerTask(event, state)) |
| 260 return; | 282 return; |
| 261 unsigned long long layerId = event.asUInt(InstrumentationEventArguments::Lay
erId); | 283 unsigned long long layerId = event.asUInt(InstrumentationEventArguments::Lay
erId); |
| 262 ASSERT(layerId); | 284 ASSERT(layerId); |
| 263 RefPtr<JSONObject> record = createRecord(event, TimelineRecordType::Rasteriz
e); | 285 RefPtr<JSONObject> record = createRecord(event, TimelineRecordType::Rasteriz
e); |
| 264 record->setObject("data", TimelineRecordFactory::createLayerData(m_layerToNo
deMap.get(layerId))); | 286 record->setObject("data", TimelineRecordFactory::createLayerData(m_layerToNo
deMap.get(layerId))); |
| 265 state.recordStack.addScopedRecord(record.release()); | 287 state.recordStack.addScopedRecord(record.release()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 for (size_t i = 0, size = events.size(); i < size; ++i) { | 389 for (size_t i = 0, size = events.size(); i < size; ++i) { |
| 368 const TraceEvent& event = events[i]; | 390 const TraceEvent& event = events[i]; |
| 369 HandlersMap::iterator it = m_handlersByType.find(std::make_pair(event.na
me(), event.phase())); | 391 HandlersMap::iterator it = m_handlersByType.find(std::make_pair(event.na
me(), event.phase())); |
| 370 ASSERT(it != m_handlersByType.end() && it->value); | 392 ASSERT(it != m_handlersByType.end() && it->value); |
| 371 (this->*(it->value))(event); | 393 (this->*(it->value))(event); |
| 372 } | 394 } |
| 373 } | 395 } |
| 374 | 396 |
| 375 } // namespace WebCore | 397 } // namespace WebCore |
| 376 | 398 |
| OLD | NEW |