xref: /aosp_15_r20/external/cronet/net/proxy_resolution/win/dhcpcsvc_init_win.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/proxy_resolution/win/dhcpcsvc_init_win.h"
6 
7 #include <windows.h>
8 
9 #include <dhcpcsdk.h>
10 #include <dhcpv6csdk.h>
11 
12 #include "base/check_op.h"
13 #include "base/lazy_instance.h"
14 
15 namespace {
16 
17 class DhcpcsvcInitSingleton {
18  public:
DhcpcsvcInitSingleton()19   DhcpcsvcInitSingleton() {
20     DWORD version = 0;
21     DWORD err = DhcpCApiInitialize(&version);
22     DCHECK(err == ERROR_SUCCESS);  // DCHECK_EQ complains of unsigned mismatch.
23   }
24 };
25 
26 // Worker pool threads that use the DHCP API may still be running at shutdown.
27 // Leak instance and skip cleanup.
28 static base::LazyInstance<DhcpcsvcInitSingleton>::Leaky
29     g_dhcpcsvc_init_singleton = LAZY_INSTANCE_INITIALIZER;
30 
31 }  // namespace
32 
33 namespace net {
34 
EnsureDhcpcsvcInit()35 void EnsureDhcpcsvcInit() {
36   g_dhcpcsvc_init_singleton.Get();
37 }
38 
39 }  // namespace net
40