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 "ScriptProfile.h" 38#include <wtf/PassRefPtr.h> 39 40namespace WebCore { 41 42inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier) 43{ 44#if ENABLE(INSPECTOR) 45 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 46 addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, callStack, requestIdentifier); 47#else 48 UNUSED_PARAM(page); 49 UNUSED_PARAM(source); 50 UNUSED_PARAM(type); 51 UNUSED_PARAM(level); 52 UNUSED_PARAM(message); 53 UNUSED_PARAM(callStack); 54 UNUSED_PARAM(requestIdentifier); 55#endif 56} 57 58inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, ScriptState* state, PassRefPtr<ScriptArguments> arguments, unsigned long requestIdentifier) 59{ 60#if ENABLE(INSPECTOR) 61 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 62 addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, state, arguments, requestIdentifier); 63#else 64 UNUSED_PARAM(page); 65 UNUSED_PARAM(source); 66 UNUSED_PARAM(type); 67 UNUSED_PARAM(level); 68 UNUSED_PARAM(message); 69 UNUSED_PARAM(state); 70 UNUSED_PARAM(arguments); 71 UNUSED_PARAM(requestIdentifier); 72#endif 73} 74 75inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier) 76{ 77#if ENABLE(INSPECTOR) 78 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 79 addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, scriptId, lineNumber, columnNumber, state, requestIdentifier); 80#else 81 UNUSED_PARAM(page); 82 UNUSED_PARAM(source); 83 UNUSED_PARAM(type); 84 UNUSED_PARAM(level); 85 UNUSED_PARAM(message); 86 UNUSED_PARAM(scriptId); 87 UNUSED_PARAM(lineNumber); 88 UNUSED_PARAM(state); 89 UNUSED_PARAM(requestIdentifier); 90#endif 91} 92 93#if ENABLE(WORKERS) 94inline void InspectorInstrumentation::addMessageToConsole(WorkerContext* workerContext, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier) 95{ 96#if ENABLE(INSPECTOR) 97 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForWorkerContext(workerContext)) 98 addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, callStack, requestIdentifier); 99#else 100 UNUSED_PARAM(workerContext); 101 UNUSED_PARAM(source); 102 UNUSED_PARAM(type); 103 UNUSED_PARAM(level); 104 UNUSED_PARAM(message); 105 UNUSED_PARAM(callStack); 106 UNUSED_PARAM(requestIdentifier); 107#endif 108} 109 110inline void InspectorInstrumentation::addMessageToConsole(WorkerContext* workerContext, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier) 111{ 112#if ENABLE(INSPECTOR) 113 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForWorkerContext(workerContext)) 114 addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, scriptId, lineNumber, columnNumber, state, requestIdentifier); 115#else 116 UNUSED_PARAM(workerContext); 117 UNUSED_PARAM(source); 118 UNUSED_PARAM(type); 119 UNUSED_PARAM(level); 120 UNUSED_PARAM(message); 121 UNUSED_PARAM(scriptId); 122 UNUSED_PARAM(lineNumber); 123 UNUSED_PARAM(columnNumber); 124 UNUSED_PARAM(state); 125 UNUSED_PARAM(requestIdentifier); 126#endif 127} 128#endif 129 130inline void InspectorInstrumentation::consoleCount(Page* page, ScriptState* state, PassRefPtr<ScriptArguments> arguments) 131{ 132#if ENABLE(INSPECTOR) 133 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 134 consoleCountImpl(instrumentingAgents, state, arguments); 135#else 136 UNUSED_PARAM(page); 137 UNUSED_PARAM(state); 138 UNUSED_PARAM(arguments); 139#endif 140} 141 142inline void InspectorInstrumentation::startConsoleTiming(Frame* frame, const String& title) 143{ 144#if ENABLE(INSPECTOR) 145 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 146 startConsoleTimingImpl(instrumentingAgents, frame, title); 147#else 148 UNUSED_PARAM(frame); 149 UNUSED_PARAM(title); 150#endif 151} 152 153inline void InspectorInstrumentation::stopConsoleTiming(Frame* frame, const String& title, PassRefPtr<ScriptCallStack> stack) 154{ 155#if ENABLE(INSPECTOR) 156 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 157 stopConsoleTimingImpl(instrumentingAgents, frame, title, stack); 158#else 159 UNUSED_PARAM(frame); 160 UNUSED_PARAM(title); 161 UNUSED_PARAM(stack); 162#endif 163} 164 165inline void InspectorInstrumentation::consoleTimeStamp(Frame* frame, PassRefPtr<ScriptArguments> arguments) 166{ 167#if ENABLE(INSPECTOR) 168 FAST_RETURN_IF_NO_FRONTENDS(void()); 169 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 170 consoleTimeStampImpl(instrumentingAgents, frame, arguments); 171#else 172 UNUSED_PARAM(frame); 173 UNUSED_PARAM(arguments); 174#endif 175} 176 177#if ENABLE(JAVASCRIPT_DEBUGGER) 178inline void InspectorInstrumentation::addStartProfilingMessageToConsole(Page* page, const String& title, unsigned lineNumber, unsigned columnNumber, const String& sourceURL) 179{ 180#if ENABLE(INSPECTOR) 181 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 182 addStartProfilingMessageToConsoleImpl(instrumentingAgents, title, lineNumber, columnNumber, sourceURL); 183#else 184 UNUSED_PARAM(page); 185 UNUSED_PARAM(title); 186 UNUSED_PARAM(lineNumber); 187 UNUSED_PARAM(columnNumber); 188 UNUSED_PARAM(sourceURL); 189#endif 190} 191 192inline void InspectorInstrumentation::addProfile(Page* page, RefPtr<ScriptProfile> profile, PassRefPtr<ScriptCallStack> callStack) 193{ 194#if ENABLE(INSPECTOR) 195 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 196 addProfileImpl(instrumentingAgents, profile, callStack); 197#else 198 UNUSED_PARAM(page); 199 UNUSED_PARAM(profile); 200 UNUSED_PARAM(callStack); 201#endif 202} 203 204inline bool InspectorInstrumentation::profilerEnabled(Page* page) 205{ 206#if ENABLE(INSPECTOR) 207 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 208 return profilerEnabledImpl(instrumentingAgents); 209#else 210 UNUSED_PARAM(page); 211#endif 212 return false; 213} 214 215inline String InspectorInstrumentation::getCurrentUserInitiatedProfileName(Page* page, bool incrementProfileNumber) 216{ 217#if ENABLE(INSPECTOR) 218 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 219 return InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(instrumentingAgents, incrementProfileNumber); 220#else 221 UNUSED_PARAM(page); 222 UNUSED_PARAM(incrementProfileNumber); 223#endif 224 return ""; 225} 226#endif 227 228} // namespace WebCore 229 230#endif // !defined(InspectorConsoleInstrumentation_h) 231