1 /* 2 * Copyright (C) 2009 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 #include "config.h" 32 #include "TimelineRecordFactory.h" 33 34 #if ENABLE(INSPECTOR) 35 36 #include "Event.h" 37 #include "InspectorFrontend.h" 38 #include "IntRect.h" 39 #include "ResourceRequest.h" 40 #include "ResourceResponse.h" 41 #include "ScriptArray.h" 42 #include "ScriptObject.h" 43 44 namespace WebCore { 45 46 ScriptObject TimelineRecordFactory::createGenericRecord(InspectorFrontend* frontend, double startTime) 47 { 48 ScriptObject record = frontend->newScriptObject(); 49 record.set("startTime", startTime); 50 return record; 51 } 52 53 ScriptObject TimelineRecordFactory::createEventDispatchData(InspectorFrontend* frontend, const Event& event) 54 { 55 ScriptObject data = frontend->newScriptObject(); 56 data.set("type", event.type().string()); 57 return data; 58 } 59 60 ScriptObject TimelineRecordFactory::createGenericTimerData(InspectorFrontend* frontend, int timerId) 61 { 62 ScriptObject data = frontend->newScriptObject(); 63 data.set("timerId", timerId); 64 return data; 65 } 66 67 ScriptObject TimelineRecordFactory::createTimerInstallData(InspectorFrontend* frontend, int timerId, int timeout, bool singleShot) 68 { 69 ScriptObject data = frontend->newScriptObject(); 70 data.set("timerId", timerId); 71 data.set("timeout", timeout); 72 data.set("singleShot", singleShot); 73 return data; 74 } 75 76 ScriptObject TimelineRecordFactory::createXHRReadyStateChangeData(InspectorFrontend* frontend, const String& url, int readyState) 77 { 78 ScriptObject data = frontend->newScriptObject(); 79 data.set("url", url); 80 data.set("readyState", readyState); 81 return data; 82 } 83 84 ScriptObject TimelineRecordFactory::createXHRLoadData(InspectorFrontend* frontend, const String& url) 85 { 86 ScriptObject data = frontend->newScriptObject(); 87 data.set("url", url); 88 return data; 89 } 90 91 ScriptObject TimelineRecordFactory::createEvaluateScriptData(InspectorFrontend* frontend, const String& url, double lineNumber) 92 { 93 ScriptObject data = frontend->newScriptObject(); 94 data.set("url", url); 95 data.set("lineNumber", lineNumber); 96 return data; 97 } 98 99 ScriptObject TimelineRecordFactory::createMarkTimelineData(InspectorFrontend* frontend, const String& message) 100 { 101 ScriptObject data = frontend->newScriptObject(); 102 data.set("message", message); 103 return data; 104 } 105 106 107 ScriptObject TimelineRecordFactory::createResourceSendRequestData(InspectorFrontend* frontend, unsigned long identifier, bool isMainResource, const ResourceRequest& request) 108 { 109 ScriptObject data = frontend->newScriptObject(); 110 data.set("identifier", identifier); 111 data.set("url", request.url().string()); 112 data.set("requestMethod", request.httpMethod()); 113 data.set("isMainResource", isMainResource); 114 return data; 115 } 116 117 ScriptObject TimelineRecordFactory::createResourceReceiveResponseData(InspectorFrontend* frontend, unsigned long identifier, const ResourceResponse& response) 118 { 119 ScriptObject data = frontend->newScriptObject(); 120 data.set("identifier", identifier); 121 data.set("statusCode", response.httpStatusCode()); 122 data.set("mimeType", response.mimeType()); 123 data.set("expectedContentLength", response.expectedContentLength()); 124 return data; 125 } 126 127 ScriptObject TimelineRecordFactory::createResourceFinishData(InspectorFrontend* frontend, unsigned long identifier, bool didFail) 128 { 129 ScriptObject data = frontend->newScriptObject(); 130 data.set("identifier", identifier); 131 data.set("didFail", didFail); 132 return data; 133 } 134 135 ScriptObject TimelineRecordFactory::createPaintData(InspectorFrontend* frontend, const IntRect& rect) 136 { 137 ScriptObject data = frontend->newScriptObject(); 138 data.set("x", rect.x()); 139 data.set("y", rect.y()); 140 data.set("width", rect.width()); 141 data.set("height", rect.height()); 142 return data; 143 } 144 145 ScriptObject TimelineRecordFactory::createParseHTMLData(InspectorFrontend* frontend, unsigned int length, unsigned int startLine) 146 { 147 ScriptObject data = frontend->newScriptObject(); 148 data.set("length", length); 149 data.set("startLine", startLine); 150 return data; 151 } 152 153 } // namespace WebCore 154 155 #endif // ENABLE(INSPECTOR) 156