Web Inspector: [Canvas] remove invalid canvas profile trace logs upon frame navigation
authoraandrey@chromium.org <aandrey@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 12:45:12 +0000 (12:45 +0000)
committeraandrey@chromium.org <aandrey@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 12:45:12 +0000 (12:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108454

Reviewed by Pavel Feldman.

Source/WebCore:

When canvas profile trace logs stored in the backend get destroyed (for example, on frame navigation), send an event to frontend and update the UI.
Drive-by: replace String types to corresponding TypeBuilder::Canvas::* typedefs.
* inspector/InjectedScriptCanvasModule.cpp:
(WebCore::InjectedScriptCanvasModule::captureFrame):
(WebCore::InjectedScriptCanvasModule::startCapturing):
(WebCore::InjectedScriptCanvasModule::callStartCapturingFunction):
(WebCore::InjectedScriptCanvasModule::stopCapturing):
(WebCore::InjectedScriptCanvasModule::dropTraceLog):
(WebCore::InjectedScriptCanvasModule::callVoidFunctionWithTraceLogIdArgument):
(WebCore::InjectedScriptCanvasModule::traceLog):
(WebCore::InjectedScriptCanvasModule::replayTraceLog):
(WebCore::InjectedScriptCanvasModule::resourceInfo):
(WebCore::InjectedScriptCanvasModule::resourceState):
* inspector/InjectedScriptCanvasModule.h:
(InjectedScriptCanvasModule):
* inspector/Inspector.json:
* inspector/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::dropTraceLog):
(WebCore::InspectorCanvasAgent::stopCapturing):
(WebCore::InspectorCanvasAgent::getTraceLog):
(WebCore::InspectorCanvasAgent::replayTraceLog):
(WebCore::InspectorCanvasAgent::getResourceInfo):
(WebCore::InspectorCanvasAgent::getResourceState):
(WebCore::InspectorCanvasAgent::frameNavigated):
* inspector/InspectorCanvasAgent.h:
(InspectorCanvasAgent):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::hasIdForFrame):
(WebCore):
* inspector/InspectorPageAgent.h:
(InspectorPageAgent):
* inspector/front-end/CanvasProfileView.js:
(WebInspector.CanvasProfileType.prototype._runSingleFrameCapturing):
(WebInspector.CanvasProfileType.prototype._startFrameCapturing):
(WebInspector.CanvasProfileType.prototype._didStartCapturingFrame):
(WebInspector.CanvasProfileType.prototype._traceLogsRemoved):
(WebInspector.CanvasDispatcher.prototype.contextCreated):
(WebInspector.CanvasDispatcher.prototype.traceLogsRemoved):
(WebInspector.CanvasProfileHeader):
(WebInspector.CanvasProfileHeader.prototype.frameId):

LayoutTests:

* inspector/profiler/canvas-profiler-test.js:
(initialize_CanvasWebGLProfilerTest.InspectorTest.enableCanvasAgent.InspectorBackend.registerCanvasDispatcher):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141403 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/profiler/canvas-profiler-test.js
Source/WebCore/ChangeLog
Source/WebCore/inspector/InjectedScriptCanvasModule.cpp
Source/WebCore/inspector/InjectedScriptCanvasModule.h
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorCanvasAgent.cpp
Source/WebCore/inspector/InspectorCanvasAgent.h
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/inspector/front-end/CanvasProfileView.js

index edb9bd5..2e77422 100644 (file)
@@ -1,3 +1,13 @@
+2013-01-31  Andrey Adaikin  <aandrey@chromium.org>
+
+        Web Inspector: [Canvas] remove invalid canvas profile trace logs upon frame navigation
+        https://bugs.webkit.org/show_bug.cgi?id=108454
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/profiler/canvas-profiler-test.js:
+        (initialize_CanvasWebGLProfilerTest.InspectorTest.enableCanvasAgent.InspectorBackend.registerCanvasDispatcher):
+
 2013-01-31  Andrey Lushnikov  <lushnikov@chromium.org>
 
         Web Inspector: DTE doesn't highlight words if the selected one is the last in the line
