Changeset 139853 in webkit


Ignore:
Timestamp:
Jan 16, 2013, 1:50:19 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Inspector] Add events for tracking page loads and scheduled navigations.
https://bugs.webkit.org/show_bug.cgi?id=104168

Patch by Ken Kania <kkania@chromium.org> on 2013-01-16
Reviewed by Pavel Feldman.

These events are needed for clients who need to be aware of when a page is
navigating or about to navigate. Some clients may wish to prevent interaction
with the page during this time. Two of the new events track loading start and
stop, as measured by the ProgressTracker. The other two events track when a
page has a new scheduled navigation and when it no longer has a scheduled
navigation. These latter two events won't allow the client to determine if
a load is going to happen in all circumstances, but is sufficient for many cases.

Source/WebCore:

Tests: inspector-protocol/page/frameScheduledNavigation.html

inspector-protocol/page/frameStartedLoading.html

  • inspector/Inspector.json:
  • inspector/InspectorInstrumentation.cpp:

(WebCore):
(WebCore::InspectorInstrumentation::frameStartedLoadingImpl):
(WebCore::InspectorInstrumentation::frameStoppedLoadingImpl):
(WebCore::InspectorInstrumentation::frameScheduledNavigationImpl):
(WebCore::InspectorInstrumentation::frameClearedScheduledNavigationImpl):

  • inspector/InspectorInstrumentation.h:

(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::frameStartedLoading):
(WebCore):
(WebCore::InspectorInstrumentation::frameStoppedLoading):
(WebCore::InspectorInstrumentation::frameScheduledNavigation):
(WebCore::InspectorInstrumentation::frameClearedScheduledNavigation):

  • inspector/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::frameStartedLoading):
(WebCore):
(WebCore::InspectorPageAgent::frameStoppedLoading):
(WebCore::InspectorPageAgent::frameScheduledNavigation):
(WebCore::InspectorPageAgent::frameClearedScheduledNavigation):

  • inspector/InspectorPageAgent.h:
  • inspector/front-end/ResourceTreeModel.js:

(WebInspector.PageDispatcher.prototype.frameDetached):
(WebInspector.PageDispatcher.prototype.frameStartedLoading):
(WebInspector.PageDispatcher.prototype.frameStoppedLoading):
(WebInspector.PageDispatcher.prototype.frameScheduledNavigation):
(WebInspector.PageDispatcher.prototype.frameClearedScheduledNavigation):

  • loader/NavigationScheduler.cpp:

(WebCore::NavigationScheduler::clear):
(WebCore::NavigationScheduler::timerFired):
(WebCore::NavigationScheduler::startTimer):
(WebCore::NavigationScheduler::cancel):

  • loader/ProgressTracker.cpp:

(WebCore::ProgressTracker::progressStarted):
(WebCore::ProgressTracker::finalProgressComplete):

LayoutTests:

  • inspector-protocol/page/frameScheduledNavigation-expected.txt: Added.
  • inspector-protocol/page/frameScheduledNavigation.html: Added.
  • inspector-protocol/page/frameStartedLoading-expected.txt: Added.
  • inspector-protocol/page/frameStartedLoading.html: Added.
