src/3rdparty/webkit/WebCore/page/Console.cpp
changeset 30 5dc02b23752f
parent 3 41300fa6a67c
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    28 
    28 
    29 #include "config.h"
    29 #include "config.h"
    30 #include "Console.h"
    30 #include "Console.h"
    31 
    31 
    32 #include "CString.h"
    32 #include "CString.h"
       
    33 #include "Chrome.h"
    33 #include "ChromeClient.h"
    34 #include "ChromeClient.h"
    34 #include "ConsoleMessage.h"
    35 #include "ConsoleMessage.h"
    35 #include "Frame.h"
    36 #include "Frame.h"
    36 #include "FrameLoader.h"
    37 #include "FrameLoader.h"
    37 #include "FrameTree.h"
    38 #include "FrameTree.h"
    38 #include "InspectorController.h"
    39 #include "InspectorController.h"
    39 #include "Page.h"
    40 #include "Page.h"
    40 #include "PageGroup.h"
    41 #include "PageGroup.h"
    41 #include "PlatformString.h"
    42 #include "PlatformString.h"
    42 
    43 
    43 #if ENABLE(JAVASCRIPT_DEBUGGER)
       
    44 #include <profiler/Profiler.h>
       
    45 #endif
       
    46 
       
    47 #include "ScriptCallStack.h"
    44 #include "ScriptCallStack.h"
       
    45 #include "ScriptProfile.h"
       
    46 #include "ScriptProfiler.h"
    48 #include <stdio.h>
    47 #include <stdio.h>
    49 #include <wtf/UnusedParam.h>
    48 #include <wtf/UnusedParam.h>
    50 
    49 
    51 namespace WebCore {
    50 namespace WebCore {
    52 
    51 
   189     printSourceURLAndLine(lastCaller.sourceURL().prettyURL(), 0);
   188     printSourceURLAndLine(lastCaller.sourceURL().prettyURL(), 0);
   190     printMessageSourceAndLevelPrefix(JSMessageSource, level);
   189     printMessageSourceAndLevelPrefix(JSMessageSource, level);
   191 
   190 
   192     for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) {
   191     for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) {
   193         String argAsString;
   192         String argAsString;
   194         if (lastCaller.argumentAt(i).getString(argAsString))
   193         if (lastCaller.argumentAt(i).getString(callStack->state(), argAsString))
   195             printf(" %s", argAsString.utf8().data());
   194             printf(" %s", argAsString.utf8().data());
   196     }
   195     }
   197     printf("\n");
   196     printf("\n");
   198 }
   197 }
   199 
   198 
   268 #else
   267 #else
   269     UNUSED_PARAM(callStack);
   268     UNUSED_PARAM(callStack);
   270 #endif
   269 #endif
   271 }
   270 }
   272 
   271 
       
   272 void Console::markTimeline(ScriptCallStack* callStack)
       
   273 {
       
   274 #if ENABLE(INSPECTOR)
       
   275     Page* page = this->page();
       
   276     if (!page)
       
   277         return;
       
   278 
       
   279     const ScriptCallFrame& lastCaller = callStack->at(0);
       
   280     String message;
       
   281     getFirstArgumentAsString(callStack->state(), lastCaller, message);
       
   282 
       
   283     page->inspectorController()->markTimeline(message);
       
   284 #else
       
   285     UNUSED_PARAM(callStack);
       
   286 #endif
       
   287 }
       
   288 
   273 #if ENABLE(WML)
   289 #if ENABLE(WML)
   274 String Console::lastWMLErrorMessage() const
   290 String Console::lastWMLErrorMessage() const
   275 {
   291 {
   276     Page* page = this->page();
   292     Page* page = this->page();
   277     if (!page)
   293     if (!page)
   296 }
   312 }
   297 #endif
   313 #endif
   298 
   314 
   299 #if ENABLE(JAVASCRIPT_DEBUGGER)
   315 #if ENABLE(JAVASCRIPT_DEBUGGER)
   300 
   316 
   301 void Console::profile(const JSC::UString& title, ScriptCallStack* callStack)
   317 void Console::profile(const String& title, ScriptCallStack* callStack)
   302 {
   318 {
   303     Page* page = this->page();
   319     Page* page = this->page();
   304     if (!page)
   320     if (!page)
   305         return;
   321         return;
   306 
   322 
   309     // FIXME: log a console message when profiling is disabled.
   325     // FIXME: log a console message when profiling is disabled.
   310     if (!controller->profilerEnabled())
   326     if (!controller->profilerEnabled())
   311         return;
   327         return;
   312 #endif
   328 #endif
   313 
   329 
   314     JSC::UString resolvedTitle = title;
   330     String resolvedTitle = title;
   315     if (title.isNull())   // no title so give it the next user initiated profile title.
   331     if (title.isNull()) // no title so give it the next user initiated profile title.
   316 #if ENABLE(INSPECTOR)
   332 #if ENABLE(INSPECTOR)
   317         resolvedTitle = controller->getCurrentUserInitiatedProfileName(true);
   333         resolvedTitle = controller->getCurrentUserInitiatedProfileName(true);
   318 #else
   334 #else
   319         resolvedTitle = "";
   335         resolvedTitle = "";
   320 #endif
   336 #endif
   321 
   337 
   322     JSC::Profiler::profiler()->startProfiling(callStack->state(), resolvedTitle);
   338     ScriptProfiler::start(callStack->state(), resolvedTitle);
   323 
   339 
   324 #if ENABLE(INSPECTOR)
   340 #if ENABLE(INSPECTOR)
   325     const ScriptCallFrame& lastCaller = callStack->at(0);
   341     const ScriptCallFrame& lastCaller = callStack->at(0);
   326     controller->addStartProfilingMessageToConsole(resolvedTitle, lastCaller.lineNumber(), lastCaller.sourceURL());
   342     controller->addStartProfilingMessageToConsole(resolvedTitle, lastCaller.lineNumber(), lastCaller.sourceURL());
   327 #endif
   343 #endif
   328 }
   344 }
   329 
   345 
   330 void Console::profileEnd(const JSC::UString& title, ScriptCallStack* callStack)
   346 void Console::profileEnd(const String& title, ScriptCallStack* callStack)
   331 {
   347 {
   332     Page* page = this->page();
   348     Page* page = this->page();
   333     if (!page)
   349     if (!page)
   334         return;
       
   335 
       
   336     if (!this->page())
       
   337         return;
   350         return;
   338 
   351 
   339 #if ENABLE(INSPECTOR)
   352 #if ENABLE(INSPECTOR)
   340     InspectorController* controller = page->inspectorController();
   353     InspectorController* controller = page->inspectorController();
   341     if (!controller->profilerEnabled())
   354     if (!controller->profilerEnabled())
   342         return;
   355         return;
   343 #endif
   356 #endif
   344 
   357 
   345     RefPtr<JSC::Profile> profile = JSC::Profiler::profiler()->stopProfiling(callStack->state(), title);
   358     RefPtr<ScriptProfile> profile = ScriptProfiler::stop(callStack->state(), title);
   346     if (!profile)
   359     if (!profile)
   347         return;
   360         return;
   348 
   361 
   349     m_profiles.append(profile);
   362     m_profiles.append(profile);
   350 
   363