index 9c88665..d6d6a42 100644 (file)
@@ -5,7 +5,8 @@ InspectorTest.enableCanvasAgent = function(callback)
     var dispatcher = InspectorBackend._domainDispatchers["Canvas"];
     if (!dispatcher) {
         InspectorBackend.registerCanvasDispatcher({
-            contextCreated: function() {}
+            contextCreated: function() {},
+            traceLogsRemoved: function() {}
         });
     }
 
index 9d8a32b..7ae0944 100644 (file)
@@ -1,3 +1,52 @@
+2013-01-31  Andrey Adaikin  <aandrey@chromium.org>
+
+        Web Inspector: [Canvas] remove invalid canvas profile trace logs upon frame navigation
+        https://bugs.webkit.org/show_bug.cgi?id=108454
+
+        Reviewed by Pavel Feldman.
+
+        When canvas profile trace logs stored in the backend get destroyed (for example, on frame navigation), send an event to frontend and update the UI.
+        Drive-by: replace String types to corresponding TypeBuilder::Canvas::* typedefs.
+
+        * inspector/InjectedScriptCanvasModule.cpp:
+        (WebCore::InjectedScriptCanvasModule::captureFrame):
+        (WebCore::InjectedScriptCanvasModule::startCapturing):
+        (WebCore::InjectedScriptCanvasModule::callStartCapturingFunction):
+        (WebCore::InjectedScriptCanvasModule::stopCapturing):
+        (WebCore::InjectedScriptCanvasModule::dropTraceLog):
+        (WebCore::InjectedScriptCanvasModule::callVoidFunctionWithTraceLogIdArgument):
+        (WebCore::InjectedScriptCanvasModule::traceLog):
+        (WebCore::InjectedScriptCanvasModule::replayTraceLog):
+        (WebCore::InjectedScriptCanvasModule::resourceInfo):
+        (WebCore::InjectedScriptCanvasModule::resourceState):
+        * inspector/InjectedScriptCanvasModule.h:
+        (InjectedScriptCanvasModule):
+        * inspector/Inspector.json:
+        * inspector/InspectorCanvasAgent.cpp:
+        (WebCore::InspectorCanvasAgent::dropTraceLog):
+        (WebCore::InspectorCanvasAgent::stopCapturing):
+        (WebCore::InspectorCanvasAgent::getTraceLog):
+        (WebCore::InspectorCanvasAgent::replayTraceLog):
+        (WebCore::InspectorCanvasAgent::getResourceInfo):
+        (WebCore::InspectorCanvasAgent::getResourceState):
+        (WebCore::InspectorCanvasAgent::frameNavigated):
+        * inspector/InspectorCanvasAgent.h:
+        (InspectorCanvasAgent):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::hasIdForFrame):
+        (WebCore):
+        * inspector/InspectorPageAgent.h:
+        (InspectorPageAgent):
+        * inspector/front-end/CanvasProfileView.js:
+        (WebInspector.CanvasProfileType.prototype._runSingleFrameCapturing):
+        (WebInspector.CanvasProfileType.prototype._startFrameCapturing):
+        (WebInspector.CanvasProfileType.prototype._didStartCapturingFrame):
+        (WebInspector.CanvasProfileType.prototype._traceLogsRemoved):
+        (WebInspector.CanvasDispatcher.prototype.contextCreated):
+        (WebInspector.CanvasDispatcher.prototype.traceLogsRemoved):
+        (WebInspector.CanvasProfileHeader):
+        (WebInspector.CanvasProfileHeader.prototype.frameId):
+
 2013-01-31  Andrey Lushnikov  <lushnikov@chromium.org>
 
         Web Inspector: DTE doesn't highlight words if the selected one is the last in the line
