2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
34 #if ENABLE(WEB_TIMING)
36 #include "DOMWindowProperty.h"
37 #include "EventTarget.h"
38 #include "MemoryInfo.h"
39 #include "PerformanceEntryList.h"
40 #include "PerformanceNavigation.h"
41 #include "PerformanceTiming.h"
42 #include <wtf/PassRefPtr.h>
43 #include <wtf/RefCounted.h>
44 #include <wtf/RefPtr.h>
45 #include <wtf/text/WTFString.h>
50 class ResourceRequest;
51 class ResourceResponse;
53 class Performance : public RefCounted<Performance>, public DOMWindowProperty, public EventTarget {
55 static PassRefPtr<Performance> create(Frame* frame) { return adoptRef(new Performance(frame)); }
58 virtual const AtomicString& interfaceName() const;
59 virtual ScriptExecutionContext* scriptExecutionContext() const;
61 PassRefPtr<MemoryInfo> memory() const;
62 PerformanceNavigation* navigation() const;
63 PerformanceTiming* timing() const;
64 double webkitNow() const;
66 #if ENABLE(PERFORMANCE_TIMELINE)
67 PassRefPtr<PerformanceEntryList> webkitGetEntries() const;
68 PassRefPtr<PerformanceEntryList> webkitGetEntriesByType(const String& entryType);
69 PassRefPtr<PerformanceEntryList> webkitGetEntriesByName(const String& name, const String& entryType);
72 #if ENABLE(RESOURCE_TIMING)
73 void webkitClearResourceTimings();
74 void webkitSetResourceTimingBufferSize(unsigned int);
76 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull);
78 void addResourceTiming(const ResourceRequest&, const ResourceResponse&, double finishTime, Document*);
81 using RefCounted<Performance>::ref;
82 using RefCounted<Performance>::deref;
85 explicit Performance(Frame*);
87 virtual void refEventTarget() { ref(); }
88 virtual void derefEventTarget() { deref(); }
89 virtual EventTargetData* eventTargetData();
90 virtual EventTargetData* ensureEventTargetData();
92 EventTargetData m_eventTargetData;
94 mutable RefPtr<PerformanceNavigation> m_navigation;
95 mutable RefPtr<PerformanceTiming> m_timing;
97 #if ENABLE(RESOURCE_TIMING)
98 Vector<RefPtr<PerformanceEntry> > m_resourceTimingBuffer;
104 #endif // ENABLE(WEB_TIMING)
106 #endif // Performance_h