Commit 01b4acba authored by timothy@apple.com's avatar timothy@apple.com

Remove TimelineTraceEventProcessor since no current ports use it

https://bugs.webkit.org/show_bug.cgi?id=121171

Reviewed by Joseph Pecoraro.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorClient.h:
* inspector/InspectorInstrumentation.cpp:
* inspector/InspectorInstrumentation.h:
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::stop):
* inspector/InspectorTimelineAgent.h:
* inspector/TimelineTraceEventProcessor.cpp: Removed.
* inspector/TimelineTraceEventProcessor.h: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155549 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0ce6a86a
......@@ -1622,7 +1622,6 @@ set(WebCore_SOURCES
inspector/ScriptCallFrame.cpp
inspector/ScriptCallStack.cpp
inspector/TimelineRecordFactory.cpp
inspector/TimelineTraceEventProcessor.cpp
inspector/WorkerConsoleAgent.cpp
inspector/WorkerDebuggerAgent.cpp
inspector/WorkerInspectorController.cpp
......
2013-09-11 Timothy Hatcher <timothy@apple.com>
Remove TimelineTraceEventProcessor since no current ports use it
https://bugs.webkit.org/show_bug.cgi?id=121171
Reviewed by Joseph Pecoraro.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorClient.h:
* inspector/InspectorInstrumentation.cpp:
* inspector/InspectorInstrumentation.h:
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::stop):
* inspector/InspectorTimelineAgent.h:
* inspector/TimelineTraceEventProcessor.cpp: Removed.
* inspector/TimelineTraceEventProcessor.h: Removed.
2013-09-11 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r155519.
......@@ -3930,8 +3930,6 @@ webcore_sources += \
Source/WebCore/inspector/ScriptGCEventListener.h \
Source/WebCore/inspector/TimelineRecordFactory.cpp \
Source/WebCore/inspector/TimelineRecordFactory.h \
Source/WebCore/inspector/TimelineTraceEventProcessor.cpp \
Source/WebCore/inspector/TimelineTraceEventProcessor.h \
Source/WebCore/inspector/WorkerConsoleAgent.cpp \
Source/WebCore/inspector/WorkerConsoleAgent.h \
Source/WebCore/inspector/WorkerDebuggerAgent.cpp \
......
......@@ -813,7 +813,6 @@ SOURCES += \
inspector/ScriptCallFrame.cpp \
inspector/ScriptCallStack.cpp \
inspector/TimelineRecordFactory.cpp \
inspector/TimelineTraceEventProcessor.cpp \
inspector/WorkerConsoleAgent.cpp \
inspector/WorkerDebuggerAgent.cpp \
inspector/WorkerInspectorController.cpp \
......
......@@ -6726,14 +6726,6 @@
<ClCompile Include="..\html\track\VideoTrack.cpp" />
<ClCompile Include="..\html\track\VideoTrackList.cpp" />
<ClCompile Include="..\html\track\WebVTTElement.cpp" />
<ClCompile Include="..\inspector\TimelineTraceEventProcessor.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\Modules\filesystem\DirectoryEntry.cpp" />
<ClCompile Include="..\Modules\filesystem\DirectoryEntrySync.cpp" />
<ClCompile Include="..\Modules\filesystem\DirectoryReader.cpp" />
......@@ -18877,7 +18869,6 @@
<ClInclude Include="..\html\track\VideoTrack.h" />
<ClInclude Include="..\html\track\VideoTrackList.h" />
<ClInclude Include="..\html\track\WebVTTElement.h" />
<ClInclude Include="..\inspector\TimelineTraceEventProcessor.h" />
<ClInclude Include="..\Modules\filesystem\AsyncFileWriter.h" />
<ClInclude Include="..\Modules\filesystem\AsyncFileWriterClient.h" />
<ClInclude Include="..\Modules\filesystem\DirectoryEntry.h" />
......@@ -5353,9 +5353,6 @@
<ClCompile Include="..\svg\graphics\SVGImageForContainer.cpp">
<Filter>rendering\svg\graphics</Filter>
</ClCompile>
<ClCompile Include="..\inspector\TimelineTraceEventProcessor.cpp">
<Filter>inspector</Filter>
</ClCompile>
<ClCompile Include="..\rendering\HitTestLocation.cpp">
<Filter>rendering</Filter>
</ClCompile>
......@@ -13133,9 +13130,6 @@
<ClInclude Include="..\svg\graphics\SVGImageForContainer.h">
<Filter>rendering\svg\graphics</Filter>
</ClInclude>
<ClInclude Include="..\inspector\TimelineTraceEventProcessor.h">
<Filter>inspector</Filter>
</ClInclude>
<ClInclude Include="..\rendering\HitTestLocation.h">
<Filter>rendering</Filter>
</ClInclude>
......
......@@ -1362,8 +1362,6 @@
46F9D5DF0B0D60170028EE36 /* progressCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DC0B0D60170028EE36 /* progressCursor.png */; };
490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */; };
490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; };
49140256168E02E8002D6C6A /* TimelineTraceEventProcessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49140254168E02B4002D6C6A /* TimelineTraceEventProcessor.cpp */; };
49140257168E02EC002D6C6A /* TimelineTraceEventProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49140255168E02B4002D6C6A /* TimelineTraceEventProcessor.h */; };
49182B5215DCE6F000548418 /* PlatformInstrumentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49182B5015DCE6F000548418 /* PlatformInstrumentation.cpp */; };
49182B5315DCE6F000548418 /* PlatformInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 49182B5115DCE6F000548418 /* PlatformInstrumentation.h */; };
49291E4B134172C800E753DE /* ImageRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 49291E4A134172C800E753DE /* ImageRenderingMode.h */; };
......@@ -7866,8 +7864,6 @@
46F9D5DC0B0D60170028EE36 /* progressCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = progressCursor.png; sourceTree = "<group>"; };
490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEWebKitBridge.cpp; sourceTree = "<group>"; };
490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; };
49140254168E02B4002D6C6A /* TimelineTraceEventProcessor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimelineTraceEventProcessor.cpp; sourceTree = "<group>"; };
49140255168E02B4002D6C6A /* TimelineTraceEventProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimelineTraceEventProcessor.h; sourceTree = "<group>"; };
49182B5015DCE6F000548418 /* PlatformInstrumentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformInstrumentation.cpp; sourceTree = "<group>"; };
49182B5115DCE6F000548418 /* PlatformInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformInstrumentation.h; sourceTree = "<group>"; };
49291E4A134172C800E753DE /* ImageRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageRenderingMode.h; sourceTree = "<group>"; };
......@@ -14109,8 +14105,6 @@
9FA37EF01172FD4100C4CD55 /* ScriptProfileNode.idl */,
7553CFE7108F473F00EA281E /* TimelineRecordFactory.cpp */,
7553CFE6108F473F00EA281E /* TimelineRecordFactory.h */,
49140254168E02B4002D6C6A /* TimelineTraceEventProcessor.cpp */,
49140255168E02B4002D6C6A /* TimelineTraceEventProcessor.h */,
F382088E147D35F90010BC06 /* WorkerConsoleAgent.cpp */,
F382088F147D35F90010BC06 /* WorkerConsoleAgent.h */,
F34742DE1343631F00531BC2 /* WorkerDebuggerAgent.cpp */,
......@@ -24308,7 +24302,6 @@
498770F31242C535002226BA /* TilingData.h in Headers */,
F55B3DDC1251F12D003EF269 /* TimeInputType.h in Headers */,
7553CFE8108F473F00EA281E /* TimelineRecordFactory.h in Headers */,
49140257168E02EC002D6C6A /* TimelineTraceEventProcessor.h in Headers */,
9305B24D098F1B6B00C28855 /* Timer.h in Headers */,
E44613B00CD6331000FADA75 /* TimeRanges.h in Headers */,
49E912AE0EFAC906009D0CAF /* TimingFunction.h in Headers */,
......@@ -27384,7 +27377,6 @@
498770F21242C535002226BA /* TilingData.cpp in Sources */,
F55B3DDB1251F12D003EF269 /* TimeInputType.cpp in Sources */,
7553CFE9108F473F00EA281E /* TimelineRecordFactory.cpp in Sources */,
49140256168E02E8002D6C6A /* TimelineTraceEventProcessor.cpp in Sources */,
93309EA4099EB78C0056E581 /* Timer.cpp in Sources */,
E44613AF0CD6331000FADA75 /* TimeRanges.cpp in Sources */,
070334D9145A006F008D8D45 /* TrackBase.cpp in Sources */,
......@@ -81,7 +81,6 @@
#include "ScriptCallFrame.cpp"
#include "ScriptCallStack.cpp"
#include "TimelineRecordFactory.cpp"
#include "TimelineTraceEventProcessor.cpp"
#include "WorkerConsoleAgent.cpp"
#include "WorkerDebuggerAgent.cpp"
#include "WorkerInspectorController.cpp"
......
......@@ -59,11 +59,6 @@ public:
virtual void clearBrowserCookies() { }
virtual bool canMonitorMainThread() { return false; }
typedef void (*TraceEventCallback)(char phase, const unsigned char*, const char* name, unsigned long long id,
int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues,
unsigned char flags);
virtual void setTraceEventCallback(TraceEventCallback) { }
virtual bool canOverrideDeviceMetrics() { return false; }
virtual void overrideDeviceMetrics(int /*width*/, int /*height*/, float /*fontScaleFactor*/, bool /*fitWindow*/)
......
......@@ -1387,19 +1387,6 @@ void InspectorInstrumentation::pseudoElementDestroyedImpl(InstrumentingAgents* i
}
#endif
namespace InstrumentationEvents {
const char PaintLayer[] = "PaintLayer";
const char RasterTask[] = "RasterTask";
const char Paint[] = "Paint";
const char Layer[] = "Layer";
const char BeginFrame[] = "BeginFrame";
};
namespace InstrumentationEventArguments {
const char LayerId[] = "layerId";
const char PageId[] = "pageId";
};
} // namespace WebCore
#endif // !ENABLE(INSPECTOR)
......@@ -512,19 +512,6 @@ private:
#endif
};
namespace InstrumentationEvents {
extern const char PaintLayer[];
extern const char RasterTask[];
extern const char Paint[];
extern const char Layer[];
extern const char BeginFrame[];
};
namespace InstrumentationEventArguments {
extern const char LayerId[];
extern const char PageId[];
};
inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
{
#if ENABLE(INSPECTOR)
......
......@@ -52,7 +52,6 @@
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "TimelineRecordFactory.h"
#include "TimelineTraceEventProcessor.h"
#include <wtf/CurrentTime.h>
......@@ -191,8 +190,6 @@ void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth, c
m_instrumentingAgents->setInspectorTimelineAgent(this);
ScriptGCEvent::addEventListener(this);
m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, true);
if (m_client && m_pageAgent)
m_traceEventProcessor = adoptRef(new TimelineTraceEventProcessor(m_weakFactory.createWeakPtr(), m_client));
}
void InspectorTimelineAgent::stop(ErrorString*)
......@@ -200,8 +197,6 @@ void InspectorTimelineAgent::stop(ErrorString*)
if (!m_state->getBoolean(TimelineAgentState::timelineAgentEnabled))
return;
m_traceEventProcessor->shutdown();
m_traceEventProcessor.clear();
m_weakFactory.revokeAll();
m_instrumentingAgents->setInspectorTimelineAgent(0);
ScriptGCEvent::removeEventListener(this);
......
......@@ -60,7 +60,6 @@ class Page;
class RenderObject;
class ResourceRequest;
class ResourceResponse;
class TimelineTraceEventProcessor;
typedef String ErrorString;
......@@ -195,7 +194,6 @@ public:
private:
friend class TimelineRecordStack;
friend class TimelineTraceEventProcessor;
struct TimelineRecordEntry {
TimelineRecordEntry(PassRefPtr<InspectorObject> record, PassRefPtr<InspectorObject> data, PassRefPtr<InspectorArray> children, const String& type, size_t usedHeapSizeAtStart)
......@@ -261,7 +259,6 @@ private:
InspectorType m_inspectorType;
InspectorClient* m_client;
WeakPtrFactory<InspectorTimelineAgent> m_weakFactory;
RefPtr<TimelineTraceEventProcessor> m_traceEventProcessor;
};
} // namespace WebCore
......
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(INSPECTOR)
#include "TimelineTraceEventProcessor.h"
#include "InspectorClient.h"
#include "InspectorInstrumentation.h"
#include "TimelineRecordFactory.h"
#include <wtf/CurrentTime.h>
#include <wtf/MainThread.h>
#include <wtf/ThreadSpecific.h>
#include <wtf/Vector.h>
namespace WebCore {
namespace {
class TraceEventDispatcher {
WTF_MAKE_NONCOPYABLE(TraceEventDispatcher);
public:
static TraceEventDispatcher* instance()
{
DEFINE_STATIC_LOCAL(TraceEventDispatcher, instance, ());
return &instance;
}
void addProcessor(TimelineTraceEventProcessor* processor, InspectorClient* client)
{
MutexLocker locker(m_mutex);
m_processors.append(processor);
if (m_processors.size() == 1)
client->setTraceEventCallback(dispatchEventOnAnyThread);
}
void removeProcessor(TimelineTraceEventProcessor* processor, InspectorClient* client)
{
MutexLocker locker(m_mutex);
size_t index = m_processors.find(processor);
if (index == notFound) {
ASSERT_NOT_REACHED();
return;
}
m_processors.remove(index);
if (m_processors.isEmpty())
client->setTraceEventCallback(0);
}
private:
TraceEventDispatcher() { }
static void dispatchEventOnAnyThread(char phase, const unsigned char*, const char* name, unsigned long long id,
int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues,
unsigned char flags)
{
TraceEventDispatcher* self = instance();
Vector<RefPtr<TimelineTraceEventProcessor> > processors;
{
MutexLocker locker(self->m_mutex);
processors = self->m_processors;
}
for (int i = 0, size = processors.size(); i < size; ++i) {
processors[i]->processEventOnAnyThread(static_cast<TimelineTraceEventProcessor::TraceEventPhase>(phase),
name, id, numArgs, argNames, argTypes, argValues, flags);
}
}
Mutex m_mutex;
Vector<RefPtr<TimelineTraceEventProcessor> > m_processors;
};
} // namespce
TimelineRecordStack::TimelineRecordStack(WeakPtr<InspectorTimelineAgent> timelineAgent)
: m_timelineAgent(timelineAgent)
{
}
void TimelineRecordStack::addScopedRecord(PassRefPtr<InspectorObject> record)
{
m_stack.append(Entry(record));
}
void TimelineRecordStack::closeScopedRecord(double endTime)
{
if (m_stack.isEmpty())
return;
Entry last = m_stack.last();
m_stack.removeLast();
last.record->setNumber("endTime", endTime);
if (last.children->length())
last.record->setArray("children", last.children);
addInstantRecord(last.record);
}
void TimelineRecordStack::addInstantRecord(PassRefPtr<InspectorObject> record)
{
if (m_stack.isEmpty())
send(record);
else
m_stack.last().children->pushObject(record);
}
#ifndef NDEBUG
bool TimelineRecordStack::isOpenRecordOfType(const String& type)
{
String lastRecordType;
return m_stack.isEmpty() || (m_stack.last().record->getString("type", &lastRecordType) && type == lastRecordType);
}
#endif
void TimelineRecordStack::send(PassRefPtr<InspectorObject> record)
{
InspectorTimelineAgent* timelineAgent = m_timelineAgent.get();
if (!timelineAgent)
return;
timelineAgent->sendEvent(record);
}
TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimelineAgent> timelineAgent, InspectorClient *client)
: m_timelineAgent(timelineAgent)
, m_timeConverter(timelineAgent.get()->timeConverter())
, m_inspectorClient(client)
, m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page()))
, m_layerId(0)
{
registerHandler(InstrumentationEvents::BeginFrame, TracePhaseInstant, &TimelineTraceEventProcessor::onBeginFrame);
registerHandler(InstrumentationEvents::PaintLayer, TracePhaseBegin, &TimelineTraceEventProcessor::onPaintLayerBegin);
registerHandler(InstrumentationEvents::PaintLayer, TracePhaseEnd, &TimelineTraceEventProcessor::onPaintLayerEnd);
registerHandler(InstrumentationEvents::RasterTask, TracePhaseBegin, &TimelineTraceEventProcessor::onRasterTaskBegin);
registerHandler(InstrumentationEvents::RasterTask, TracePhaseEnd, &TimelineTraceEventProcessor::onRasterTaskEnd);
registerHandler(InstrumentationEvents::Layer, TracePhaseDeleteObject, &TimelineTraceEventProcessor::onLayerDeleted);
registerHandler(InstrumentationEvents::Paint, TracePhaseInstant, &TimelineTraceEventProcessor::onPaint);
registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseBegin, &TimelineTraceEventProcessor::onImageDecodeBegin);
registerHandler(PlatformInstrumentation::ImageDecodeEvent, TracePhaseEnd, &TimelineTraceEventProcessor::onImageDecodeEnd);
TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient);
}
TimelineTraceEventProcessor::~TimelineTraceEventProcessor()
{
}
void TimelineTraceEventProcessor::registerHandler(const char* name, TraceEventPhase phase, TraceEventHandler handler)
{
m_handlersByType.set(std::make_pair(name, phase), handler);
}
void TimelineTraceEventProcessor::shutdown()
{
TraceEventDispatcher::instance()->removeProcessor(this, m_inspectorClient);
}
size_t TimelineTraceEventProcessor::TraceEvent::findParameter(const char* name) const
{
for (int i = 0; i < m_argumentCount; ++i) {
if (!strcmp(name, m_argumentNames[i]))
return i;
}
return notFound;
}
const TimelineTraceEventProcessor::TraceValueUnion& TimelineTraceEventProcessor::TraceEvent::parameter(const char* name, TraceValueTypes expectedType) const
{
static TraceValueUnion missingValue;
size_t index = findParameter(name);
if (index == notFound || m_argumentTypes[index] != expectedType) {
ASSERT_NOT_REACHED();
return missingValue;
}
return *reinterpret_cast<const TraceValueUnion*>(m_argumentValues + index);
}
void TimelineTraceEventProcessor::processEventOnAnyThread(TraceEventPhase phase, const char* name, unsigned long long id,
int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues,
unsigned char)
{
HandlersMap::iterator it = m_handlersByType.find(std::make_pair(name, phase));
if (it == m_handlersByType.end())
return;
TraceEvent event(monotonicallyIncreasingTime(), phase, name, id, currentThread(), numArgs, argNames, argTypes, argValues);
if (!isMainThread()) {
MutexLocker locker(m_backgroundEventsMutex);
m_backgroundEvents.append(event);
return;
}
(this->*(it->value))(event);
}
void TimelineTraceEventProcessor::onBeginFrame(const TraceEvent&)
{
processBackgroundEvents();
}
void TimelineTraceEventProcessor::onPaintLayerBegin(const TraceEvent& event)
{
m_layerId = event.asUInt(InstrumentationEventArguments::LayerId);
ASSERT(m_layerId);
}
void TimelineTraceEventProcessor::onPaintLayerEnd(const TraceEvent&)
{
m_layerId = 0;
}
void TimelineTraceEventProcessor::onRasterTaskBegin(const TraceEvent& event)
{
unsigned long long layerId = event.asUInt(InstrumentationEventArguments::LayerId);
if (!m_knownLayers.contains(layerId))
return;
TimelineThreadState& state = threadState(event.threadIdentifier());
ASSERT(!state.inRasterizeEvent);
state.inRasterizeEvent = true;
RefPtr<InspectorObject> record = createRecord(event, TimelineRecordType::Rasterize);
state.recordStack.addScopedRecord(record.release());
}
void TimelineTraceEventProcessor::onRasterTaskEnd(const TraceEvent& event)
{
TimelineThreadState& state = threadState(event.threadIdentifier());
if (!state.inRasterizeEvent)
return;
ASSERT(state.recordStack.isOpenRecordOfType(TimelineRecordType::Rasterize));
state.recordStack.closeScopedRecord(m_timeConverter.fromMonotonicallyIncreasingTime(event.timestamp()));
state.inRasterizeEvent = false;
}
void TimelineTraceEventProcessor::onImageDecodeBegin(const TraceEvent& event)
{
TimelineThreadState& state = threadState(event.threadIdentifier());
if (!state.inRasterizeEvent)
return;
state.recordStack.addScopedRecord(createRecord(event, TimelineRecordType::DecodeImage));
}
void TimelineTraceEventProcessor::onImageDecodeEnd(const TraceEvent& event)
{
TimelineThreadState& state = threadState(event.threadIdentifier());
if (!state.inRasterizeEvent)
return;
ASSERT(state.recordStack.isOpenRecordOfType(TimelineRecordType::DecodeImage));
state.recordStack.closeScopedRecord(m_timeConverter.fromMonotonicallyIncreasingTime(event.timestamp()));
}
void TimelineTraceEventProcessor::onLayerDeleted(const TraceEvent& event)
{
unsigned long long id = event.id();
ASSERT(id);
processBackgroundEvents();
m_knownLayers.remove(id);
}
void TimelineTraceEventProcessor::onPaint(const TraceEvent& event)
{
if (!m_layerId)
return;
unsigned long long pageId = event.asUInt(InstrumentationEventArguments::PageId);
if (pageId == m_pageId)
m_knownLayers.add(m_layerId);
}
PassRefPtr<InspectorObject> TimelineTraceEventProcessor::createRecord(const TraceEvent& event, const String& recordType, PassRefPtr<InspectorObject> data)
{
double startTime = m_timeConverter.fromMonotonicallyIncreasingTime(event.timestamp());
RefPtr<InspectorObject> record = TimelineRecordFactory::createBackgroundRecord(startTime, String::number(event.threadIdentifier()));
record->setString("type", recordType);
record->setObject("data", data ? data : InspectorObject::create());
return record.release();
}
void TimelineTraceEventProcessor::processBackgroundEvents()
{
ASSERT(isMainThread());
Vector<TraceEvent> events;
{
MutexLocker locker(m_backgroundEventsMutex);
events.reserveCapacity(m_backgroundEvents.capacity());
m_backgroundEvents.swap(events);
}
for (size_t i = 0, size = events.size(); i < size; ++i) {
const TraceEvent& event = events[i];
HandlersMap::iterator it = m_handlersByType.find(std::make_pair(event.name(), event.phase()));
ASSERT(it != m_handlersByType.end() && it->value);
(this->*(it->value))(event);
}
}
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TimelineTraceEventProcessor_h
#define TimelineTraceEventProcessor_h
#if ENABLE(INSPECTOR)
#include "InspectorTimelineAgent.h"
#include "InspectorValues.h"