index 6dd3391..474929d 100644 (file)
 #include "ScriptFunctionCall.h"
 #include "ScriptObject.h"
 
+using WebCore::TypeBuilder::Array;
+using WebCore::TypeBuilder::Canvas::ResourceId;
+using WebCore::TypeBuilder::Canvas::ResourceInfo;
+using WebCore::TypeBuilder::Canvas::ResourceState;
+using WebCore::TypeBuilder::Canvas::TraceLog;
+using WebCore::TypeBuilder::Canvas::TraceLogId;
+
 namespace WebCore {
 
 InjectedScriptCanvasModule::InjectedScriptCanvasModule()
@@ -84,17 +91,17 @@ ScriptObject InjectedScriptCanvasModule::callWrapContextFunction(const String& f
     return ScriptObject(context.scriptState(), resultValue);
 }
 
-void InjectedScriptCanvasModule::captureFrame(ErrorString* errorString, String* traceLogId)
+void InjectedScriptCanvasModule::captureFrame(ErrorString* errorString, TraceLogId* traceLogId)
 {
     callStartCapturingFunction("captureFrame", errorString, traceLogId);
 }
 
-void InjectedScriptCanvasModule::startCapturing(ErrorString* errorString, String* traceLogId)
+void InjectedScriptCanvasModule::startCapturing(ErrorString* errorString, TraceLogId* traceLogId)
 {
     callStartCapturingFunction("startCapturing", errorString, traceLogId);
 }
 
-void InjectedScriptCanvasModule::callStartCapturingFunction(const String& functionName, ErrorString* errorString, String* traceLogId)
+void InjectedScriptCanvasModule::callStartCapturingFunction(const String& functionName, ErrorString* errorString, TraceLogId* traceLogId)
 {
     ScriptFunctionCall function(injectedScriptObject(), functionName);
     RefPtr<InspectorValue> resultValue;
@@ -103,17 +110,17 @@ void InjectedScriptCanvasModule::callStartCapturingFunction(const String& functi
         *errorString = "Internal error: " + functionName;
 }
 
-void InjectedScriptCanvasModule::stopCapturing(ErrorString* errorString, const String& traceLogId)
+void InjectedScriptCanvasModule::stopCapturing(ErrorString* errorString, const TraceLogId& traceLogId)
 {
     callVoidFunctionWithTraceLogIdArgument("stopCapturing", errorString, traceLogId);
 }
 
-void InjectedScriptCanvasModule::dropTraceLog(ErrorString* errorString, const String& traceLogId)
+void InjectedScriptCanvasModule::dropTraceLog(ErrorString* errorString, const TraceLogId& traceLogId)
 {
     callVoidFunctionWithTraceLogIdArgument("dropTraceLog", errorString, traceLogId);
 }
 
-void InjectedScriptCanvasModule::callVoidFunctionWithTraceLogIdArgument(const String& functionName, ErrorString* errorString, const String& traceLogId)
+void InjectedScriptCanvasModule::callVoidFunctionWithTraceLogIdArgument(const String& functionName, ErrorString* errorString, const TraceLogId& traceLogId)
 {
     ScriptFunctionCall function(injectedScriptObject(), functionName);
     function.appendArgument(traceLogId);
@@ -124,7 +131,7 @@ void InjectedScriptCanvasModule::callVoidFunctionWithTraceLogIdArgument(const St
         *errorString = "Internal error: " + functionName;
 }
 
-void InjectedScriptCanvasModule::traceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TypeBuilder::Canvas::TraceLog>* traceLog)
+void InjectedScriptCanvasModule::traceLog(ErrorString* errorString, const TraceLogId& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TraceLog>* traceLog)
 {
     ScriptFunctionCall function(injectedScriptObject(), "traceLog");
     function.appendArgument(traceLogId);
@@ -139,10 +146,10 @@ void InjectedScriptCanvasModule::traceLog(ErrorString* errorString, const String
             *errorString = "Internal error: traceLog";
         return;
     }
-    *traceLog = TypeBuilder::Canvas::TraceLog::runtimeCast(resultValue);
+    *traceLog = TraceLog::runtimeCast(resultValue);
 }
 
-void InjectedScriptCanvasModule::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr<TypeBuilder::Canvas::ResourceState>* result)
+void InjectedScriptCanvasModule::replayTraceLog(ErrorString* errorString, const TraceLogId& traceLogId, int stepNo, RefPtr<ResourceState>* result)
 {
     ScriptFunctionCall function(injectedScriptObject(), "replayTraceLog");
     function.appendArgument(traceLogId);
@@ -154,10 +161,10 @@ void InjectedScriptCanvasModule::replayTraceLog(ErrorString* errorString, const
             *errorString = "Internal error: replayTraceLog";
         return;
     }
-    *result = TypeBuilder::Canvas::ResourceState::runtimeCast(resultValue);
+    *result = ResourceState::runtimeCast(resultValue);
 }
 
-void InjectedScriptCanvasModule::resourceInfo(ErrorString* errorString, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceInfo>* result)
+void InjectedScriptCanvasModule::resourceInfo(ErrorString* errorString, const ResourceId& resourceId, RefPtr<ResourceInfo>* result)
 {
     ScriptFunctionCall function(injectedScriptObject(), "resourceInfo");
     function.appendArgument(resourceId);
@@ -168,10 +175,10 @@ void InjectedScriptCanvasModule::resourceInfo(ErrorString* errorString, const St
             *errorString = "Internal error: resourceInfo";
         return;
     }
-    *result = TypeBuilder::Canvas::ResourceInfo::runtimeCast(resultValue);
+    *result = ResourceInfo::runtimeCast(resultValue);
 }
 
-void InjectedScriptCanvasModule::resourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceState>* result)
+void InjectedScriptCanvasModule::resourceState(ErrorString* errorString, const TraceLogId& traceLogId, const ResourceId& resourceId, RefPtr<ResourceState>* result)
 {
     ScriptFunctionCall function(injectedScriptObject(), "resourceState");
     function.appendArgument(traceLogId);
@@ -183,7 +190,7 @@ void InjectedScriptCanvasModule::resourceState(ErrorString* errorString, const S
             *errorString = "Internal error: resourceState";
         return;
     }
-    *result = TypeBuilder::Canvas::ResourceState::runtimeCast(resultValue);
+    *result = ResourceState::runtimeCast(resultValue);
 }
 
 } // namespace WebCore
