mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:12:43 +00:00 
			
		
		
		
	 834202aeb9
			
		
	
	
		834202aeb9
		
	
	
	
	
		
			
			This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created.
		
			
				
	
	
		
			37 lines
		
	
	
	
		
			860 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			860 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibCore/ElapsedTimer.h>
 | |
| #include <LibWeb/DOM/EventTarget.h>
 | |
| 
 | |
| namespace Web::HighResolutionTime {
 | |
| 
 | |
| class Performance final : public DOM::EventTarget {
 | |
|     WEB_PLATFORM_OBJECT(Performance, DOM::EventTarget);
 | |
| 
 | |
| public:
 | |
|     virtual ~Performance() override;
 | |
| 
 | |
|     double now() const { return static_cast<double>(m_timer.elapsed()); }
 | |
|     double time_origin() const;
 | |
| 
 | |
|     JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
 | |
| 
 | |
| private:
 | |
|     explicit Performance(HTML::Window&);
 | |
| 
 | |
|     virtual void initialize(JS::Realm&) override;
 | |
|     virtual void visit_edges(Cell::Visitor&) override;
 | |
| 
 | |
|     JS::NonnullGCPtr<HTML::Window> m_window;
 | |
|     JS::GCPtr<NavigationTiming::PerformanceTiming> m_timing;
 | |
| 
 | |
|     Core::ElapsedTimer m_timer;
 | |
| };
 | |
| 
 | |
| }
 |