Home | History | Annotate | Download | only in inspector
      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 #ifndef TimelineRecordFactory_h
     32 #define TimelineRecordFactory_h
     33 
     34 #include "core/platform/JSONValues.h"
     35 #include "weborigin/KURL.h"
     36 #include "wtf/Forward.h"
     37 #include "wtf/text/WTFString.h"
     38 
     39 namespace WebCore {
     40 
     41     class Event;
     42     class FloatQuad;
     43     class InspectorFrontend;
     44     class IntRect;
     45     class ResourceRequest;
     46     class ResourceResponse;
     47 
     48     class TimelineRecordFactory {
     49     public:
     50         static PassRefPtr<JSONObject> createGenericRecord(double startTime, int maxCallStackDepth, const String& type);
     51         static PassRefPtr<JSONObject> createBackgroundRecord(double startTime, const String& thread);
     52 
     53         static PassRefPtr<JSONObject> createGCEventData(const size_t usedHeapSizeDelta);
     54 
     55         static PassRefPtr<JSONObject> createFunctionCallData(const String& scriptName, int scriptLine);
     56 
     57         static PassRefPtr<JSONObject> createEventDispatchData(const Event&);
     58 
     59         static PassRefPtr<JSONObject> createGenericTimerData(int timerId);
     60 
     61         static PassRefPtr<JSONObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
     62 
     63         static PassRefPtr<JSONObject> createXHRReadyStateChangeData(const String& url, int readyState);
     64 
     65         static PassRefPtr<JSONObject> createXHRLoadData(const String& url);
     66 
     67         static PassRefPtr<JSONObject> createEvaluateScriptData(const String&, double lineNumber);
     68 
     69         static PassRefPtr<JSONObject> createTimeStampData(const String&);
     70 
     71         static PassRefPtr<JSONObject> createResourceSendRequestData(const String& requestId, const ResourceRequest&);
     72 
     73         static PassRefPtr<JSONObject> createScheduleResourceRequestData(const String&);
     74 
     75         static PassRefPtr<JSONObject> createResourceReceiveResponseData(const String& requestId, const ResourceResponse&);
     76 
     77         static PassRefPtr<JSONObject> createReceiveResourceData(const String& requestId, int length);
     78 
     79         static PassRefPtr<JSONObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime);
     80 
     81         static PassRefPtr<JSONObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout);
     82 
     83         static PassRefPtr<JSONObject> createDecodeImageData(const String& imageType);
     84 
     85         static PassRefPtr<JSONObject> createResizeImageData(bool shouldCache);
     86 
     87         static PassRefPtr<JSONObject> createMarkData(bool isMainFrame);
     88 
     89         static PassRefPtr<JSONObject> createParseHTMLData(unsigned startLine);
     90 
     91         static PassRefPtr<JSONObject> createAnimationFrameData(int callbackId);
     92 
     93         static PassRefPtr<JSONObject> createLayerData(long long layerRootNodeId);
     94 
     95         static PassRefPtr<JSONObject> createPaintData(const FloatQuad&, long long layerRootNodeId);
     96 
     97         static void appendLayoutRoot(JSONObject* data, const FloatQuad&, long long rootNodeId);
     98 
     99         static void appendStyleRecalcDetails(JSONObject* data, unsigned elementCount);
    100 
    101         static inline PassRefPtr<JSONObject> createWebSocketCreateData(unsigned long identifier, const KURL& url, const String& protocol)
    102         {
    103             RefPtr<JSONObject> data = JSONObject::create();
    104             data->setNumber("identifier", identifier);
    105             data->setString("url", url.string());
    106             if (!protocol.isNull())
    107                 data->setString("webSocketProtocol", protocol);
    108             return data.release();
    109         }
    110 
    111         static inline PassRefPtr<JSONObject> createGenericWebSocketData(unsigned long identifier)
    112         {
    113             RefPtr<JSONObject> data = JSONObject::create();
    114             data->setNumber("identifier", identifier);
    115             return data.release();
    116         }
    117     private:
    118         TimelineRecordFactory() { }
    119     };
    120 
    121 } // namespace WebCore
    122 
    123 #endif // !defined(TimelineRecordFactory_h)
    124