| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/inspector/InspectorInstrumentation.h" | 31 #include "core/probe/CoreProbes.h" |
| 32 | 32 |
| 33 #include "core/InspectorInstrumentationAgents.h" | 33 #include "core/CoreProbeSink.h" |
| 34 #include "core/events/Event.h" | 34 #include "core/events/Event.h" |
| 35 #include "core/events/EventTarget.h" | 35 #include "core/events/EventTarget.h" |
| 36 #include "core/frame/FrameHost.h" | 36 #include "core/frame/FrameHost.h" |
| 37 #include "core/inspector/InspectorCSSAgent.h" | 37 #include "core/inspector/InspectorCSSAgent.h" |
| 38 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 38 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
| 39 #include "core/inspector/InspectorNetworkAgent.h" | 39 #include "core/inspector/InspectorNetworkAgent.h" |
| 40 #include "core/inspector/InspectorPageAgent.h" | 40 #include "core/inspector/InspectorPageAgent.h" |
| 41 #include "core/inspector/InspectorSession.h" | 41 #include "core/inspector/InspectorSession.h" |
| 42 #include "core/inspector/InspectorTraceEvents.h" | 42 #include "core/inspector/InspectorTraceEvents.h" |
| 43 #include "core/inspector/MainThreadDebugger.h" | 43 #include "core/inspector/MainThreadDebugger.h" |
| 44 #include "core/inspector/ThreadDebugger.h" | 44 #include "core/inspector/ThreadDebugger.h" |
| 45 #include "core/inspector/WorkerInspectorController.h" | 45 #include "core/inspector/WorkerInspectorController.h" |
| 46 #include "core/page/Page.h" | 46 #include "core/page/Page.h" |
| 47 #include "core/workers/MainThreadWorkletGlobalScope.h" | 47 #include "core/workers/MainThreadWorkletGlobalScope.h" |
| 48 #include "core/workers/WorkerGlobalScope.h" | 48 #include "core/workers/WorkerGlobalScope.h" |
| 49 #include "core/workers/WorkerThread.h" | 49 #include "core/workers/WorkerThread.h" |
| 50 #include "platform/instrumentation/tracing/TraceEvent.h" | 50 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 51 #include "platform/loader/fetch/FetchInitiatorInfo.h" | 51 #include "platform/loader/fetch/FetchInitiatorInfo.h" |
| 52 | 52 |
| 53 namespace blink { | 53 namespace blink { |
| 54 | |
| 55 namespace probe { | 54 namespace probe { |
| 56 | 55 |
| 57 double ProbeBase::captureStartTime() const { | |
| 58 if (!m_startTime) | |
| 59 m_startTime = monotonicallyIncreasingTime(); | |
| 60 return m_startTime; | |
| 61 } | |
| 62 | |
| 63 double ProbeBase::captureEndTime() const { | |
| 64 if (!m_endTime) | |
| 65 m_endTime = monotonicallyIncreasingTime(); | |
| 66 return m_endTime; | |
| 67 } | |
| 68 | |
| 69 double ProbeBase::duration() const { | |
| 70 DCHECK(m_startTime); | |
| 71 return captureEndTime() - m_startTime; | |
| 72 } | |
| 73 | |
| 74 AsyncTask::AsyncTask(ExecutionContext* context, | 56 AsyncTask::AsyncTask(ExecutionContext* context, |
| 75 void* task, | 57 void* task, |
| 76 const char* step, | 58 const char* step, |
| 77 bool enabled) | 59 bool enabled) |
| 78 : m_debugger(enabled ? ThreadDebugger::from(toIsolate(context)) : nullptr), | 60 : m_debugger(enabled ? ThreadDebugger::from(toIsolate(context)) : nullptr), |
| 79 m_task(task), | 61 m_task(task), |
| 80 m_recurring(step) { | 62 m_recurring(step) { |
| 81 if (m_recurring) { | 63 if (m_recurring) { |
| 82 TRACE_EVENT_FLOW_STEP0("devtools.timeline.async", "AsyncTask", | 64 TRACE_EVENT_FLOW_STEP0("devtools.timeline.async", "AsyncTask", |
| 83 TRACE_ID_LOCAL(reinterpret_cast<uintptr_t>(task)), | 65 TRACE_ID_LOCAL(reinterpret_cast<uintptr_t>(task)), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 133 } |
| 152 | 134 |
| 153 void continueWithPolicyIgnore(LocalFrame* frame, | 135 void continueWithPolicyIgnore(LocalFrame* frame, |
| 154 DocumentLoader* loader, | 136 DocumentLoader* loader, |
| 155 unsigned long identifier, | 137 unsigned long identifier, |
| 156 const ResourceResponse& r, | 138 const ResourceResponse& r, |
| 157 Resource* resource) { | 139 Resource* resource) { |
| 158 didReceiveResourceResponseButCanceled(frame, loader, identifier, r, resource); | 140 didReceiveResourceResponseButCanceled(frame, loader, identifier, r, resource); |
| 159 } | 141 } |
| 160 | 142 |
| 161 InspectorInstrumentationAgents* instrumentingAgentsFor( | 143 CoreProbeSink* toCoreProbeSink(WorkerGlobalScope* workerGlobalScope) { |
| 162 WorkerGlobalScope* workerGlobalScope) { | |
| 163 if (!workerGlobalScope) | 144 if (!workerGlobalScope) |
| 164 return nullptr; | 145 return nullptr; |
| 165 if (WorkerInspectorController* controller = | 146 if (WorkerInspectorController* controller = |
| 166 workerGlobalScope->thread()->workerInspectorController()) | 147 workerGlobalScope->thread()->workerInspectorController()) |
| 167 return controller->instrumentingAgents(); | 148 return controller->instrumentingAgents(); |
| 168 return nullptr; | 149 return nullptr; |
| 169 } | 150 } |
| 170 | 151 |
| 171 InspectorInstrumentationAgents* instrumentingAgentsForNonDocumentContext( | 152 CoreProbeSink* toCoreProbeSinkForNonDocumentContext(ExecutionContext* context) { |
| 172 ExecutionContext* context) { | |
| 173 if (context->isWorkerGlobalScope()) | 153 if (context->isWorkerGlobalScope()) |
| 174 return instrumentingAgentsFor(toWorkerGlobalScope(context)); | 154 return toCoreProbeSink(toWorkerGlobalScope(context)); |
| 175 if (context->isMainThreadWorkletGlobalScope()) | 155 if (context->isMainThreadWorkletGlobalScope()) |
| 176 return instrumentingAgentsFor( | 156 return toCoreProbeSink(toMainThreadWorkletGlobalScope(context)->frame()); |
| 177 toMainThreadWorkletGlobalScope(context)->frame()); | |
| 178 return nullptr; | 157 return nullptr; |
| 179 } | 158 } |
| 180 | 159 |
| 181 } // namespace InspectorInstrumentation | 160 } // namespace probe |
| 182 | |
| 183 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |