• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #include "libcef_dll/shutdown_checker.h"
6 
7 #include <atomic>
8 
9 #include "include/base/cef_logging.h"
10 
11 namespace shutdown_checker {
12 
13 #if DCHECK_IS_ON()
14 
15 namespace {
16 
17 std::atomic_bool g_cef_shutdown{false};
18 
IsCefShutdown()19 bool IsCefShutdown() {
20   return g_cef_shutdown.load();
21 }
22 
SetCefShutdown()23 void SetCefShutdown() {
24   g_cef_shutdown.store(true);
25 }
26 
27 }  // namespace
28 
AssertNotShutdown()29 void AssertNotShutdown() {
30   DCHECK(!IsCefShutdown())
31       << "Object reference incorrectly held at CefShutdown";
32 }
33 
SetIsShutdown()34 void SetIsShutdown() {
35   DCHECK(!IsCefShutdown());
36   SetCefShutdown();
37 }
38 
39 #else  // !DCHECK_IS_ON()
40 
41 void AssertNotShutdown() {}
42 
43 #endif  // !DCHECK_IS_ON()
44 
45 }  // namespace shutdown_checker
46