Location:
trunk
Files:
5 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139852 r139853  
     12013-01-16  Ken Kania  <kkania@chromium.org>
     2
     3        [Inspector] Add events for tracking page loads and scheduled navigations.
     4        https://bugs.webkit.org/show_bug.cgi?id=104168
     5
     6        Reviewed by Pavel Feldman.
     7
     8        These events are needed for clients who need to be aware of when a page is
     9        navigating or about to navigate. Some clients may wish to prevent interaction
     10        with the page during this time. Two of the new events track loading start and
     11        stop, as measured by the ProgressTracker. The other two events track when a
     12        page has a new scheduled navigation and when it no longer has a scheduled
     13        navigation. These latter two events won't allow the client to determine if
     14        a load is going to happen in all circumstances, but is sufficient for many cases.
     15
     16        * inspector-protocol/page/frameScheduledNavigation-expected.txt: Added.
     17        * inspector-protocol/page/frameScheduledNavigation.html: Added.
     18        * inspector-protocol/page/frameStartedLoading-expected.txt: Added.
     19        * inspector-protocol/page/frameStartedLoading.html: Added.
     20
    1212013-01-16  Zan Dobersek  <zdobersek@igalia.com>
    222
  • trunk/Source/WebCore/ChangeLog

    r139849 r139853  
     12013-01-16  Ken Kania  <kkania@chromium.org>
     2
     3        [Inspector] Add events for tracking page loads and scheduled navigations.
     4        https://bugs.webkit.org/show_bug.cgi?id=104168
     5
     6        Reviewed by Pavel Feldman.
     7
     8        These events are needed for clients who need to be aware of when a page is
     9        navigating or about to navigate. Some clients may wish to prevent interaction
     10        with the page during this time. Two of the new events track loading start and
     11        stop, as measured by the ProgressTracker. The other two events track when a
     12        page has a new scheduled navigation and when it no longer has a scheduled
     13        navigation. These latter two events won't allow the client to determine if
     14        a load is going to happen in all circumstances, but is sufficient for many cases.
     15
     16        Tests: inspector-protocol/page/frameScheduledNavigation.html
     17               inspector-protocol/page/frameStartedLoading.html
     18
     19        * inspector/Inspector.json:
     20        * inspector/InspectorInstrumentation.cpp:
     21        (WebCore):
     22        (WebCore::InspectorInstrumentation::frameStartedLoadingImpl):
     23        (WebCore::InspectorInstrumentation::frameStoppedLoadingImpl):
     24        (WebCore::InspectorInstrumentation::frameScheduledNavigationImpl):
     25        (WebCore::InspectorInstrumentation::frameClearedScheduledNavigationImpl):
     26        * inspector/InspectorInstrumentation.h:
     27        (InspectorInstrumentation):
     28        (WebCore::InspectorInstrumentation::frameStartedLoading):
     29        (WebCore):
     30        (WebCore::InspectorInstrumentation::frameStoppedLoading):
     31        (WebCore::InspectorInstrumentation::frameScheduledNavigation):
     32        (WebCore::InspectorInstrumentation::frameClearedScheduledNavigation):
     33        * inspector/InspectorPageAgent.cpp:
     34        (WebCore::InspectorPageAgent::frameStartedLoading):
     35        (WebCore):
     36        (WebCore::InspectorPageAgent::frameStoppedLoading):
     37        (WebCore::InspectorPageAgent::frameScheduledNavigation):
     38        (WebCore::InspectorPageAgent::frameClearedScheduledNavigation):
     39        * inspector/InspectorPageAgent.h:
     40        * inspector/front-end/ResourceTreeModel.js:
     41        (WebInspector.PageDispatcher.prototype.frameDetached):
     42        (WebInspector.PageDispatcher.prototype.frameStartedLoading):
     43        (WebInspector.PageDispatcher.prototype.frameStoppedLoading):
     44        (WebInspector.PageDispatcher.prototype.frameScheduledNavigation):
     45        (WebInspector.PageDispatcher.prototype.frameClearedScheduledNavigation):
     46        * loader/NavigationScheduler.cpp:
     47        (WebCore::NavigationScheduler::clear):
     48        (WebCore::NavigationScheduler::timerFired):
     49        (WebCore::NavigationScheduler::startTimer):
     50        (WebCore::NavigationScheduler::cancel):
     51        * loader/ProgressTracker.cpp:
     52        (WebCore::ProgressTracker::progressStarted):
     53        (WebCore::ProgressTracker::finalProgressComplete):
     54
    1552013-01-16  Tommy Widenflycht  <tommyw@google.com>
    256
  • trunk/Source/WebCore/inspector/Inspector.json

    r139814 r139853  
    493493                "parameters": [
    494494                    { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has been detached." }
     495                ],
     496                "hidden": true
     497            },
     498            {
     499                "name": "frameStartedLoading",
     500                "description": "Fired when frame has started loading.",
     501                "parameters": [
     502                    { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has started loading." }
     503                ],
     504                "hidden": true
     505            },
     506            {
     507                "name": "frameStoppedLoading",
     508                "description": "Fired when frame has stopped loading.",
     509                "parameters": [
     510                    { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has stopped loading." }
     511                ],
     512                "hidden": true
     513            },
     514            {
     515                "name": "frameScheduledNavigation",
     516                "description": "Fired when frame schedules a potential navigation.",
     517                "parameters": [
     518                    { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has scheduled a navigation." },
     519                    { "name": "delay", "type": "number", "description": "Delay (in seconds) until the navigation is scheduled to begin. The navigation is not guaranteed to start." }
     520                ],
     521                "hidden": true
     522            },
     523            {
     524                "name": "frameClearedScheduledNavigation",
     525                "description": "Fired when frame no longer has a scheduled navigation.",
     526                "parameters": [
     527                    { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." }
    495528                ],
    496529                "hidden": true
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r138497 r139853  
    928928}
    929929
     930void InspectorInstrumentation::frameStartedLoadingImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
     931{
     932    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
     933        inspectorPageAgent->frameStartedLoading(frame);
     934}
     935
     936void InspectorInstrumentation::frameStoppedLoadingImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
     937{
     938    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
     939        inspectorPageAgent->frameStoppedLoading(frame);
     940}
     941
     942void InspectorInstrumentation::frameScheduledNavigationImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, double delay)
     943{
     944    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
     945        inspectorPageAgent->frameScheduledNavigation(frame, delay);
     946}
     947
     948void InspectorInstrumentation::frameClearedScheduledNavigationImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
     949{
     950    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
     951        inspectorPageAgent->frameClearedScheduledNavigation(frame);
     952}
     953
    930954void InspectorInstrumentation::willDestroyCachedResourceImpl(CachedResource* cachedResource)
    931955{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r139132 r139853  
    192192    static void didCommitLoad(Frame*, DocumentLoader*);
    193193    static void loaderDetachedFromFrame(Frame*, DocumentLoader*);
     194    static void frameStartedLoading(Frame*);
     195    static void frameStoppedLoading(Frame*);
     196    static void frameScheduledNavigation(Frame*, double delay);
     197    static void frameClearedScheduledNavigation(Frame*);
    194198    static void willDestroyCachedResource(CachedResource*);
    195199
     
    391395    static void didCommitLoadImpl(InstrumentingAgents*, Page*, DocumentLoader*);
    392396    static void loaderDetachedFromFrameImpl(InstrumentingAgents*, DocumentLoader*);
     397    static void frameStartedLoadingImpl(InstrumentingAgents*, Frame*);
     398    static void frameStoppedLoadingImpl(InstrumentingAgents*, Frame*);
     399    static void frameScheduledNavigationImpl(InstrumentingAgents*, Frame*, double delay);
     400    static void frameClearedScheduledNavigationImpl(InstrumentingAgents*, Frame*);
    393401    static void willDestroyCachedResourceImpl(CachedResource*);
    394402
     
    16521660}
    16531661
     1662inline void InspectorInstrumentation::frameStartedLoading(Frame* frame)
     1663{
     1664#if ENABLE(INSPECTOR)
     1665    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1666        frameStartedLoadingImpl(instrumentingAgents, frame);
     1667#endif
     1668}
     1669
     1670inline void InspectorInstrumentation::frameStoppedLoading(Frame* frame)
     1671{
     1672#if ENABLE(INSPECTOR)
     1673    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1674        frameStoppedLoadingImpl(instrumentingAgents, frame);
     1675#endif
     1676}
     1677
     1678inline void InspectorInstrumentation::frameScheduledNavigation(Frame* frame, double delay)
     1679{
     1680#if ENABLE(INSPECTOR)
     1681    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1682        frameScheduledNavigationImpl(instrumentingAgents, frame, delay);
     1683#endif
     1684}
     1685
     1686inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame* frame)
     1687{
     1688#if ENABLE(INSPECTOR)
     1689    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1690        frameClearedScheduledNavigationImpl(instrumentingAgents, frame);
     1691#endif
     1692}
     1693
    16541694inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource* cachedResource)
    16551695{
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r139418 r139853  
    901901}
    902902
     903void InspectorPageAgent::frameStartedLoading(Frame* frame)
     904{
     905    m_frontend->frameStartedLoading(frameId(frame));
     906}
     907
     908void InspectorPageAgent::frameStoppedLoading(Frame* frame)
     909{
     910    m_frontend->frameStoppedLoading(frameId(frame));
     911}
     912
     913void InspectorPageAgent::frameScheduledNavigation(Frame* frame, double delay)
     914{
     915    m_frontend->frameScheduledNavigation(frameId(frame), delay);
     916}
     917
     918void InspectorPageAgent::frameClearedScheduledNavigation(Frame* frame)
     919{
     920    m_frontend->frameClearedScheduledNavigation(frameId(frame));
     921}
     922
    903923void InspectorPageAgent::applyScreenWidthOverride(long* width)
    904924{
  • trunk/Source/WebCore/inspector/InspectorPageAgent.h

    r139418 r139853  
    139139    void frameDetached(Frame*);
    140140    void loaderDetachedFromFrame(DocumentLoader*);
     141    void frameStartedLoading(Frame*);
     142    void frameStoppedLoading(Frame*);
     143    void frameScheduledNavigation(Frame*, double delay);
     144    void frameClearedScheduledNavigation(Frame*);
    141145    void applyScreenWidthOverride(long*);
    142146    void applyScreenHeightOverride(long*);
  • trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js

    r133463 r139853  
    597597    {
    598598        this._resourceTreeModel._frameDetached(frameId);
     599    },
     600
     601    frameStartedLoading: function(frameId) {
     602    },
     603
     604    frameStoppedLoading: function(frameId) {
     605    },
     606
     607    frameScheduledNavigation: function(frameId, delay) {
     608    },
     609
     610    frameClearedScheduledNavigation: function(frameId) {
    599611    }
    600612}
  • trunk/Source/WebCore/loader/NavigationScheduler.cpp

    r112184 r139853  
    4646#include "HTMLFrameOwnerElement.h"
    4747#include "HistoryItem.h"
     48#include "InspectorInstrumentation.h"
    4849#include "Page.h"
    4950#include "UserGestureIndicator.h"
     
    287288void NavigationScheduler::clear()
    288289{
     290    if (m_timer.isActive())
     291        InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
    289292    m_timer.stop();
    290293    m_redirect.clear();
     
    412415    if (!m_frame->page())
    413416        return;
    414     if (m_frame->page()->defersLoading())
    415         return;
     417    if (m_frame->page()->defersLoading()) {
     418        InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
     419        return;
     420    }
    416421
    417422    OwnPtr<ScheduledNavigation> redirect(m_redirect.release());
    418423    redirect->fire(m_frame);
     424    InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
    419425}
    420426
     
    459465    m_timer.startOneShot(m_redirect->delay());
    460466    m_redirect->didStartTimer(m_frame, &m_timer);
     467    InspectorInstrumentation::frameScheduledNavigation(m_frame, m_redirect->delay());
    461468}
    462469
    463470void NavigationScheduler::cancel(bool newLoadInProgress)
    464471{
     472    if (m_timer.isActive())
     473        InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
    465474    m_timer.stop();
    466475
  • trunk/Source/WebCore/loader/ProgressTracker.cpp

    r103781 r139853  
    3232#include "FrameLoaderStateMachine.h"
    3333#include "FrameLoaderClient.h"
     34#include "InspectorInstrumentation.h"
    3435#include "Logging.h"
    3536#include "ResourceResponse.h"
     
    121122
    122123    frame->loader()->client()->didChangeEstimatedProgress();
     124    InspectorInstrumentation::frameStartedLoading(frame);
    123125}
    124126
     
    156158    frame->loader()->client()->setMainFrameDocumentReady(true);
    157159    frame->loader()->client()->postProgressFinishedNotification();
     160    InspectorInstrumentation::frameStoppedLoading(frame.get());
    158161}
    159162
Note: See TracChangeset for help on using the changeset viewer.