refactor: prefer using base::NoDestructor to base::{Singleton,LazyInstance} (#41424)
		
	refactor: prefer using base::NoDestructor to base::{Singleton,LazyInstance}
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
	
	
This commit is contained in:
		
					parent
					
						
							
								a55f23979e
							
						
					
				
			
			
				commit
				
					
						7331e5dfb1
					
				
			
		
					 12 changed files with 44 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -4,6 +4,7 @@
 | 
			
		|||
 | 
			
		||||
#include "shell/browser/net/network_context_service_factory.h"
 | 
			
		||||
 | 
			
		||||
#include "base/no_destructor.h"
 | 
			
		||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
 | 
			
		||||
#include "shell/browser/net/network_context_service.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +17,8 @@ NetworkContextService* NetworkContextServiceFactory::GetForContext(
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
NetworkContextServiceFactory* NetworkContextServiceFactory::GetInstance() {
 | 
			
		||||
  return base::Singleton<NetworkContextServiceFactory>::get();
 | 
			
		||||
  static base::NoDestructor<NetworkContextServiceFactory> instance;
 | 
			
		||||
  return instance.get();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
NetworkContextServiceFactory::NetworkContextServiceFactory()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,11 @@ namespace content {
 | 
			
		|||
class BrowserContext;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace base {
 | 
			
		||||
template <typename T>
 | 
			
		||||
class NoDestructor;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace electron {
 | 
			
		||||
 | 
			
		||||
class NetworkContextService;
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +38,7 @@ class NetworkContextServiceFactory : public BrowserContextKeyedServiceFactory {
 | 
			
		|||
      delete;
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  friend struct base::DefaultSingletonTraits<NetworkContextServiceFactory>;
 | 
			
		||||
  friend base::NoDestructor<NetworkContextServiceFactory>;
 | 
			
		||||
 | 
			
		||||
  NetworkContextServiceFactory();
 | 
			
		||||
  ~NetworkContextServiceFactory() override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue