summaryrefslogtreecommitdiffstats
path: root/net/proxy/dhcpcsvc_init_win.cc
blob: 7e32aeae9cd5593b3d788341cdd5bc9f8d845ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/proxy/dhcpcsvc_init_win.h"

#include "base/lazy_instance.h"
#include "base/logging.h"

#include <dhcpcsdk.h>
#include <dhcpv6csdk.h>

namespace {

class DhcpcsvcInitSingleton {
 public:
  DhcpcsvcInitSingleton() {
    DWORD version = 0;
    DWORD err = DhcpCApiInitialize(&version);
    DCHECK(err == ERROR_SUCCESS);  // DCHECK_EQ complains of unsigned mismatch.
  }

  ~DhcpcsvcInitSingleton() {
    // Worker pool threads that use the DHCP API may still be running, so skip
    // cleanup.
  }
};

static base::LazyInstance<DhcpcsvcInitSingleton> g_dhcpcsvc_init_singleton =
    LAZY_INSTANCE_INITIALIZER;

}  // namespace

namespace net {

void EnsureDhcpcsvcInit() {
  g_dhcpcsvc_init_singleton.Get();
}

}  // namespace net