WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-105796-20130204202546.patch (text/plain), 36.20 KB, created by
Andrey Kosyakov
on 2013-02-04 08:29:07 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andrey Kosyakov
Created:
2013-02-04 08:29:07 PST
Size:
36.20 KB
patch
obsolete
>Subversion Revision: 141765 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 551b66ee1bb639add9177a62e9d9217b2062816b..65752afdda333411d4bc87374ba285af0efab28a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,62 @@ >+2013-02-04 Andrey Kosyakov <caseq@chromium.org> >+ >+ Web Inspector: plumb trace events to Timeline agent >+ https://bugs.webkit.org/show_bug.cgi?id=105796 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ - 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/InspectorAllInOne.cpp: >+ * inspector/InspectorClient.h: >+ (InspectorClient): >+ (WebCore::InspectorClient::setTraceEventCallback): >+ * inspector/InspectorTimelineAgent.cpp: >+ (WebCore::InspectorTimelineAgent::start): >+ (WebCore::InspectorTimelineAgent::stop): >+ (WebCore::InspectorTimelineAgent::InspectorTimelineAgent): >+ (WebCore::InspectorTimelineAgent::page): >+ (WebCore): >+ * 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): >+ > 2013-02-04 Eugene Klyuchnikov <eustas@chromium.org> > > Web Inspector: [Network] Minor refactorings. >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index cbfea16e07288cea783c3284e123d562b347f565..7822318bc3fcc12cb71e51a9f4a955674da28ef1 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,26 @@ >+2013-02-04 Andrey Kosyakov <caseq@chromium.org> >+ >+ Web Inspector: plumb trace events to Timeline agent >+ https://bugs.webkit.org/show_bug.cgi?id=105796 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-03 KwangYong Choi <ky0.choi@samsung.com> > > Fix build warning after r141473 >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index bd233b9f1e398f03697a033237551d79c15bb8e7..05145d1bd9dd4a93a913697cd1faf334686fc8a6 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1655,6 +1655,7 @@ set(WebCore_SOURCES > inspector/ScriptCallFrame.cpp > inspector/ScriptCallStack.cpp > inspector/TimelineRecordFactory.cpp >+ inspector/TimelineTraceEventProcessor.cpp > inspector/WorkerConsoleAgent.cpp > inspector/WorkerDebuggerAgent.cpp > inspector/WorkerInspectorController.cpp >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 17316550562b72563e0eb42f12d428edd9ab5d0b..0cef788076f2af530c2b138f17e5a59359de9165 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -3867,6 +3867,8 @@ 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 \ >diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index e8f6fc162d39945c441b0e6c429930dcad7d0b65..87371331d5ffe77b3270ebed82ab4029e37cab8b 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -813,6 +813,7 @@ SOURCES += \ > inspector/ScriptCallFrame.cpp \ > inspector/ScriptCallStack.cpp \ > inspector/TimelineRecordFactory.cpp \ >+ inspector/TimelineTraceEventProcessor.cpp \ > inspector/WorkerConsoleAgent.cpp \ > inspector/WorkerDebuggerAgent.cpp \ > inspector/WorkerInspectorController.cpp \ >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index dcbb3555220d7bb40b157e00708d7643821445a7..be715c2577a3a8d30d58d91aeb0b040281248540 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -1913,6 +1913,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', >diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >index 74aac951e0f3b686406fe35e6b9c84a9962ca0a8..86bc9d30a9fd64ab90cbdab4967cbcc05e17680c 100755 >--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj >+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >@@ -76654,6 +76654,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" > > >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 9b208d2819a8b6f9ba5de99708b359e037b2cadb..e3f0ae4b0ce5d31e86e00cecfb6205629d0ba83f 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1275,6 +1275,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, ); }; }; >@@ -8623,6 +8625,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>"; }; >@@ -15193,6 +15197,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 */, >@@ -26339,6 +26345,7 @@ > 977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */, > 977E2E0F12F0FC9C00C13380 /* XSSAuditorDelegate.h in Headers */, > FD537353137B651800008DCE /* ZeroPole.h in Headers */, >+ 49140257168E02EC002D6C6A /* TimelineTraceEventProcessor.h in Headers */, > ); > runOnlyForDeploymentPostprocessing = 0; > }; >@@ -29497,6 +29504,7 @@ > 977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */, > 977E2E0E12F0FC9C00C13380 /* XSSAuditorDelegate.cpp in Sources */, > FD537352137B651800008DCE /* ZeroPole.cpp in Sources */, >+ 49140256168E02E8002D6C6A /* TimelineTraceEventProcessor.cpp in Sources */, > ); > runOnlyForDeploymentPostprocessing = 0; > }; >diff --git a/Source/WebCore/inspector/InspectorAllInOne.cpp b/Source/WebCore/inspector/InspectorAllInOne.cpp >index 9c9ff20859c2d8cb856347d67b81131a7bb89ebf..b113dd9ed2f26d7cd84264f12d544d43ad35477e 100644 >--- a/Source/WebCore/inspector/InspectorAllInOne.cpp >+++ b/Source/WebCore/inspector/InspectorAllInOne.cpp >@@ -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" >diff --git a/Source/WebCore/inspector/InspectorClient.h b/Source/WebCore/inspector/InspectorClient.h >index b9f8f5612f47d5963afab82dc79eff7fbf34c5bf..3c97129ad31c69c549ecddc1b8f6fcf1ede97485 100644 >--- a/Source/WebCore/inspector/InspectorClient.h >+++ b/Source/WebCore/inspector/InspectorClient.h >@@ -59,6 +59,11 @@ 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*/) >diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.cpp b/Source/WebCore/inspector/InspectorTimelineAgent.cpp >index ac7adcb0aa356fe770cdffc3039692566578a257..8c067c5d9edeb68b36e883d7b95191a7bb25ab33 100644 >--- a/Source/WebCore/inspector/InspectorTimelineAgent.cpp >+++ b/Source/WebCore/inspector/InspectorTimelineAgent.cpp >@@ -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 >@@ -51,6 +51,7 @@ > #include "ResourceRequest.h" > #include "ResourceResponse.h" > #include "TimelineRecordFactory.h" >+#include "TimelineTraceEventProcessor.h" > > #include <wtf/CurrentTime.h> > >@@ -171,6 +172,9 @@ void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth) > m_instrumentingAgents->setInspectorTimelineAgent(this); > ScriptGCEvent::addEventListener(this); > m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, true); >+ // The below would be false for workers. >+ if (m_client && m_pageAgent) >+ m_traceEventProcessor = adoptRef(new TimelineTraceEventProcessor(m_weakFactory.createWeakPtr(), m_client)); > } > > void InspectorTimelineAgent::stop(ErrorString*) >@@ -178,6 +182,8 @@ void InspectorTimelineAgent::stop(ErrorString*) > if (!m_state->getBoolean(TimelineAgentState::timelineAgentEnabled)) > return; > >+ m_traceEventProcessor.clear(); >+ m_weakFactory.revokeAll(); > m_instrumentingAgents->setInspectorTimelineAgent(0); > ScriptGCEvent::removeEventListener(this); > >@@ -564,6 +570,7 @@ InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentin > , m_platformInstrumentationClientInstalledAtStackDepth(0) > , m_inspectorType(type) > , m_client(client) >+ , m_weakFactory(this) > { > } > >@@ -624,6 +631,11 @@ double InspectorTimelineAgent::timestampFromMicroseconds(double microseconds) > return (microseconds + m_timestampOffset) * 1000.0; > } > >+Page* InspectorTimelineAgent::page() >+{ >+ return m_pageAgent ? m_pageAgent->page() : 0; >+} >+ > } // namespace WebCore > > #endif // ENABLE(INSPECTOR) >diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.h b/Source/WebCore/inspector/InspectorTimelineAgent.h >index e7062a118188facdd5434a1211d3c7fc5f06e966..75f02437c0cfd33d4eb736eb647039e08b32c187 100644 >--- a/Source/WebCore/inspector/InspectorTimelineAgent.h >+++ b/Source/WebCore/inspector/InspectorTimelineAgent.h >@@ -42,6 +42,7 @@ > #include "ScriptGCEventListener.h" > #include <wtf/PassOwnPtr.h> > #include <wtf/Vector.h> >+#include <wtf/WeakPtr.h> > > namespace WebCore { > class Event; >@@ -52,9 +53,11 @@ class InspectorPageAgent; > class InspectorState; > class InstrumentingAgents; > class IntRect; >+class Page; > class RenderObject; > class ResourceRequest; > class ResourceResponse; >+class TimelineTraceEventProcessor; > > typedef String ErrorString; > >@@ -166,6 +169,8 @@ public: > 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) >@@ -195,6 +200,7 @@ private: > > double timestamp(); > double timestampFromMicroseconds(double microseconds); >+ Page* page(); > > InspectorPageAgent* m_pageAgent; > >@@ -220,6 +226,8 @@ private: > RefPtr<InspectorObject> m_pendingFrameRecord; > InspectorType m_inspectorType; > InspectorClient* m_client; >+ WeakPtrFactory<InspectorTimelineAgent> m_weakFactory; >+ RefPtr<TimelineTraceEventProcessor> m_traceEventProcessor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/inspector/TimelineTraceEventProcessor.cpp b/Source/WebCore/inspector/TimelineTraceEventProcessor.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f9175d99ba332beb219c96be27646c45aa0b65ed >--- /dev/null >+++ b/Source/WebCore/inspector/TimelineTraceEventProcessor.cpp >@@ -0,0 +1,211 @@ >+/* >+* 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.remove(index); >+ if (m_processors.isEmpty()) >+ client->setTraceEventCallback(0); >+ } >+ >+private: >+ enum { ProcessorsVectorInlineCapacity = 2 }; >+ >+ 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>, ProcessorsVectorInlineCapacity> 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>, ProcessorsVectorInlineCapacity> 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 >+{ >+ 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) >+{ >+ ASSERT(isMainThread()); >+ >+ 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) >+{ >+ ASSERT(isMainThread()); >+ >+ InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); >+ if (!timelineAgent) >+ return; >+ timelineAgent->appendBackgroundThreadRecord(data, recordType, startTime, endTime, thread); >+} >+ >+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]; >+ processEvent(m_handlersByType.find(event.name())->value, event); >+ } >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(INSPECTOR) >diff --git a/Source/WebCore/inspector/TimelineTraceEventProcessor.h b/Source/WebCore/inspector/TimelineTraceEventProcessor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..2c555c11241a22a4adbd67ea326842ad58a013e4 >--- /dev/null >+++ b/Source/WebCore/inspector/TimelineTraceEventProcessor.h >@@ -0,0 +1,195 @@ >+/* >+* 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 "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 { >+ unsigned long long m_uint; >+ long long m_int; >+ double m_double; >+ bool m_bool; >+ const void* m_pointer; >+ const char* m_string; >+ >+ TraceValueUnion() { } >+ }; >+ >+ 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) >diff --git a/Source/WebKit/chromium/public/WebDevToolsAgentClient.h b/Source/WebKit/chromium/public/WebDevToolsAgentClient.h >index a1f6a6da4e3adf77e55ea10dcc0875e5c4fcc61b..f6d30858c3c04d48114e87b2a484835d1f8b212f 100644 >--- a/Source/WebKit/chromium/public/WebDevToolsAgentClient.h >+++ b/Source/WebKit/chromium/public/WebDevToolsAgentClient.h >@@ -77,6 +77,12 @@ public: > }; > 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() { } > }; >diff --git a/Source/WebKit/chromium/src/InspectorClientImpl.cpp b/Source/WebKit/chromium/src/InspectorClientImpl.cpp >index e94df9a7b18f498ebf38ba1820eeb863c9259cfe..22506f3576f8419532ef096771d6a60fdbb48c1e 100644 >--- a/Source/WebKit/chromium/src/InspectorClientImpl.cpp >+++ b/Source/WebKit/chromium/src/InspectorClientImpl.cpp >@@ -218,6 +218,12 @@ bool InspectorClientImpl::handleJavaScriptDialog(bool accept) > return false; > } > >+void InspectorClientImpl::setTraceEventCallback(TraceEventCallback callback) >+{ >+ if (WebDevToolsAgentImpl* agent = devToolsAgent()) >+ agent->setTraceEventCallback(callback); >+} >+ > WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent() > { > return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent()); >diff --git a/Source/WebKit/chromium/src/InspectorClientImpl.h b/Source/WebKit/chromium/src/InspectorClientImpl.h >index d173fca27e052b834412f84c85265e518630f38d..7dcde4eb16b51f338fc90e3a9c7b7e3d97adf263 100644 >--- a/Source/WebKit/chromium/src/InspectorClientImpl.h >+++ b/Source/WebKit/chromium/src/InspectorClientImpl.h >@@ -88,6 +88,7 @@ public: > virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&); > > virtual bool captureScreenshot(WTF::String* data); >+ virtual void setTraceEventCallback(TraceEventCallback); > > virtual bool handleJavaScriptDialog(bool accept); > >diff --git a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp >index 4ea460a10b60891ca5eeecdaa8f373559ce818b3..9fe1ccf921e8346853df32e804c5aba13fc433f6 100644 >--- a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp >+++ b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp >@@ -591,6 +591,11 @@ bool WebDevToolsAgentImpl::handleJavaScriptDialog(bool accept) > return true; > } > >+void WebDevToolsAgentImpl::setTraceEventCallback(TraceEventCallback callback) >+{ >+ m_client->setTraceEventCallback(callback); >+} >+ > void WebDevToolsAgentImpl::dispatchOnInspectorBackend(const WebString& message) > { > inspectorController()->dispatchMessageFromFrontend(message); >diff --git a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h >index 5e8f24594c4bc442fdef2dd30239137ca24fbbfd..509191fe981c09f519e7637f81e6b806a15b1d55 100644 >--- a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h >+++ b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h >@@ -110,6 +110,7 @@ public: > > 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); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 105796
:
180791
|
180876
|
180881
|
180922
|
180932
|
186000
|
186015
|
186381
|
186384
|
186389
|
190277