InspectorConsoleInstrumentation.h 8.9 KB

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