This source file includes following definitions.
- createGenericRecord
- createBackgroundRecord
- createGCEventData
- createFunctionCallData
- createEventDispatchData
- createGenericTimerData
- createTimerInstallData
- createXHRReadyStateChangeData
- createXHRLoadData
- createEvaluateScriptData
- createConsoleTimeData
- createTimeStampData
- createScheduleResourceRequestData
- createResourceSendRequestData
- createResourceReceiveResponseData
- createResourceFinishData
- createReceiveResourceData
- createLayoutData
- createDecodeImageData
- createResizeImageData
- createMarkData
- createParseHTMLData
- createAnimationFrameData
- createGPUTaskData
- createQuad
- createNodeData
- createLayerData
- createLayerTreeData
- setNodeData
- setLayerData
- setPaintData
- createFrameData
- setLayoutRoot
- setStyleRecalcDetails
- setImageDetails
- createEmbedderCallbackData
- type
#include "config.h"
#include "core/inspector/TimelineRecordFactory.h"
#include "bindings/v8/ScriptCallStackFactory.h"
#include "core/events/Event.h"
#include "core/inspector/ScriptCallStack.h"
#include "platform/geometry/FloatQuad.h"
#include "platform/geometry/LayoutRect.h"
#include "platform/network/ResourceRequest.h"
#include "platform/network/ResourceResponse.h"
#include "wtf/CurrentTime.h"
namespace WebCore {
using TypeBuilder::Timeline::TimelineEvent;
PassRefPtr<TimelineEvent> TimelineRecordFactory::createGenericRecord(double startTime, int maxCallStackDepth, const String& type, PassRefPtr<JSONObject> data)
{
ASSERT(data.get());
RefPtr<TimelineEvent> record = TimelineEvent::create()
.setType(type)
.setData(data)
.setStartTime(startTime);
if (maxCallStackDepth) {
RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(maxCallStackDepth, true);
if (stackTrace && stackTrace->size())
record->setStackTrace(stackTrace->buildInspectorArray());
}
return record.release();
}
PassRefPtr<TimelineEvent> TimelineRecordFactory::createBackgroundRecord(double startTime, const String& threadName, const String& type, PassRefPtr<JSONObject> data)
{
ASSERT(data.get());
RefPtr<TimelineEvent> record = TimelineEvent::create()
.setType(type)
.setData(data)
.setStartTime(startTime);
record->setThread(threadName);
return record.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createGCEventData(size_t usedHeapSizeDelta)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("usedHeapSizeDelta", usedHeapSizeDelta);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createFunctionCallData(int scriptId, const String& scriptName, int scriptLine)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("scriptId", String::number(scriptId));
data->setString("scriptName", scriptName);
data->setNumber("scriptLine", scriptLine);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createEventDispatchData(const Event& event)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("type", event.type().string());
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createGenericTimerData(int timerId)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("timerId", timerId);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createTimerInstallData(int timerId, int timeout, bool singleShot)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("timerId", timerId);
data->setNumber("timeout", timeout);
data->setBoolean("singleShot", singleShot);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createXHRReadyStateChangeData(const String& url, int readyState)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
data->setNumber("readyState", readyState);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createXHRLoadData(const String& url)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createEvaluateScriptData(const String& url, double lineNumber)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
data->setNumber("lineNumber", lineNumber);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createConsoleTimeData(const String& message)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("message", message);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createTimeStampData(const String& message)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("message", message);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createScheduleResourceRequestData(const String& url)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createResourceSendRequestData(const String& requestId, const ResourceRequest& request)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setString("url", request.url().string());
data->setString("requestMethod", request.httpMethod());
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createResourceReceiveResponseData(const String& requestId, const ResourceResponse& response)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setNumber("statusCode", response.httpStatusCode());
data->setString("mimeType", response.mimeType());
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createResourceFinishData(const String& requestId, bool didFail, double finishTime)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setBoolean("didFail", didFail);
if (finishTime)
data->setNumber("networkTime", finishTime);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createReceiveResourceData(const String& requestId, int length)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setNumber("encodedDataLength", length);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("dirtyObjects", dirtyObjects);
data->setNumber("totalObjects", totalObjects);
data->setBoolean("partialLayout", partialLayout);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("imageType", imageType);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createResizeImageData(bool shouldCache)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setBoolean("cached", shouldCache);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createMarkData(bool isMainFrame)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setBoolean("isMainFrame", isMainFrame);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createParseHTMLData(unsigned startLine)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("startLine", startLine);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createAnimationFrameData(int callbackId)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("id", callbackId);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createGPUTaskData(bool foreign)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setBoolean("foreign", foreign);
return data.release();
}
static PassRefPtr<JSONArray> createQuad(const FloatQuad& quad)
{
RefPtr<JSONArray> array = JSONArray::create();
array->pushNumber(quad.p1().x());
array->pushNumber(quad.p1().y());
array->pushNumber(quad.p2().x());
array->pushNumber(quad.p2().y());
array->pushNumber(quad.p3().x());
array->pushNumber(quad.p3().y());
array->pushNumber(quad.p4().x());
array->pushNumber(quad.p4().y());
return array.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createNodeData(long long nodeId)
{
RefPtr<JSONObject> data = JSONObject::create();
setNodeData(data.get(), nodeId);
return data.release();
}
PassRefPtr<JSONObject> TimelineRecordFactory::createLayerData(long long rootNodeId)
{
return createNodeData(rootNodeId);
}
PassRefPtr<JSONObject> TimelineRecordFactory::createLayerTreeData(PassRefPtr<JSONValue> layerTree)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setValue("layerTree", layerTree);
return data.release();
}
void TimelineRecordFactory::setNodeData(JSONObject* data, long long nodeId)
{
if (nodeId)
data->setNumber("rootNode", nodeId);
}
void TimelineRecordFactory::setLayerData(JSONObject* data, long long rootNodeId)
{
setNodeData(data, rootNodeId);
}
void TimelineRecordFactory::setPaintData(JSONObject* data, const FloatQuad& quad, long long layerRootNodeId, int graphicsLayerId)
{
setLayerData(data, layerRootNodeId);
data->setArray("clip", createQuad(quad));
data->setNumber("layerId", graphicsLayerId);
}
PassRefPtr<JSONObject> TimelineRecordFactory::createFrameData(int frameId)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("id", frameId);
return data.release();
}
void TimelineRecordFactory::setLayoutRoot(JSONObject* data, const FloatQuad& quad, long long rootNodeId)
{
data->setArray("root", createQuad(quad));
if (rootNodeId)
data->setNumber("rootNode", rootNodeId);
}
void TimelineRecordFactory::setStyleRecalcDetails(JSONObject* data, unsigned elementCount)
{
data->setNumber("elementCount", elementCount);
}
void TimelineRecordFactory::setImageDetails(JSONObject* data, long long imageElementId, const String& url)
{
if (imageElementId)
data->setNumber("elementId", imageElementId);
if (!url.isEmpty())
data->setString("url", url);
}
PassRefPtr<JSONObject> TimelineRecordFactory::createEmbedderCallbackData(const String& callbackName)
{
RefPtr<JSONObject> data = JSONObject::create();
data->setString("callbackName", callbackName);
return data.release();
}
String TimelineRecordFactory::type(TypeBuilder::Timeline::TimelineEvent* event)
{
String type;
event->type(&type);
return type;
}
}