1 /* 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef InspectorConsoleInstrumentation_h 32 #define InspectorConsoleInstrumentation_h 33 34 #include "InspectorInstrumentation.h" 35 #include "ScriptArguments.h" 36 #include "ScriptCallStack.h" 37 #include <wtf/PassRefPtr.h> 38 39 namespace WebCore { 40 41 inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) 42 { 43 #if ENABLE(INSPECTOR) 44 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 45 addMessageToConsoleImpl(inspectorAgent, source, type, level, message, arguments, callStack); 46 #endif 47 } 48 49 inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) 50 { 51 #if ENABLE(INSPECTOR) 52 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 53 addMessageToConsoleImpl(inspectorAgent, source, type, level, message, lineNumber, sourceID); 54 #endif 55 } 56 57 inline void InspectorInstrumentation::consoleCount(Page* page, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> stack) 58 { 59 #if ENABLE(INSPECTOR) 60 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 61 consoleCountImpl(inspectorAgent, arguments, stack); 62 #endif 63 } 64 65 inline void InspectorInstrumentation::startConsoleTiming(Page* page, const String& title) 66 { 67 #if ENABLE(INSPECTOR) 68 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 69 startConsoleTimingImpl(inspectorAgent, title); 70 #endif 71 } 72 73 inline void InspectorInstrumentation::stopConsoleTiming(Page* page, const String& title, PassRefPtr<ScriptCallStack> stack) 74 { 75 #if ENABLE(INSPECTOR) 76 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 77 stopConsoleTimingImpl(inspectorAgent, title, stack); 78 #endif 79 } 80 81 inline void InspectorInstrumentation::consoleMarkTimeline(Page* page, PassRefPtr<ScriptArguments> arguments) 82 { 83 #if ENABLE(INSPECTOR) 84 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForPage(page)) 85 consoleMarkTimelineImpl(inspectorAgent, arguments); 86 #endif 87 } 88 89 #if ENABLE(JAVASCRIPT_DEBUGGER) 90 inline void InspectorInstrumentation::addStartProfilingMessageToConsole(Page* page, const String& title, unsigned lineNumber, const String& sourceURL) 91 { 92 #if ENABLE(INSPECTOR) 93 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 94 addStartProfilingMessageToConsoleImpl(inspectorAgent, title, lineNumber, sourceURL); 95 #endif 96 } 97 98 inline void InspectorInstrumentation::addProfile(Page* page, RefPtr<ScriptProfile> profile, PassRefPtr<ScriptCallStack> callStack) 99 { 100 #if ENABLE(INSPECTOR) 101 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 102 addProfileImpl(inspectorAgent, profile, callStack); 103 #endif 104 } 105 106 inline bool InspectorInstrumentation::profilerEnabled(Page* page) 107 { 108 #if ENABLE(INSPECTOR) 109 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 110 return profilerEnabledImpl(inspectorAgent); 111 #endif 112 return false; 113 } 114 115 inline String InspectorInstrumentation::getCurrentUserInitiatedProfileName(Page* page, bool incrementProfileNumber) 116 { 117 #if ENABLE(INSPECTOR) 118 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) 119 return InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(inspectorAgent, incrementProfileNumber); 120 #endif 121 return ""; 122 } 123 #endif 124 125 } // namespace WebCore 126 127 #endif // !defined(InspectorConsoleInstrumentation_h) 128