| 1 | /* |
| 2 | * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 | * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are |
| 7 | * met: |
| 8 | * |
| 9 | * * Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above |
| 12 | * copyright notice, this list of conditions and the following disclaimer |
| 13 | * in the documentation and/or other materials provided with the |
| 14 | * distribution. |
| 15 | * * Neither the name of Google Inc. nor the names of its |
| 16 | * contributors may be used to endorse or promote products derived from |
| 17 | * this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | #pragma once |
| 33 | |
| 34 | #include <JavaScriptCore/InspectorEnvironment.h> |
| 35 | #include <wtf/FastMalloc.h> |
| 36 | #include <wtf/Noncopyable.h> |
| 37 | #include <wtf/RefCounted.h> |
| 38 | |
| 39 | namespace Inspector { |
| 40 | class InspectorAgent; |
| 41 | class InspectorDebuggerAgent; |
| 42 | class InspectorScriptProfilerAgent; |
| 43 | } |
| 44 | |
| 45 | namespace WebCore { |
| 46 | |
| 47 | class InspectorApplicationCacheAgent; |
| 48 | class InspectorCPUProfilerAgent; |
| 49 | class InspectorCSSAgent; |
| 50 | class InspectorCanvasAgent; |
| 51 | class InspectorDOMAgent; |
| 52 | class InspectorDOMDebuggerAgent; |
| 53 | class InspectorDOMStorageAgent; |
| 54 | class InspectorDatabaseAgent; |
| 55 | class InspectorLayerTreeAgent; |
| 56 | class InspectorMemoryAgent; |
| 57 | class InspectorNetworkAgent; |
| 58 | class InspectorPageAgent; |
| 59 | class InspectorTimelineAgent; |
| 60 | class InspectorWorkerAgent; |
| 61 | class Page; |
| 62 | class PageDebuggerAgent; |
| 63 | class PageHeapAgent; |
| 64 | class ; |
| 65 | class WebConsoleAgent; |
| 66 | |
| 67 | class InstrumentingAgents : public RefCounted<InstrumentingAgents> { |
| 68 | WTF_MAKE_NONCOPYABLE(InstrumentingAgents); |
| 69 | WTF_MAKE_FAST_ALLOCATED; |
| 70 | public: |
| 71 | // FIXME: InstrumentingAgents could be uniquely owned by InspectorController if instrumentation |
| 72 | // cookies kept only a weak reference to InstrumentingAgents. Then, reset() would be unnecessary. |
| 73 | static Ref<InstrumentingAgents> create(Inspector::InspectorEnvironment& environment) |
| 74 | { |
| 75 | return adoptRef(*new InstrumentingAgents(environment)); |
| 76 | } |
| 77 | ~InstrumentingAgents() = default; |
| 78 | void reset(); |
| 79 | |
| 80 | Inspector::InspectorEnvironment& inspectorEnvironment() const { return m_environment; } |
| 81 | |
| 82 | Inspector::InspectorAgent* inspectorAgent() const { return m_inspectorAgent; } |
| 83 | void setInspectorAgent(Inspector::InspectorAgent* agent) { m_inspectorAgent = agent; } |
| 84 | |
| 85 | InspectorPageAgent* inspectorPageAgent() const { return m_inspectorPageAgent; } |
| 86 | void setInspectorPageAgent(InspectorPageAgent* agent) { m_inspectorPageAgent = agent; } |
| 87 | |
| 88 | InspectorCanvasAgent* inspectorCanvasAgent() const { return m_inspectorCanvasAgent; } |
| 89 | void setInspectorCanvasAgent(InspectorCanvasAgent* agent) { m_inspectorCanvasAgent = agent; } |
| 90 | |
| 91 | InspectorCSSAgent* inspectorCSSAgent() const { return m_inspectorCSSAgent; } |
| 92 | void setInspectorCSSAgent(InspectorCSSAgent* agent) { m_inspectorCSSAgent = agent; } |
| 93 | |
| 94 | WebConsoleAgent* webConsoleAgent() const { return m_webConsoleAgent; } |
| 95 | void setWebConsoleAgent(WebConsoleAgent* agent) { m_webConsoleAgent = agent; } |
| 96 | |
| 97 | InspectorDOMAgent* inspectorDOMAgent() const { return m_inspectorDOMAgent; } |
| 98 | void setInspectorDOMAgent(InspectorDOMAgent* agent) { m_inspectorDOMAgent = agent; } |
| 99 | |
| 100 | InspectorNetworkAgent* inspectorNetworkAgent() const { return m_inspectorNetworkAgent; } |
| 101 | void setInspectorNetworkAgent(InspectorNetworkAgent* agent) { m_inspectorNetworkAgent = agent; } |
| 102 | |
| 103 | PageRuntimeAgent* () const { return m_pageRuntimeAgent; } |
| 104 | void (PageRuntimeAgent* agent) { m_pageRuntimeAgent = agent; } |
| 105 | |
| 106 | Inspector::InspectorScriptProfilerAgent* inspectorScriptProfilerAgent() const { return m_inspectorScriptProfilerAgent; } |
| 107 | void setInspectorScriptProfilerAgent(Inspector::InspectorScriptProfilerAgent* agent) { m_inspectorScriptProfilerAgent = agent; } |
| 108 | |
| 109 | InspectorTimelineAgent* inspectorTimelineAgent() const { return m_inspectorTimelineAgent; } |
| 110 | void setInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_inspectorTimelineAgent = agent; } |
| 111 | |
| 112 | InspectorTimelineAgent* persistentInspectorTimelineAgent() const { return m_persistentInspectorTimelineAgent; } |
| 113 | void setPersistentInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_persistentInspectorTimelineAgent = agent; } |
| 114 | |
| 115 | InspectorDOMStorageAgent* inspectorDOMStorageAgent() const { return m_inspectorDOMStorageAgent; } |
| 116 | void setInspectorDOMStorageAgent(InspectorDOMStorageAgent* agent) { m_inspectorDOMStorageAgent = agent; } |
| 117 | |
| 118 | #if ENABLE(RESOURCE_USAGE) |
| 119 | InspectorCPUProfilerAgent* inspectorCPUProfilerAgent() const { return m_inspectorCPUProfilerAgent; } |
| 120 | void setInspectorCPUProfilerAgent(InspectorCPUProfilerAgent* agent) { m_inspectorCPUProfilerAgent = agent; } |
| 121 | |
| 122 | InspectorMemoryAgent* inspectorMemoryAgent() const { return m_inspectorMemoryAgent; } |
| 123 | void setInspectorMemoryAgent(InspectorMemoryAgent* agent) { m_inspectorMemoryAgent = agent; } |
| 124 | #endif |
| 125 | |
| 126 | InspectorDatabaseAgent* inspectorDatabaseAgent() const { return m_inspectorDatabaseAgent; } |
| 127 | void setInspectorDatabaseAgent(InspectorDatabaseAgent* agent) { m_inspectorDatabaseAgent = agent; } |
| 128 | |
| 129 | InspectorApplicationCacheAgent* inspectorApplicationCacheAgent() const { return m_inspectorApplicationCacheAgent; } |
| 130 | void setInspectorApplicationCacheAgent(InspectorApplicationCacheAgent* agent) { m_inspectorApplicationCacheAgent = agent; } |
| 131 | |
| 132 | Inspector::InspectorDebuggerAgent* inspectorDebuggerAgent() const { return m_inspectorDebuggerAgent; } |
| 133 | void setInspectorDebuggerAgent(Inspector::InspectorDebuggerAgent* agent) { m_inspectorDebuggerAgent = agent; } |
| 134 | |
| 135 | PageDebuggerAgent* pageDebuggerAgent() const { return m_pageDebuggerAgent; } |
| 136 | void setPageDebuggerAgent(PageDebuggerAgent* agent) { m_pageDebuggerAgent = agent; } |
| 137 | |
| 138 | PageHeapAgent* pageHeapAgent() const { return m_pageHeapAgent; } |
| 139 | void setPageHeapAgent(PageHeapAgent* agent) { m_pageHeapAgent = agent; } |
| 140 | |
| 141 | InspectorDOMDebuggerAgent* inspectorDOMDebuggerAgent() const { return m_inspectorDOMDebuggerAgent; } |
| 142 | void setInspectorDOMDebuggerAgent(InspectorDOMDebuggerAgent* agent) { m_inspectorDOMDebuggerAgent = agent; } |
| 143 | |
| 144 | InspectorLayerTreeAgent* inspectorLayerTreeAgent() const { return m_inspectorLayerTreeAgent; } |
| 145 | void setInspectorLayerTreeAgent(InspectorLayerTreeAgent* agent) { m_inspectorLayerTreeAgent = agent; } |
| 146 | |
| 147 | InspectorWorkerAgent* inspectorWorkerAgent() const { return m_inspectorWorkerAgent; } |
| 148 | void setInspectorWorkerAgent(InspectorWorkerAgent* agent) { m_inspectorWorkerAgent = agent; } |
| 149 | |
| 150 | private: |
| 151 | InstrumentingAgents(Inspector::InspectorEnvironment&); |
| 152 | |
| 153 | Inspector::InspectorEnvironment& m_environment; |
| 154 | |
| 155 | Inspector::InspectorAgent* m_inspectorAgent { nullptr }; |
| 156 | InspectorPageAgent* m_inspectorPageAgent { nullptr }; |
| 157 | InspectorCSSAgent* m_inspectorCSSAgent { nullptr }; |
| 158 | InspectorLayerTreeAgent* m_inspectorLayerTreeAgent { nullptr }; |
| 159 | InspectorWorkerAgent* m_inspectorWorkerAgent { nullptr }; |
| 160 | WebConsoleAgent* m_webConsoleAgent { nullptr }; |
| 161 | InspectorDOMAgent* m_inspectorDOMAgent { nullptr }; |
| 162 | InspectorNetworkAgent* m_inspectorNetworkAgent { nullptr }; |
| 163 | PageRuntimeAgent* { nullptr }; |
| 164 | Inspector::InspectorScriptProfilerAgent* m_inspectorScriptProfilerAgent { nullptr }; |
| 165 | InspectorTimelineAgent* m_inspectorTimelineAgent { nullptr }; |
| 166 | InspectorTimelineAgent* m_persistentInspectorTimelineAgent { nullptr }; |
| 167 | InspectorDOMStorageAgent* m_inspectorDOMStorageAgent { nullptr }; |
| 168 | #if ENABLE(RESOURCE_USAGE) |
| 169 | InspectorCPUProfilerAgent* m_inspectorCPUProfilerAgent { nullptr }; |
| 170 | InspectorMemoryAgent* m_inspectorMemoryAgent { nullptr }; |
| 171 | #endif |
| 172 | InspectorDatabaseAgent* m_inspectorDatabaseAgent { nullptr }; |
| 173 | InspectorApplicationCacheAgent* m_inspectorApplicationCacheAgent { nullptr }; |
| 174 | Inspector::InspectorDebuggerAgent* m_inspectorDebuggerAgent { nullptr }; |
| 175 | PageDebuggerAgent* m_pageDebuggerAgent { nullptr }; |
| 176 | PageHeapAgent* m_pageHeapAgent { nullptr }; |
| 177 | InspectorDOMDebuggerAgent* m_inspectorDOMDebuggerAgent { nullptr }; |
| 178 | InspectorCanvasAgent* m_inspectorCanvasAgent { nullptr }; |
| 179 | }; |
| 180 | |
| 181 | } // namespace WebCore |
| 182 | |