index 3e0686f..e5ce70e 100644 (file)
@@ -55,14 +55,14 @@ public:
     ScriptObject wrapWebGLContext(const ScriptObject&);
 #endif
 
-    void captureFrame(ErrorString*, String*);
-    void startCapturing(ErrorString*, String*);
-    void stopCapturing(ErrorString*, const String&);
-    void dropTraceLog(ErrorString*, const String&);
+    void captureFrame(ErrorString*, TypeBuilder::Canvas::TraceLogId*);
+    void startCapturing(ErrorString*, TypeBuilder::Canvas::TraceLogId*);
+    void stopCapturing(ErrorString*, const TypeBuilder::Canvas::TraceLogId&);
+    void dropTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&);
     void traceLog(ErrorString*, const String&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>*);
-    void replayTraceLog(ErrorString*, const String&, int, RefPtr<TypeBuilder::Canvas::ResourceState>*);
-    void resourceInfo(ErrorString*, const String&, RefPtr<TypeBuilder::Canvas::ResourceInfo>*);
-    void resourceState(ErrorString*, const String&, const String&, RefPtr<TypeBuilder::Canvas::ResourceState>*);
+    void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>*);
+    void resourceInfo(ErrorString*, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceInfo>*);
+    void resourceState(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceState>*);
 
 private:
     ScriptObject callWrapContextFunction(const String&, const ScriptObject&);
