Changeset 76344 in webkit


Ignore:
Timestamp:
Jan 21, 2011 4:30:56 AM (13 years ago)
Author:
loislo@chromium.org
Message:

2011-01-20 Ilya Tikhonovsky <loislo@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: switch page/Console implementation from InspectorController to InspectorInstrumentation.

There are some places in WebCore where we still using direct InspectorController calls.
The idea is to pass all the Inspector related calls via InspectorInstrumentaion which is the
Inspector facade for WebCore.

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

  • inspector/InspectorController.cpp:
  • inspector/InspectorController.h:
  • inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::addProfileImpl): (WebCore::InspectorInstrumentation::profilerEnabledImpl): (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl):
  • inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::addProfile): (WebCore::InspectorInstrumentation::profilerEnabled): (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileName):
  • page/Console.cpp: (WebCore::Console::profile): (WebCore::Console::profileEnd):
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76341 r76344  
     12011-01-20  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: switch page/Console implementation from InspectorController to InspectorInstrumentation.
     6
     7        There are some places in WebCore where we still using direct InspectorController calls.
     8        The idea is to pass all the Inspector related calls via InspectorInstrumentaion which is the
     9        Inspector facade for WebCore.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=52869
     12
     13        * inspector/InspectorController.cpp:
     14        * inspector/InspectorController.h:
     15        * inspector/InspectorInstrumentation.cpp:
     16        (WebCore::InspectorInstrumentation::addProfileImpl):
     17        (WebCore::InspectorInstrumentation::profilerEnabledImpl):
     18        (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl):
     19        * inspector/InspectorInstrumentation.h:
     20        (WebCore::InspectorInstrumentation::addProfile):
     21        (WebCore::InspectorInstrumentation::profilerEnabled):
     22        (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileName):
     23        * page/Console.cpp:
     24        (WebCore::Console::profile):
     25        (WebCore::Console::profileEnd):
     26
    1272011-01-12  Pavel Podivilov  <podivilov@chromium.org>
    228
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r76337 r76344  
    984984
    985985#if ENABLE(JAVASCRIPT_DEBUGGER)
    986 void InspectorController::addProfile(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL)
    987 {
    988     if (!enabled())
    989         return;
    990     m_profilerAgent->addProfile(prpProfile, lineNumber, sourceURL);
    991 }
    992 
    993986bool InspectorController::isRecordingUserInitiatedProfile() const
    994987{
    995988    return m_profilerAgent->isRecordingUserInitiatedProfile();
    996 }
    997 
    998 String InspectorController::getCurrentUserInitiatedProfileName(bool incrementProfileNumber)
    999 {
    1000     return m_profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber);
    1001989}
    1002990
  • trunk/Source/WebCore/inspector/InspectorController.h

    r76337 r76344  
    228228
    229229#if ENABLE(JAVASCRIPT_DEBUGGER)
    230     void addProfile(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
    231230    bool isRecordingUserInitiatedProfile() const;
    232     String getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false);
    233231    void startProfiling() { startUserInitiatedProfiling(); }
    234232    void startUserInitiatedProfiling();
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r76337 r76344  
    553553        profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, sourceURL);
    554554}
     555
     556void InspectorInstrumentation::addProfileImpl(InspectorController* inspectorController, RefPtr<ScriptProfile> profile, ScriptCallStack* callStack)
     557{
     558    if (InspectorProfilerAgent* profilerAgent = inspectorController->profilerAgent()) {
     559        const ScriptCallFrame& lastCaller = callStack->at(0);
     560        profilerAgent->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL());
     561    }
     562}
     563
     564bool InspectorInstrumentation::profilerEnabledImpl(InspectorController* inspectorController)
     565{
     566    if (!inspectorController->enabled())
     567        return false;
     568
     569    InspectorProfilerAgent* profilerAgent = inspectorController->profilerAgent();
     570    if (!profilerAgent)
     571        return false;
     572
     573    return profilerAgent->enabled();
     574}
     575
     576String InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(InspectorController* inspectorController, bool incrementProfileNumber)
     577{
     578    if (InspectorProfilerAgent* profilerAgent = inspectorController->profilerAgent())
     579        return profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber);
     580    return "";
     581}
    555582#endif
    556583
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r76337 r76344  
    140140#if ENABLE(JAVASCRIPT_DEBUGGER)
    141141    static void addStartProfilingMessageToConsole(Page*, const String& title, unsigned lineNumber, const String& sourceURL);
     142    static void addProfile(Page*, RefPtr<ScriptProfile>, ScriptCallStack*);
     143    static bool profilerEnabled(Page*);
     144    static String getCurrentUserInitiatedProfileName(Page*, bool incrementProfileNumber);
    142145#endif
    143146
     
    247250#if ENABLE(JAVASCRIPT_DEBUGGER)
    248251    static void addStartProfilingMessageToConsoleImpl(InspectorController*, const String& title, unsigned lineNumber, const String& sourceURL);
     252    static void addProfileImpl(InspectorController*, RefPtr<ScriptProfile>, ScriptCallStack*);
     253    static bool profilerEnabledImpl(InspectorController*);
     254    static String getCurrentUserInitiatedProfileNameImpl(InspectorController*, bool incrementProfileNumber);
    249255#endif
    250256
     
    882888#endif
    883889}
     890
     891inline void InspectorInstrumentation::addProfile(Page* page, RefPtr<ScriptProfile> profile, ScriptCallStack* callStack)
     892{
     893#if ENABLE(INSPECTOR)
     894    if (InspectorController* inspectorController = inspectorControllerForPage(page))
     895        addProfileImpl(inspectorController, profile, callStack);
     896#endif
     897}
     898
     899inline bool InspectorInstrumentation::profilerEnabled(Page* page)
     900{
     901#if ENABLE(INSPECTOR)
     902    if (InspectorController* inspectorController = inspectorControllerForPage(page))
     903        return profilerEnabledImpl(inspectorController);
     904#endif
     905    return false;
     906}
     907
     908inline String InspectorInstrumentation::getCurrentUserInitiatedProfileName(Page* page, bool incrementProfileNumber)
     909{
     910#if ENABLE(INSPECTOR)
     911    if (InspectorController* inspectorController = inspectorControllerForPage(page))
     912        return InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(inspectorController, incrementProfileNumber);
     913#endif
     914    return "";
     915}
    884916#endif
    885917
     
    937969    return 0;
    938970}
     971
    939972#endif
    940973
  • trunk/Source/WebCore/page/Console.cpp

    r76337 r76344  
    263263        return;
    264264
    265 #if ENABLE(INSPECTOR)
    266     InspectorController* controller = page->inspectorController();
    267265    // FIXME: log a console message when profiling is disabled.
    268     if (!controller->profilerEnabled())
    269         return;
    270 #endif
     266    if (!InspectorInstrumentation::profilerEnabled(page))
     267        return;
    271268
    272269    String resolvedTitle = title;
    273270    if (title.isNull()) // no title so give it the next user initiated profile title.
    274 #if ENABLE(INSPECTOR)
    275         resolvedTitle = controller->getCurrentUserInitiatedProfileName(true);
    276 #else
    277         resolvedTitle = "";
    278 #endif
     271        resolvedTitle = InspectorInstrumentation::getCurrentUserInitiatedProfileName(page, true);
    279272
    280273    ScriptProfiler::start(state, resolvedTitle);
     
    290283        return;
    291284
    292 #if ENABLE(INSPECTOR)
    293     InspectorController* controller = page->inspectorController();
    294     if (!controller->profilerEnabled())
    295         return;
    296 #endif
     285    if (!InspectorInstrumentation::profilerEnabled(page))
     286        return;
    297287
    298288    RefPtr<ScriptProfile> profile = ScriptProfiler::stop(state, title);
     
    301291
    302292    m_profiles.append(profile);
    303 
    304 #if ENABLE(INSPECTOR)
    305     const ScriptCallFrame& lastCaller = callStack->at(0);
    306     controller->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL());
    307 #endif
     293    InspectorInstrumentation::addProfile(page, profile, callStack.get());
    308294}
    309295
Note: See TracChangeset for help on using the changeset viewer.