Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceBase.h

Issue 1352523002: Use high precision timestamp for Event.timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 15 matching lines...) Expand all
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #ifndef PerformanceBase_h 32 #ifndef PerformanceBase_h
33 #define PerformanceBase_h 33 #define PerformanceBase_h
34 34
35 #include "core/CoreExport.h" 35 #include "core/CoreExport.h"
36 #include "core/dom/DOMHighResTimeStamp.h"
36 #include "core/events/EventTarget.h" 37 #include "core/events/EventTarget.h"
37 #include "core/timing/PerformanceEntry.h" 38 #include "core/timing/PerformanceEntry.h"
38 #include "platform/Timer.h" 39 #include "platform/Timer.h"
39 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
40 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
41 #include "wtf/RefPtr.h" 42 #include "wtf/RefPtr.h"
42 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 class Document; 47 class Document;
47 class ExceptionState; 48 class ExceptionState;
48 class PerformanceObserver; 49 class PerformanceObserver;
49 class PerformanceTiming; 50 class PerformanceTiming;
50 class ResourceTimingInfo; 51 class ResourceTimingInfo;
51 class UserTiming; 52 class UserTiming;
52 53
53 using PerformanceEntryVector = HeapVector<Member<PerformanceEntry>>; 54 using PerformanceEntryVector = HeapVector<Member<PerformanceEntry>>;
54 using PerformanceObservers = HeapListHashSet<Member<PerformanceObserver>>; 55 using PerformanceObservers = HeapListHashSet<Member<PerformanceObserver>>;
55 56
56 class CORE_EXPORT PerformanceBase : public RefCountedGarbageCollectedEventTarget WithInlineData<PerformanceBase> { 57 class CORE_EXPORT PerformanceBase : public RefCountedGarbageCollectedEventTarget WithInlineData<PerformanceBase> {
57 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PerformanceBase); 58 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PerformanceBase);
58 public: 59 public:
59 ~PerformanceBase() override; 60 ~PerformanceBase() override;
60 61
61 const AtomicString& interfaceName() const override; 62 const AtomicString& interfaceName() const override;
62 63
63 virtual PerformanceTiming* timing() const; 64 virtual PerformanceTiming* timing() const;
64 double now() const; 65
66 // Reduce the resolution to 5µs to prevent timing attacks. See:
67 // http://www.w3.org/TR/hr-time-2/#privacy-security
68 static double clampTimeResolution(double timeSeconds);
69
70 // Translate given platform monotonic time in seconds into a high resolution
71 // DOMHighResTimeStamp in milliseconds. The result timestamp is relative to
72 // document's time origin and has a time resolution that is safe for
73 // exposing to web.
74 DOMHighResTimeStamp monotonicTimeToDOMHighResTimeStamp(double) const;
75 DOMHighResTimeStamp now() const;
65 76
66 double timeOrigin() const { return m_timeOrigin; } 77 double timeOrigin() const { return m_timeOrigin; }
67 78
68 static double clampTimeResolution(double timeSeconds);
69
70 PerformanceEntryVector getEntries() const; 79 PerformanceEntryVector getEntries() const;
71 PerformanceEntryVector getEntriesByType(const String& entryType); 80 PerformanceEntryVector getEntriesByType(const String& entryType);
72 PerformanceEntryVector getEntriesByName(const String& name, const String& en tryType); 81 PerformanceEntryVector getEntriesByName(const String& name, const String& en tryType);
73 82
74 void clearResourceTimings(); 83 void clearResourceTimings();
75 void setResourceTimingBufferSize(unsigned); 84 void setResourceTimingBufferSize(unsigned);
76 85
77 DEFINE_ATTRIBUTE_EVENT_LISTENER(resourcetimingbufferfull); 86 DEFINE_ATTRIBUTE_EVENT_LISTENER(resourcetimingbufferfull);
78 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull); 87 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull);
79 88
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 PerformanceEntryTypeMask m_observerFilterOptions; 136 PerformanceEntryTypeMask m_observerFilterOptions;
128 PerformanceObservers m_observers; 137 PerformanceObservers m_observers;
129 PerformanceObservers m_activeObservers; 138 PerformanceObservers m_activeObservers;
130 PerformanceObservers m_suspendedObservers; 139 PerformanceObservers m_suspendedObservers;
131 Timer<PerformanceBase> m_deliverObservationsTimer; 140 Timer<PerformanceBase> m_deliverObservationsTimer;
132 }; 141 };
133 142
134 } // namespace blink 143 } // namespace blink
135 144
136 #endif // PerformanceBase_h 145 #endif // PerformanceBase_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.idl ('k') | third_party/WebKit/Source/core/timing/PerformanceBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698