index 9bf9672..1559201 100644 (file)
                     { "name": "frameId", "$ref": "Network.FrameId", "description": "Identifier of the frame containing a canvas with a context." }
                 ],
                 "description": "Fired when a canvas context has been created in the given frame. The context may not be instrumented (see hasUninstrumentedCanvases command)."
+            },
+            {
+                "name": "traceLogsRemoved",
+                "parameters": [
+                    { "name": "frameId", "$ref": "Network.FrameId", "optional": true, "description": "If given, trace logs from the given frame were removed." },
+                    { "name": "traceLogId", "$ref": "TraceLogId", "optional": true, "description": "If given, trace log with the given ID was removed." }
+                ],
+                "description": "Fired when a set of trace logs were removed from the backend. If no parameters are given, all trace logs were removed."
             }
         ]
     },
index cac3976..b9cef8f 100644 (file)
@@ -51,6 +51,8 @@
 #include "ScriptProfiler.h"
 #include "ScriptState.h"
 
+using WebCore::TypeBuilder::Array;
+using WebCore::TypeBuilder::Canvas::ResourceId;
 using WebCore::TypeBuilder::Canvas::ResourceInfo;
 using WebCore::TypeBuilder::Canvas::ResourceState;
 using WebCore::TypeBuilder::Canvas::TraceLog;
@@ -114,7 +116,7 @@ void InspectorCanvasAgent::disable(ErrorString*)
     m_framesWithUninstrumentedCanvases.clear();
 }
 
-void InspectorCanvasAgent::dropTraceLog(ErrorString* errorString, const String& traceLogId)
+void InspectorCanvasAgent::dropTraceLog(ErrorString* errorString, const TraceLogId& traceLogId)
 {
     InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
     if (!module.hasNoValue())
@@ -148,35 +150,35 @@ void InspectorCanvasAgent::startCapturing(ErrorString* errorString, const FrameI
         module.startCapturing(errorString, traceLogId);
 }
 
-void InspectorCanvasAgent::stopCapturing(ErrorString* errorString, const String& traceLogId)
+void InspectorCanvasAgent::stopCapturing(ErrorString* errorString, const TraceLogId& traceLogId)
 {
     InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
     if (!module.hasNoValue())
         module.stopCapturing(errorString, traceLogId);
 }
 
-void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TraceLog>& traceLog)
+void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const TraceLogId& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TraceLog>& traceLog)
 {
     InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
     if (!module.hasNoValue())
         module.traceLog(errorString, traceLogId, startOffset, maxLength, &traceLog);
 }
 
-void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr<ResourceState>& result)
+void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const TraceLogId& traceLogId, int stepNo, RefPtr<ResourceState>& result)
 {
     InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
     if (!module.hasNoValue())
         module.replayTraceLog(errorString, traceLogId, stepNo, &result);
 }
 
-void InspectorCanvasAgent::getResourceInfo(ErrorString* errorString, const String& resourceId, RefPtr<ResourceInfo>& result)
+void InspectorCanvasAgent::getResourceInfo(ErrorString* errorString, const ResourceId& resourceId, RefPtr<ResourceInfo>& result)
 {
     InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, resourceId);
     if (!module.hasNoValue())
         module.resourceInfo(errorString, resourceId, &result);
 }
 
