This source file includes following definitions.
- m_timelineAgentId
- m_timelineAgentId
- m_timelineAgentId
- isDebuggerPausedImpl
- didReceiveResourceResponseButCanceledImpl
- continueAfterXFrameOptionsDeniedImpl
- continueWithPolicyDownloadImpl
- continueWithPolicyIgnoreImpl
- willDestroyResourceImpl
- collectingHTMLParseErrorsImpl
- preprocessImpl
- preprocessEventListenerImpl
- canvasAgentEnabled
- consoleAgentEnabled
- timelineAgentEnabled
- registerInstrumentingAgents
- unregisterInstrumentingAgents
- retrieveTimelineAgent
- instrumentingAgentsFor
- instrumentingAgentsFor
- instrumentingAgentsFor
- instrumentingAgentsFor
- instrumentingAgentsForNonDocumentContext
- instrumentationForPage
- instrumentationForWorkerGlobalScope
#include "config.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/events/EventTarget.h"
#include "core/fetch/FetchInitiatorInfo.h"
#include "core/inspector/InspectorCSSAgent.h"
#include "core/inspector/InspectorConsoleAgent.h"
#include "core/inspector/InspectorController.h"
#include "core/inspector/InspectorDebuggerAgent.h"
#include "core/inspector/InspectorInspectorAgent.h"
#include "core/inspector/InspectorProfilerAgent.h"
#include "core/inspector/InspectorResourceAgent.h"
#include "core/inspector/InspectorTimelineAgent.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/inspector/WorkerInspectorController.h"
#include "core/workers/WorkerGlobalScope.h"
namespace WebCore {
namespace {
static HashSet<InstrumentingAgents*>* instrumentingAgentsSet = 0;
}
namespace InspectorInstrumentation {
int FrontendCounter::s_frontendCounter = 0;
}
InspectorInstrumentationCookie::InspectorInstrumentationCookie()
: m_instrumentingAgents(nullptr)
, m_timelineAgentId(0)
{
}
InspectorInstrumentationCookie::InspectorInstrumentationCookie(InstrumentingAgents* agents, int timelineAgentId)
: m_instrumentingAgents(agents)
, m_timelineAgentId(timelineAgentId)
{
}
InspectorInstrumentationCookie::InspectorInstrumentationCookie(const InspectorInstrumentationCookie& other)
: m_instrumentingAgents(other.m_instrumentingAgents)
, m_timelineAgentId(other.m_timelineAgentId)
{
}
InspectorInstrumentationCookie& InspectorInstrumentationCookie::operator=(const InspectorInstrumentationCookie& other)
{
if (this != &other) {
m_instrumentingAgents = other.m_instrumentingAgents;
m_timelineAgentId = other.m_timelineAgentId;
}
return *this;
}
InspectorInstrumentationCookie::~InspectorInstrumentationCookie()
{
}
namespace InspectorInstrumentation {
bool isDebuggerPausedImpl(InstrumentingAgents* instrumentingAgents)
{
if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
return debuggerAgent->isPaused();
return false;
}
void didReceiveResourceResponseButCanceledImpl(LocalFrame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
{
didReceiveResourceResponse(frame, identifier, loader, r, 0);
}
void continueAfterXFrameOptionsDeniedImpl(LocalFrame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
{
didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
}
void continueWithPolicyDownloadImpl(LocalFrame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
{
didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
}
void continueWithPolicyIgnoreImpl(LocalFrame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
{
didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
}
void willDestroyResourceImpl(Resource* cachedResource)
{
if (!instrumentingAgentsSet)
return;
HashSet<InstrumentingAgents*>::iterator end = instrumentingAgentsSet->end();
for (HashSet<InstrumentingAgents*>::iterator it = instrumentingAgentsSet->begin(); it != end; ++it) {
InstrumentingAgents* instrumentingAgents = *it;
if (InspectorResourceAgent* inspectorResourceAgent = instrumentingAgents->inspectorResourceAgent())
inspectorResourceAgent->willDestroyResource(cachedResource);
}
}
bool collectingHTMLParseErrorsImpl(InstrumentingAgents* instrumentingAgents)
{
if (InspectorInspectorAgent* inspectorAgent = instrumentingAgents->inspectorInspectorAgent())
return inspectorAgent->hasFrontend();
return false;
}
PassOwnPtr<ScriptSourceCode> preprocessImpl(InstrumentingAgents* instrumentingAgents, LocalFrame* frame, const ScriptSourceCode& sourceCode)
{
if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
return debuggerAgent->preprocess(frame, sourceCode);
return PassOwnPtr<ScriptSourceCode>();
}
String preprocessEventListenerImpl(InstrumentingAgents* instrumentingAgents, LocalFrame* frame, const String& source, const String& url, const String& functionName)
{
if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
return debuggerAgent->preprocessEventListener(frame, source, url, functionName);
return source;
}
bool canvasAgentEnabled(ExecutionContext* executionContext)
{
InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(executionContext);
return instrumentingAgents && instrumentingAgents->inspectorCanvasAgent();
}
bool consoleAgentEnabled(ExecutionContext* executionContext)
{
InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(executionContext);
InspectorConsoleAgent* consoleAgent = instrumentingAgents ? instrumentingAgents->inspectorConsoleAgent() : 0;
return consoleAgent && consoleAgent->enabled();
}
bool timelineAgentEnabled(ExecutionContext* executionContext)
{
InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor(executionContext);
return instrumentingAgents && instrumentingAgents->inspectorTimelineAgent();
}
void registerInstrumentingAgents(InstrumentingAgents* instrumentingAgents)
{
if (!instrumentingAgentsSet)
instrumentingAgentsSet = new HashSet<InstrumentingAgents*>();
instrumentingAgentsSet->add(instrumentingAgents);
}
void unregisterInstrumentingAgents(InstrumentingAgents* instrumentingAgents)
{
if (!instrumentingAgentsSet)
return;
instrumentingAgentsSet->remove(instrumentingAgents);
if (instrumentingAgentsSet->isEmpty()) {
delete instrumentingAgentsSet;
instrumentingAgentsSet = 0;
}
}
InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie& cookie)
{
if (!cookie.instrumentingAgents())
return 0;
InspectorTimelineAgent* timelineAgent = cookie.instrumentingAgents()->inspectorTimelineAgent();
if (timelineAgent && cookie.hasMatchingTimelineAgentId(timelineAgent->id()))
return timelineAgent;
return 0;
}
InstrumentingAgents* instrumentingAgentsFor(Page* page)
{
if (!page)
return 0;
return instrumentationForPage(page);
}
InstrumentingAgents* instrumentingAgentsFor(EventTarget* eventTarget)
{
if (!eventTarget)
return 0;
return instrumentingAgentsFor(eventTarget->executionContext());
}
InstrumentingAgents* instrumentingAgentsFor(RenderObject* renderer)
{
return instrumentingAgentsFor(renderer->frame());
}
InstrumentingAgents* instrumentingAgentsFor(WorkerGlobalScope* workerGlobalScope)
{
if (!workerGlobalScope)
return 0;
return instrumentationForWorkerGlobalScope(workerGlobalScope);
}
InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ExecutionContext* context)
{
if (context->isWorkerGlobalScope())
return instrumentationForWorkerGlobalScope(toWorkerGlobalScope(context));
return 0;
}
}
namespace InstrumentationEvents {
const char PaintSetup[] = "PaintSetup";
const char RasterTask[] = "RasterTask";
const char Paint[] = "Paint";
const char Layer[] = "Layer";
const char RequestMainThreadFrame[] = "RequestMainThreadFrame";
const char BeginFrame[] = "BeginFrame";
const char ActivateLayerTree[] = "ActivateLayerTree";
const char DrawFrame[] = "DrawFrame";
const char EmbedderCallback[] = "EmbedderCallback";
};
namespace InstrumentationEventArguments {
const char FrameId[] = "frameId";
const char LayerId[] = "layerId";
const char LayerTreeId[] = "layerTreeId";
const char PageId[] = "pageId";
const char CallbackName[] = "callbackName";
};
InstrumentingAgents* instrumentationForPage(Page* page)
{
ASSERT(isMainThread());
return page->inspectorController().m_instrumentingAgents.get();
}
InstrumentingAgents* instrumentationForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
{
if (WorkerInspectorController* controller = workerGlobalScope->workerInspectorController())
return controller->m_instrumentingAgents.get();
return 0;
}
}