- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / inspector / InspectorInstrumentationCustomInl.h
1 /*
2 * Copyright (C) 2013 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 InspectorInstrumentationCustom_inl_h
32 #define InspectorInstrumentationCustom_inl_h
33
34 namespace WebCore {
35
36 namespace InspectorInstrumentation {
37
38 bool profilerEnabledImpl(InstrumentingAgents*);
39 bool isDebuggerPausedImpl(InstrumentingAgents*);
40 bool collectingHTMLParseErrorsImpl(InstrumentingAgents*);
41 PassOwnPtr<ScriptSourceCode> preprocessImpl(InstrumentingAgents*, Frame*, const ScriptSourceCode&);
42 String preprocessEventListenerImpl(InstrumentingAgents*, Frame*, const String& source, const String& url, const String& functionName);
43
44 bool canvasAgentEnabled(ExecutionContext*);
45 bool consoleAgentEnabled(ExecutionContext*);
46 bool timelineAgentEnabled(ExecutionContext*);
47
48 inline bool profilerEnabled(WorkerGlobalScope* scope)
49 {
50     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(scope))
51         return profilerEnabledImpl(instrumentingAgents);
52     return false;
53 }
54
55 inline bool profilerEnabled(Page* page)
56 {
57     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(page))
58         return profilerEnabledImpl(instrumentingAgents);
59     return false;
60 }
61
62 inline bool isDebuggerPaused(Frame* frame)
63 {
64     FAST_RETURN_IF_NO_FRONTENDS(false);
65     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(frame))
66         return isDebuggerPausedImpl(instrumentingAgents);
67     return false;
68 }
69
70 inline bool collectingHTMLParseErrors(Page* page)
71 {
72     FAST_RETURN_IF_NO_FRONTENDS(false);
73     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(page))
74         return collectingHTMLParseErrorsImpl(instrumentingAgents);
75     return false;
76 }
77
78 inline String preprocessEventListener(Frame* frame, const String& source, const String& url, const String& functionName)
79 {
80     FAST_RETURN_IF_NO_FRONTENDS(source);
81     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(frame))
82         return preprocessEventListenerImpl(instrumentingAgents, frame, source, url, functionName);
83     return source;
84 }
85
86 inline PassOwnPtr<ScriptSourceCode> preprocess(Frame* frame, const ScriptSourceCode& sourceCode)
87 {
88     FAST_RETURN_IF_NO_FRONTENDS(PassOwnPtr<ScriptSourceCode>());
89     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(frame))
90         return preprocessImpl(instrumentingAgents, frame, sourceCode);
91     return PassOwnPtr<ScriptSourceCode>();
92 }
93
94 } // namespace InspectorInstrumentation
95
96 } // namespace WebCore
97
98 #endif // !defined(InspectorInstrumentationCustom_inl_h)