-void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr<ResourceState>& result)
+void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const TraceLogId& traceLogId, const ResourceId& resourceId, RefPtr<ResourceState>& result)
 {
     InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
     if (!module.hasNoValue())
@@ -302,11 +304,16 @@ void InspectorCanvasAgent::frameNavigated(Frame* frame)
 {
     if (!m_enabled)
         return;
-    if (frame == m_pageAgent->mainFrame())
+    if (frame == m_pageAgent->mainFrame()) {
         m_framesWithUninstrumentedCanvases.clear();
-    else {
+        m_frontend->traceLogsRemoved(0, 0);
+    } else {
         while (frame) {
             m_framesWithUninstrumentedCanvases.remove(frame);
+            if (m_pageAgent->hasIdForFrame(frame)) {
+                String frameId = m_pageAgent->frameId(frame);
+                m_frontend->traceLogsRemoved(&frameId, 0);
+            }
             frame = frame->tree()->traverseNext();
         }
     }
index 1cf1b58..6b626fc 100644 (file)
@@ -79,15 +79,15 @@ public:
     // Called from the front-end.
     virtual void enable(ErrorString*);
     virtual void disable(ErrorString*);
-    virtual void dropTraceLog(ErrorString*, const String&);
+    virtual void dropTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&);
     virtual void hasUninstrumentedCanvases(ErrorString*, bool*);
     virtual void captureFrame(ErrorString*, const TypeBuilder::Network::FrameId*, TypeBuilder::Canvas::TraceLogId*);
     virtual void startCapturing(ErrorString*, const TypeBuilder::Network::FrameId*, TypeBuilder::Canvas::TraceLogId*);
-    virtual void stopCapturing(ErrorString*, const String&);
-    virtual void getTraceLog(ErrorString*, const String&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&);
-    virtual void replayTraceLog(ErrorString*, const String&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&);
-    virtual void getResourceInfo(ErrorString*, const String&, RefPtr<TypeBuilder::Canvas::ResourceInfo>&);
-    virtual void getResourceState(ErrorString*, const String&, const String&, RefPtr<TypeBuilder::Canvas::ResourceState>&);
+    virtual void stopCapturing(ErrorString*, const TypeBuilder::Canvas::TraceLogId&);
+    virtual void getTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&);
+    virtual void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&);
+    virtual void getResourceInfo(ErrorString*, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceInfo>&);
+    virtual void getResourceState(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceState>&);
 
 private:
     InspectorCanvasAgent(InstrumentingAgents*, InspectorCompositeState*, InspectorPageAgent*, InjectedScriptManager*);
index d2b7108..12fcd7f 100644 (file)
@@ -879,6 +879,11 @@ String InspectorPageAgent::frameId(Frame* frame)
     return identifier;
 }
 
