summaryrefslogtreecommitdiff
path: root/chromium/net/cert/cert_net_fetcher.cc
blob: aa91110382371694a1f1071f62c6adb434b212cf (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) 2017 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/cert/cert_net_fetcher.h"

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

namespace net {

namespace {

base::LazyInstance<scoped_refptr<CertNetFetcher>>::Leaky g_cert_net_fetcher =
    LAZY_INSTANCE_INITIALIZER;

}  // namespace

CertNetFetcher* GetGlobalCertNetFetcher() {
  return g_cert_net_fetcher.Get().get();
}

void SetGlobalCertNetFetcher(scoped_refptr<CertNetFetcher> cert_net_fetcher) {
  DCHECK(!g_cert_net_fetcher.Get());
  g_cert_net_fetcher.Get() = std::move(cert_net_fetcher);
}

void SetGlobalCertNetFetcherForTesting(
    scoped_refptr<CertNetFetcher> cert_net_fetcher) {
  if (g_cert_net_fetcher.Get())
    g_cert_net_fetcher.Get()->Shutdown();
  g_cert_net_fetcher.Get() = std::move(cert_net_fetcher);
}

void ShutdownGlobalCertNetFetcher() {
  g_cert_net_fetcher.Get()->Shutdown();
  g_cert_net_fetcher.Get() = nullptr;
}

}  // namespace net