mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 05:10:57 +00:00 
			
		
		
		
	 66a19b8550
			
		
	
	
		66a19b8550
		
	
	
	
	
		
			
			Otherwise we end up holding on to every fetch record indefinitely. Found by analyzing GC heap graphs on Discord.
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2024, Mohamed amine Bounya <mobounya@gmail.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/Fetch/Infrastructure/FetchController.h>
 | |
| 
 | |
| namespace Web::Fetch::Infrastructure {
 | |
| 
 | |
| // https://fetch.spec.whatwg.org/#concept-fetch-record
 | |
| class FetchRecord final : public JS::Cell {
 | |
|     GC_CELL(FetchRecord, JS::Cell);
 | |
|     GC_DECLARE_ALLOCATOR(FetchRecord);
 | |
| 
 | |
| public:
 | |
|     [[nodiscard]] static GC::Ref<FetchRecord> create(JS::VM&, GC::Ref<Infrastructure::Request>);
 | |
|     [[nodiscard]] static GC::Ref<FetchRecord> create(JS::VM&, GC::Ref<Infrastructure::Request>, GC::Ptr<FetchController>);
 | |
| 
 | |
|     [[nodiscard]] GC::Ref<Infrastructure::Request> request() const { return m_request; }
 | |
|     void set_request(GC::Ref<Infrastructure::Request> request) { m_request = request; }
 | |
| 
 | |
|     [[nodiscard]] GC::Ptr<FetchController> fetch_controller() const { return m_fetch_controller; }
 | |
|     void set_fetch_controller(GC::Ptr<FetchController> fetch_controller) { m_fetch_controller = fetch_controller; }
 | |
| 
 | |
| private:
 | |
|     explicit FetchRecord(GC::Ref<Infrastructure::Request>);
 | |
|     FetchRecord(GC::Ref<Infrastructure::Request>, GC::Ptr<FetchController>);
 | |
| 
 | |
|     virtual void visit_edges(Visitor&) override;
 | |
|     virtual void finalize() override;
 | |
| 
 | |
|     // https://fetch.spec.whatwg.org/#concept-request
 | |
|     // A fetch record has an associated request (a request)
 | |
|     GC::Ref<Infrastructure::Request> m_request;
 | |
| 
 | |
|     // https://fetch.spec.whatwg.org/#fetch-controller
 | |
|     // A fetch record has an associated controller (a fetch controller or null)
 | |
|     GC::Ptr<FetchController> m_fetch_controller { nullptr };
 | |
| 
 | |
|     IntrusiveListNode<FetchRecord> m_list_node;
 | |
| 
 | |
| public:
 | |
|     using List = IntrusiveList<&FetchRecord::m_list_node>;
 | |
| };
 | |
| 
 | |
| }
 |