+bool InspectorPageAgent::hasIdForFrame(Frame* frame) const
+{
+    return frame && m_frameToIdentifier.contains(frame);
+}
+
 String InspectorPageAgent::loaderId(DocumentLoader* loader)
 {
     if (!loader)
index dc82a97..61d6b04 100644 (file)
@@ -165,6 +165,7 @@ public:
     String createIdentifier();
     Frame* frameForId(const String& frameId);
     String frameId(Frame*);
+    bool hasIdForFrame(Frame*) const;
     String loaderId(DocumentLoader*);
     Frame* assertFrame(ErrorString*, const String& frameId);
     String scriptPreprocessor() { return m_scriptPreprocessor; }
index a3bdefa..792567f 100644 (file)
@@ -456,7 +456,8 @@ WebInspector.CanvasProfileType.prototype = {
      */
     _runSingleFrameCapturing: function(profilesPanel)
     {
-        CanvasAgent.captureFrame(this._selectedFrameId(), this._didStartCapturingFrame.bind(this, profilesPanel));
+        var frameId = this._selectedFrameId();
+        CanvasAgent.captureFrame(frameId, this._didStartCapturingFrame.bind(this, profilesPanel, frameId));
     },
 
     /**
@@ -464,7 +465,8 @@ WebInspector.CanvasProfileType.prototype = {
      */
     _startFrameCapturing: function(profilesPanel)
     {
-        CanvasAgent.startCapturing(this._selectedFrameId(), this._didStartCapturingFrame.bind(this, profilesPanel));
+        var frameId = this._selectedFrameId();
+        CanvasAgent.startCapturing(frameId, this._didStartCapturingFrame.bind(this, profilesPanel, frameId));
     },
 
     _stopFrameCapturing: function()
@@ -483,14 +485,15 @@ WebInspector.CanvasProfileType.prototype = {
 
     /**
      * @param {WebInspector.ProfilesPanel} profilesPanel
+     * @param {string|undefined} frameId
      * @param {?Protocol.Error} error
      * @param {CanvasAgent.TraceLogId} traceLogId
      */
-    _didStartCapturingFrame: function(profilesPanel, error, traceLogId)
+    _didStartCapturingFrame: function(profilesPanel, frameId, error, traceLogId)
     {
         if (error || this._lastProfileHeader && this._lastProfileHeader.traceLogId() === traceLogId)
             return;
-        var profileHeader = new WebInspector.CanvasProfileHeader(this, WebInspector.UIString("Trace Log %d", this._nextProfileUid), this._nextProfileUid, traceLogId);
+        var profileHeader = new WebInspector.CanvasProfileHeader(this, WebInspector.UIString("Trace Log %d", this._nextProfileUid), this._nextProfileUid, traceLogId, frameId);
         ++this._nextProfileUid;
         this._lastProfileHeader = profileHeader;
         profilesPanel.addProfileHeader(profileHeader);
@@ -640,6 +643,28 @@ WebInspector.CanvasProfileType.prototype = {
     },
 
     /**
+     * @param {NetworkAgent.FrameId=} frameId
+     * @param {CanvasAgent.TraceLogId=} traceLogId
+     */
+    _traceLogsRemoved: function(frameId, traceLogId)
+    {
+        var sidebarElementsToDelete = [];
+        var sidebarElements = /** @type {!Array.<WebInspector.ProfileSidebarTreeElement>} */ ((this.treeElement && this.treeElement.children) || []);
+        for (var i = 0, n = sidebarElements.length; i < n; ++i) {
+            var header = /** @type {WebInspector.CanvasProfileHeader} */ (sidebarElements[i].profile);
+            if (!header)
+                continue;
+            if (frameId && frameId !== header.frameId())
+                continue;
+            if (traceLogId && traceLogId !== header.traceLogId())
+                continue;
+            sidebarElementsToDelete.push(sidebarElements[i]);
+        }
+        for (var i = 0, n = sidebarElementsToDelete.length; i < n; ++i)
+            sidebarElementsToDelete[i].ondelete();
+    },
+
+    /**
      * @return {string|undefined}
      */
     _selectedFrameId: function()
@@ -675,6 +700,15 @@ WebInspector.CanvasDispatcher.prototype = {
     contextCreated: function(frameId)
     {
         this._profileType._contextCreated(frameId);
+    },
+
+    /**
+     * @param {NetworkAgent.FrameId=} frameId
+     * @param {CanvasAgent.TraceLogId=} traceLogId
+     */
+    traceLogsRemoved: function(frameId, traceLogId)
+    {
+        this._profileType._traceLogsRemoved(frameId, traceLogId);
     }
 }
 
@@ -685,12 +719,14 @@ WebInspector.CanvasDispatcher.prototype = {
  * @param {string} title
  * @param {number=} uid
  * @param {CanvasAgent.TraceLogId=} traceLogId
+ * @param {NetworkAgent.FrameId=} frameId
  */
-WebInspector.CanvasProfileHeader = function(type, title, uid, traceLogId)
+WebInspector.CanvasProfileHeader = function(type, title, uid, traceLogId, frameId)
 {
     WebInspector.ProfileHeader.call(this, type, title, uid);
     /** @type {CanvasAgent.TraceLogId} */
     this._traceLogId = traceLogId || "";
+    this._frameId = frameId;
     this._alive = true;
     this._traceLogSize = 0;
 }
@@ -705,7 +741,16 @@ WebInspector.CanvasProfileHeader.prototype = {
     },
 
     /**
+     * @return {NetworkAgent.FrameId|undefined}
+     */
+    frameId: function()
+    {
+        return this._frameId;
+    },
+
+    /**
      * @override
+     * @return {WebInspector.ProfileSidebarTreeElement}
      */
     createSidebarTreeElement: function()
     {