Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (144040 => 144041)
--- trunk/Source/WebCore/CMakeLists.txt 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/CMakeLists.txt 2013-02-26 12:52:33 UTC (rev 144041)
@@ -1655,6 +1655,7 @@
inspector/ScriptCallFrame.cpp
inspector/ScriptCallStack.cpp
inspector/TimelineRecordFactory.cpp
+ inspector/TimelineTraceEventProcessor.cpp
inspector/WorkerConsoleAgent.cpp
inspector/WorkerDebuggerAgent.cpp
inspector/WorkerInspectorController.cpp
Modified: trunk/Source/WebCore/ChangeLog (144040 => 144041)
--- trunk/Source/WebCore/ChangeLog 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/ChangeLog 2013-02-26 12:52:33 UTC (rev 144041)
@@ -1,5 +1,78 @@
2013-02-01 Andrey Kosyakov <ca...@chromium.org>
+ Web Inspector: plumb trace events to Timeline agent
+ https://bugs.webkit.org/show_bug.cgi?id=105796
+
+ Reviewed by Pavel Feldman.
+
+ - plumb trace events to Timeline;
+ - add TimelineTraceEventProcessor to process selected trace events;
+ - emit timeline events from TimelineTraceEventProcessor.
+
+ Note that actual event processing logic is a separate change.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * inspector/Inspector.json:
+ * inspector/InspectorAllInOne.cpp:
+ * inspector/InspectorClient.h:
+ (InspectorClient):
+ (WebCore::InspectorClient::setTraceEventCallback):
+ * inspector/InspectorTimelineAgent.cpp:
+ (WebCore::InspectorTimelineAgent::start):
+ (WebCore::InspectorTimelineAgent::stop):
+ (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+ (WebCore::InspectorTimelineAgent::appendBackgroundThreadRecord):
+ (WebCore):
+ (WebCore::InspectorTimelineAgent::page):
+ * inspector/InspectorTimelineAgent.h:
+ (WebCore):
+ (InspectorTimelineAgent):
+ * inspector/TimelineTraceEventProcessor.cpp: Added.
+ (WebCore::TimelineTraceEventProcessor::TimelineTraceEventProcessor):
+ (WebCore):
+ (WebCore::TimelineTraceEventProcessor::~TimelineTraceEventProcessor):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::parameter):
+ (WebCore::TimelineTraceEventProcessor::processEventOnAnyThread):
+ (WebCore::TimelineTraceEventProcessor::processEvent):
+ (WebCore::TimelineTraceEventProcessor::sendTimelineRecord):
+ (WebCore::TimelineTraceEventProcessor::processBackgroundEvents):
+ * inspector/TimelineTraceEventProcessor.h: Added.
+ (WebCore):
+ (TimelineTraceEventProcessor):
+ (TraceEvent):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::TraceEvent):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::timestamp):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::phase):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::name):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::threadIdentifier):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::argumentCount):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::asBool):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::asInt):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::asUInt):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::asDouble):
+ (WebCore::TimelineTraceEventProcessor::TraceEvent::asString):
+ (WebCore::TimelineTraceEventProcessor::EventTypeEntry::EventTypeEntry):
+ (EventTypeEntry):
+ * inspector/front-end/TimelineFrameController.js:
+ (WebInspector.TimelineFrameController.prototype._addRecord):
+ * inspector/front-end/TimelinePanel.js:
+ (WebInspector.TimelineRecordListRow.prototype.update):
+ (WebInspector.TimelineRecordGraphRow.prototype.update):
+ * inspector/front-end/TimelinePresentationModel.js:
+ (WebInspector.TimelinePresentationModel.Record):
+ (WebInspector.TimelinePresentationModel.insertRetrospecitveRecord):
+ (WebInspector.TimelinePresentationModel.Record.prototype.get isBackground):
+ * inspector/front-end/timelinePanel.css:
+ (.timeline-tree-item.background .timeline-tree-icon):
+ (.timeline-graph-side.background .timeline-graph-bar):
+
+2013-02-01 Andrey Kosyakov <ca...@chromium.org>
+
Web Inspector: display background events on Timeline
https://bugs.webkit.org/show_bug.cgi?id=108599
Modified: trunk/Source/WebCore/GNUmakefile.list.am (144040 => 144041)
--- trunk/Source/WebCore/GNUmakefile.list.am 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2013-02-26 12:52:33 UTC (rev 144041)
@@ -3907,6 +3907,8 @@
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 \
Modified: trunk/Source/WebCore/Target.pri (144040 => 144041)
--- trunk/Source/WebCore/Target.pri 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/Target.pri 2013-02-26 12:52:33 UTC (rev 144041)
@@ -828,6 +828,7 @@
inspector/ScriptCallFrame.cpp \
inspector/ScriptCallStack.cpp \
inspector/TimelineRecordFactory.cpp \
+ inspector/TimelineTraceEventProcessor.cpp \
inspector/WorkerConsoleAgent.cpp \
inspector/WorkerDebuggerAgent.cpp \
inspector/WorkerInspectorController.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (144040 => 144041)
--- trunk/Source/WebCore/WebCore.gypi 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/WebCore.gypi 2013-02-26 12:52:33 UTC (rev 144041)
@@ -1936,6 +1936,8 @@
'inspector/ScriptGCEventListener.h',
'inspector/TimelineRecordFactory.cpp',
'inspector/TimelineRecordFactory.h',
+ 'inspector/TimelineTraceEventProcessor.cpp',
+ 'inspector/TimelineTraceEventProcessor.h',
'inspector/WorkerConsoleAgent.cpp',
'inspector/WorkerConsoleAgent.h',
'inspector/WorkerDebuggerAgent.cpp',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (144040 => 144041)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2013-02-26 12:52:33 UTC (rev 144041)
@@ -76854,6 +76854,30 @@
RelativePath="..\inspector\TimelineRecordFactory.h"
>
</File>
+ <File
+ RelativePath="..\inspector\TimelineTraceEventProcessor.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\inspector\TimelineTraceEventProcessor.h"
+ >
+ </File>
<File
RelativePath="..\inspector\WorkerConsoleAgent.cpp"
>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (144040 => 144041)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-02-26 12:52:33 UTC (rev 144041)
@@ -1283,6 +1283,8 @@
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 */; };
492863991253B8FC00F792D6 /* ResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 492863981253B8FC00F792D6 /* ResourceLoadInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8695,6 +8697,8 @@
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>"; };
492863981253B8FC00F792D6 /* ResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadInfo.h; sourceTree = "<group>"; };
@@ -15342,6 +15346,8 @@
9FA37EF01172FD4100C4CD55 /* ScriptProfileNode.idl */,
7553CFE7108F473F00EA281E /* TimelineRecordFactory.cpp */,
7553CFE6108F473F00EA281E /* TimelineRecordFactory.h */,
+ 49140254168E02B4002D6C6A /* TimelineTraceEventProcessor.cpp */,
+ 49140255168E02B4002D6C6A /* TimelineTraceEventProcessor.h */,
F382088E147D35F90010BC06 /* WorkerConsoleAgent.cpp */,
F382088F147D35F90010BC06 /* WorkerConsoleAgent.h */,
F34742DE1343631F00531BC2 /* WorkerDebuggerAgent.cpp */,
@@ -26615,6 +26621,7 @@
977E2E0F12F0FC9C00C13380 /* XSSAuditorDelegate.h in Headers */,
FD537353137B651800008DCE /* ZeroPole.h in Headers */,
41B8CD4616D04591000E8CC0 /* SelectorCheckerFastPath.h in Headers */,
+ 49140257168E02EC002D6C6A /* TimelineTraceEventProcessor.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -29809,6 +29816,7 @@
977E2E0E12F0FC9C00C13380 /* XSSAuditorDelegate.cpp in Sources */,
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
41B8CD4516D04591000E8CC0 /* SelectorCheckerFastPath.cpp in Sources */,
+ 49140256168E02E8002D6C6A /* TimelineTraceEventProcessor.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/inspector/InspectorAllInOne.cpp (144040 => 144041)
--- trunk/Source/WebCore/inspector/InspectorAllInOne.cpp 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/inspector/InspectorAllInOne.cpp 2013-02-26 12:52:33 UTC (rev 144041)
@@ -83,6 +83,7 @@
#include "ScriptCallFrame.cpp"
#include "ScriptCallStack.cpp"
#include "TimelineRecordFactory.cpp"
+#include "TimelineTraceEventProcessor.cpp"
#include "WorkerConsoleAgent.cpp"
#include "WorkerDebuggerAgent.cpp"
#include "WorkerInspectorController.cpp"
Modified: trunk/Source/WebCore/inspector/InspectorClient.h (144040 => 144041)
--- trunk/Source/WebCore/inspector/InspectorClient.h 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/inspector/InspectorClient.h 2013-02-26 12:52:33 UTC (rev 144041)
@@ -59,6 +59,11 @@
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*/)
Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (144040 => 144041)
--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp 2013-02-26 12:52:33 UTC (rev 144041)
@@ -1,5 +1,5 @@
/*
-* Copyright (C) 2009 Google Inc. All rights reserved.
+* 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
@@ -53,6 +53,7 @@
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "TimelineRecordFactory.h"
+#include "TimelineTraceEventProcessor.h"
#include <wtf/CurrentTime.h>
@@ -179,6 +180,8 @@
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*)
@@ -186,6 +189,8 @@
if (!m_state->getBoolean(TimelineAgentState::timelineAgentEnabled))
return;
+ m_traceEventProcessor.clear();
+ m_weakFactory.revokeAll();
m_instrumentingAgents->setInspectorTimelineAgent(0);
ScriptGCEvent::removeEventListener(this);
@@ -635,6 +640,7 @@
, m_platformInstrumentationClientInstalledAtStackDepth(0)
, m_inspectorType(type)
, m_client(client)
+ , m_weakFactory(this)
{
}
@@ -706,6 +712,11 @@
return (microseconds + m_timestampOffset) * 1000.0;
}
+Page* InspectorTimelineAgent::page()
+{
+ return m_pageAgent ? m_pageAgent->page() : 0;
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.h (144040 => 144041)
--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.h 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.h 2013-02-26 12:52:33 UTC (rev 144041)
@@ -42,6 +42,7 @@
#include "ScriptGCEventListener.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
namespace WebCore {
class Event;
@@ -54,9 +55,11 @@
class InstrumentingAgents;
class IntRect;
class KURL;
+class Page;
class RenderObject;
class ResourceRequest;
class ResourceResponse;
+class TimelineTraceEventProcessor;
typedef String ErrorString;
@@ -176,6 +179,8 @@
virtual void didResizeImage() OVERRIDE;
private:
+ friend class TimelineTraceEventProcessor;
+
struct TimelineRecordEntry {
TimelineRecordEntry(PassRefPtr<InspectorObject> record, PassRefPtr<InspectorObject> data, PassRefPtr<InspectorArray> children, const String& type, const String& frameId, size_t usedHeapSizeAtStart)
: record(record), data(data), children(children), type(type), frameId(frameId), usedHeapSizeAtStart(usedHeapSizeAtStart)
@@ -213,6 +218,7 @@
double timestamp();
double timestampFromMicroseconds(double microseconds);
+ Page* page();
InspectorPageAgent* m_pageAgent;
InspectorMemoryAgent* m_memoryAgent;
@@ -239,6 +245,8 @@
RefPtr<InspectorObject> m_pendingFrameRecord;
InspectorType m_inspectorType;
InspectorClient* m_client;
+ WeakPtrFactory<InspectorTimelineAgent> m_weakFactory;
+ RefPtr<TimelineTraceEventProcessor> m_traceEventProcessor;
};
} // namespace WebCore
Added: trunk/Source/WebCore/inspector/TimelineTraceEventProcessor.cpp (0 => 144041)
--- trunk/Source/WebCore/inspector/TimelineTraceEventProcessor.cpp (rev 0)
+++ trunk/Source/WebCore/inspector/TimelineTraceEventProcessor.cpp 2013-02-26 12:52:33 UTC (rev 144041)
@@ -0,0 +1,204 @@
+/*
+* 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 "InspectorTimelineAgent.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[index] = m_processors.last();
+ m_processors.removeLast();
+ 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
+TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimelineAgent> timelineAgent, InspectorClient *client)
+ : m_timelineAgent(timelineAgent)
+ , m_inspectorClient(client)
+ , m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page()))
+{
+ TraceEventDispatcher::instance()->addProcessor(this, m_inspectorClient);
+}
+
+TimelineTraceEventProcessor::~TimelineTraceEventProcessor()
+{
+ TraceEventDispatcher::instance()->removeProcessor(this, m_inspectorClient);
+}
+
+const TimelineTraceEventProcessor::TraceValueUnion& TimelineTraceEventProcessor::TraceEvent::parameter(const char* name, TraceValueTypes expectedType) const
+{
+ static TraceValueUnion missingValue;
+
+ for (int i = 0; i < m_argumentCount; ++i) {
+ if (!strcmp(name, m_argumentNames[i])) {
+ if (m_argumentTypes[i] != expectedType) {
+ ASSERT_NOT_REACHED();
+ return missingValue;
+ }
+ return *reinterpret_cast<const TraceValueUnion*>(m_argumentValues + i);
+ }
+ }
+ ASSERT_NOT_REACHED();
+ return missingValue;
+}
+
+void TimelineTraceEventProcessor::processEventOnAnyThread(TraceEventPhase phase, const char* name, unsigned long long,
+ int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues,
+ unsigned char)
+{
+ HashMap<String, EventTypeEntry>::iterator it = m_handlersByType.find(name);
+ if (it == m_handlersByType.end())
+ return;
+
+ TraceEvent event(WTF::monotonicallyIncreasingTime(), phase, name, currentThread(), numArgs, argNames, argTypes, argValues);
+
+ if (!isMainThread()) {
+ MutexLocker locker(m_backgroundEventsMutex);
+ m_backgroundEvents.append(event);
+ return;
+ }
+
+ processEvent(it->value, event);
+}
+
+void TimelineTraceEventProcessor::processEvent(const EventTypeEntry& eventTypeEntry, const TraceEvent& event)
+{
+ TraceEventHandler handler = 0;
+ switch (event.phase()) {
+ case TracePhaseBegin:
+ handler = eventTypeEntry.m_begin;
+ break;
+ case TracePhaseEnd:
+ handler = eventTypeEntry.m_end;
+ break;
+ case TracePhaseInstant:
+ handler = eventTypeEntry.m_instant;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ if (!handler) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+ (this->*handler)(event);
+}
+
+void TimelineTraceEventProcessor::sendTimelineRecord(PassRefPtr<InspectorObject> data, const String& recordType, double startTime, double endTime, const String& thread)
+{
+ InspectorTimelineAgent* timelineAgent = m_timelineAgent.get();
+ if (!timelineAgent)
+ return;
+ timelineAgent->appendBackgroundThreadRecord(data, recordType, startTime, endTime, thread);
+}
+
+void TimelineTraceEventProcessor::processBackgroundEvents()
+{
+ 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];
+ processEvent(m_handlersByType.find(event.name())->value, event);
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
Added: trunk/Source/WebCore/inspector/TimelineTraceEventProcessor.h (0 => 144041)
--- trunk/Source/WebCore/inspector/TimelineTraceEventProcessor.h (rev 0)
+++ trunk/Source/WebCore/inspector/TimelineTraceEventProcessor.h 2013-02-26 12:52:33 UTC (rev 144041)
@@ -0,0 +1,193 @@
+/*
+* Copyright (C) 2012 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 "InspectorValues.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Threading.h>
+#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class InspectorClient;
+class InspectorTimelineAgent;
+class Page;
+
+class TimelineTraceEventProcessor : public ThreadSafeRefCounted<TimelineTraceEventProcessor> {
+public:
+ // FIXME: re-use definitions in TraceEvent.h once it's promoted to all platforms.
+ enum TraceEventPhase {
+ TracePhaseBegin = 'B',
+ TracePhaseEnd = 'E',
+ TracePhaseInstant = 'I'
+ };
+
+ TimelineTraceEventProcessor(WeakPtr<InspectorTimelineAgent>, InspectorClient*);
+ ~TimelineTraceEventProcessor();
+
+ void processEventOnAnyThread(TraceEventPhase, 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);
+
+private:
+ // FIXME: use the definition in TraceEvent.h once we expose the latter to all plaforms.
+ union TraceValueUnion {
+ bool m_bool;
+ unsigned long long m_uint;
+ long long m_int;
+ double m_double;
+ const void* m_pointer;
+ const char* m_string;
+ };
+
+ enum TraceValueTypes {
+ TypeBool = 1,
+ TypeUInt = 2,
+ TypeInt = 3,
+ TypeDouble = 4,
+ TypePointer = 5,
+ TypeString = 6,
+ TypeCopyString = 7
+ };
+
+ class TraceEvent {
+ public:
+ TraceEvent()
+ : m_argumentCount(0)
+ {
+ }
+
+ TraceEvent(double timestamp, TraceEventPhase phase, const char* name, ThreadIdentifier threadIdentifier,
+ int argumentCount, const char* const* argumentNames, const unsigned char* argumentTypes, const unsigned long long* argumentValues)
+ : m_timestamp(timestamp)
+ , m_phase(phase)
+ , m_name(name)
+ , m_threadIdentifier(threadIdentifier)
+ , m_argumentCount(argumentCount)
+ , m_argumentNames(argumentNames)
+ , m_argumentTypes(argumentTypes)
+ , m_argumentValues(argumentValues)
+ {
+ }
+
+ double timestamp() const { return m_timestamp; }
+ TraceEventPhase phase() const { return m_phase; }
+ const char* name() const { return m_name; }
+ ThreadIdentifier threadIdentifier() const { return m_threadIdentifier; }
+ int argumentCount() const { return m_argumentCount; }
+
+ bool asBool(const char* name) const
+ {
+ return parameter(name, TypeBool).m_bool;
+ }
+ long long asInt(const char* name) const
+ {
+ return parameter(name, TypeInt).m_int;
+ }
+ unsigned long long asUInt(const char* name) const
+ {
+ return parameter(name, TypeUInt).m_uint;
+ }
+ double asDouble(const char* name) const
+ {
+ return parameter(name, TypeDouble).m_double;
+ }
+ const char* asString(const char* name) const
+ {
+ return parameter(name, TypeString).m_string;
+ }
+
+ private:
+ const TraceValueUnion& parameter(const char* name, TraceValueTypes expectedType) const;
+
+ double m_timestamp;
+ TraceEventPhase m_phase;
+ const char* m_name;
+ ThreadIdentifier m_threadIdentifier;
+ int m_argumentCount;
+ const char* const* m_argumentNames;
+ const unsigned char* m_argumentTypes;
+ const unsigned long long* m_argumentValues;
+ };
+
+ typedef void (TimelineTraceEventProcessor::*TraceEventHandler)(const TraceEvent&);
+
+ struct EventTypeEntry {
+ EventTypeEntry()
+ : m_begin(0)
+ , m_end(0)
+ , m_instant(0)
+ {
+ }
+ explicit EventTypeEntry(TraceEventHandler instant)
+ : m_begin(0)
+ , m_end(0)
+ , m_instant(instant)
+ {
+ }
+ EventTypeEntry(TraceEventHandler begin, TraceEventHandler end)
+ : m_begin(begin)
+ , m_end(end)
+ , m_instant(0)
+ {
+ }
+
+ TraceEventHandler m_begin;
+ TraceEventHandler m_end;
+ TraceEventHandler m_instant;
+ };
+
+ void processBackgroundEvents();
+ void sendTimelineRecord(PassRefPtr<InspectorObject> data, const String& recordType, double startTime, double endTime, const String& thread);
+ void processEvent(const EventTypeEntry&, const TraceEvent&);
+
+ WeakPtr<InspectorTimelineAgent> m_timelineAgent;
+ InspectorClient* m_inspectorClient;
+
+ HashMap<String, EventTypeEntry> m_handlersByType;
+ Mutex m_backgroundEventsMutex;
+ Vector<TraceEvent> m_backgroundEvents;
+ unsigned long long m_pageId;
+};
+
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
+#endif // !defined(TimelineTraceEventProcessor_h)
Modified: trunk/Source/WebKit/chromium/ChangeLog (144040 => 144041)
--- trunk/Source/WebKit/chromium/ChangeLog 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebKit/chromium/ChangeLog 2013-02-26 12:52:33 UTC (rev 144041)
@@ -1,3 +1,26 @@
+2013-02-01 Andrey Kosyakov <ca...@chromium.org>
+
+ Web Inspector: plumb trace events to Timeline agent
+ https://bugs.webkit.org/show_bug.cgi?id=105796
+
+ Reviewed by Pavel Feldman.
+
+ Plumb trace events to Inspector.
+
+ * public/WebDevToolsAgentClient.h:
+ (WebDevToolsAgentClient):
+ (WebKit::WebDevToolsAgentClient::setTraceEventCallback):
+ * src/InspectorClientImpl.cpp:
+ (WebKit::InspectorClientImpl::setTraceEventCallback):
+ (WebKit):
+ * src/InspectorClientImpl.h:
+ (InspectorClientImpl):
+ * src/WebDevToolsAgentImpl.cpp:
+ (WebKit::WebDevToolsAgentImpl::setTraceEventCallback):
+ (WebKit):
+ * src/WebDevToolsAgentImpl.h:
+ (WebDevToolsAgentImpl):
+
2013-02-26 Tien-Ren Chen <trc...@chromium.org>
Implement coordinated scrollbar for subframes and overflow:scroll
Modified: trunk/Source/WebKit/chromium/public/WebDevToolsAgentClient.h (144040 => 144041)
--- trunk/Source/WebKit/chromium/public/WebDevToolsAgentClient.h 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebKit/chromium/public/WebDevToolsAgentClient.h 2013-02-26 12:52:33 UTC (rev 144041)
@@ -77,6 +77,12 @@
};
virtual void dumpUncountedAllocatedObjects(const InstrumentedObjectSizeProvider*) { }
+ 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) { }
+
protected:
~WebDevToolsAgentClient() { }
};
Modified: trunk/Source/WebKit/chromium/src/InspectorClientImpl.cpp (144040 => 144041)
--- trunk/Source/WebKit/chromium/src/InspectorClientImpl.cpp 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebKit/chromium/src/InspectorClientImpl.cpp 2013-02-26 12:52:33 UTC (rev 144041)
@@ -233,6 +233,12 @@
return true;
}
+void InspectorClientImpl::setTraceEventCallback(TraceEventCallback callback)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->setTraceEventCallback(callback);
+}
+
WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
{
return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());
Modified: trunk/Source/WebKit/chromium/src/InspectorClientImpl.h (144040 => 144041)
--- trunk/Source/WebKit/chromium/src/InspectorClientImpl.h 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebKit/chromium/src/InspectorClientImpl.h 2013-02-26 12:52:33 UTC (rev 144041)
@@ -91,6 +91,7 @@
virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&);
virtual bool captureScreenshot(WTF::String* data);
+ virtual void setTraceEventCallback(TraceEventCallback);
virtual bool handleJavaScriptDialog(bool accept);
Modified: trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp (144040 => 144041)
--- trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp 2013-02-26 12:52:33 UTC (rev 144041)
@@ -612,6 +612,11 @@
return true;
}
+void WebDevToolsAgentImpl::setTraceEventCallback(TraceEventCallback callback)
+{
+ m_client->setTraceEventCallback(callback);
+}
+
void WebDevToolsAgentImpl::dispatchOnInspectorBackend(const WebString& message)
{
inspectorController()->dispatchMessageFromFrontend(message);
Modified: trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h (144040 => 144041)
--- trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h 2013-02-26 12:52:32 UTC (rev 144040)
+++ trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h 2013-02-26 12:52:33 UTC (rev 144041)
@@ -114,6 +114,7 @@
virtual void getAllocatedObjects(HashSet<const void*>&);
virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&);
+ virtual void setTraceEventCallback(TraceEventCallback);
virtual bool captureScreenshot(WTF::String* data);