60
61 Performance::~Performance()
62 {
63 }
64
65 void Performance::contextDestroyed()
66 {
67 m_performanceTimelineTaskQueue.close();
68
69 ContextDestructionObserver::contextDestroyed();
70 }
71
72 double Performance::now() const
73 {
74 Seconds now = MonotonicTime::now() - m_timeOrigin;
75 return reduceTimeResolution(now).milliseconds();
76 }
77
78 Seconds Performance::reduceTimeResolution(Seconds seconds)
79 {
80 double resolution = (100_us).seconds();
81 double reduced = std::floor(seconds.seconds() / resolution) * resolution;
82 return Seconds(reduced);
83 }
84
85 PerformanceNavigation* Performance::navigation()
86 {
87 if (!is<Document>(scriptExecutionContext()))
88 return nullptr;
89
90 ASSERT(isMainThread());
91 if (!m_navigation)
92 m_navigation = PerformanceNavigation::create(downcast<Document>(*scriptExecutionContext()).frame());
93 return m_navigation.get();
94 }
95
96 PerformanceTiming* Performance::timing()
97 {
98 if (!is<Document>(scriptExecutionContext()))
99 return nullptr;
100
|
60
61 Performance::~Performance()
62 {
63 }
64
65 void Performance::contextDestroyed()
66 {
67 m_performanceTimelineTaskQueue.close();
68
69 ContextDestructionObserver::contextDestroyed();
70 }
71
72 double Performance::now() const
73 {
74 Seconds now = MonotonicTime::now() - m_timeOrigin;
75 return reduceTimeResolution(now).milliseconds();
76 }
77
78 Seconds Performance::reduceTimeResolution(Seconds seconds)
79 {
80 double resolution = (1000_us).seconds();
81 double reduced = std::floor(seconds.seconds() / resolution) * resolution;
82 return Seconds(reduced);
83 }
84
85 PerformanceNavigation* Performance::navigation()
86 {
87 if (!is<Document>(scriptExecutionContext()))
88 return nullptr;
89
90 ASSERT(isMainThread());
91 if (!m_navigation)
92 m_navigation = PerformanceNavigation::create(downcast<Document>(*scriptExecutionContext()).frame());
93 return m_navigation.get();
94 }
95
96 PerformanceTiming* Performance::timing()
97 {
98 if (!is<Document>(scriptExecutionContext()))
99 return nullptr;
100
|