mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:12:43 +00:00 
			
		
		
		
	 45a81f5a2c
			
		
	
	
		45a81f5a2c
		
	
	
	
	
		
			
			The storage inspector now has a new tab for local storage. The next step would be to persist local storage and receive real-time notifications for changes to update the table view.
		
			
				
	
	
		
			54 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/HashMap.h>
 | |
| #include <AK/RefCounted.h>
 | |
| #include <LibWeb/Bindings/Wrappable.h>
 | |
| #include <LibWeb/DOM/ExceptionOr.h>
 | |
| #include <LibWeb/Forward.h>
 | |
| 
 | |
| namespace Web::HTML {
 | |
| 
 | |
| class Storage
 | |
|     : public RefCounted<Storage>
 | |
|     , public Bindings::Wrappable {
 | |
| public:
 | |
|     using WrapperType = Bindings::StorageWrapper;
 | |
| 
 | |
|     static NonnullRefPtr<Storage> create();
 | |
|     ~Storage();
 | |
| 
 | |
|     size_t length() const;
 | |
|     String key(size_t index);
 | |
|     String get_item(String const& key) const;
 | |
|     DOM::ExceptionOr<void> set_item(String const& key, String const& value);
 | |
|     void remove_item(String const& key);
 | |
|     void clear();
 | |
| 
 | |
|     Vector<String> supported_property_names() const;
 | |
| 
 | |
|     auto const& map() const { return m_map; }
 | |
| 
 | |
|     void dump() const;
 | |
| 
 | |
| private:
 | |
|     Storage();
 | |
| 
 | |
|     void reorder();
 | |
|     void broadcast(String const& key, String const& old_value, String const& new_value);
 | |
| 
 | |
|     OrderedHashMap<String, String> m_map;
 | |
| };
 | |
| 
 | |
| }
 | |
| 
 | |
| namespace Web::Bindings {
 | |
| 
 | |
| StorageWrapper* wrap(JS::GlobalObject&, HTML::Storage&);
 | |
| 
 | |
| }
 |