Index: third_party/mojo/src/mojo/edk/embedder/entrypoints.cc |
diff --git a/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc b/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc |
index 3d30deb466b1d8438e8ccc8b37e35313c57a35bf..992bbd66f7c2249e3c86bcbe243006024bfc3679 100644 |
--- a/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc |
+++ b/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc |
@@ -5,6 +5,7 @@ |
#include "../../../../../../mojo/edk/embedder/embedder_internal.h" |
#include "../../../../../../mojo/edk/system/core.h" |
#include "base/command_line.h" |
+#include "base/lazy_instance.h" |
#include "mojo/public/c/system/buffer.h" |
#include "mojo/public/c/system/data_pipe.h" |
#include "mojo/public/c/system/functions.h" |
@@ -17,17 +18,25 @@ using mojo::embedder::internal::g_core; |
using mojo::system::MakeUserPointer; |
namespace { |
-bool UseNewEDK() { |
- static bool checked = false; |
- static bool use_new = false; |
- if (!checked) { |
+ |
+struct UseNewEDKChecker { |
+ UseNewEDKChecker() { |
use_new = base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk"); |
- checked = true; |
} |
- return use_new; |
-} |
+ |
+ bool use_new; |
+}; |
+ |
+// This is Leaky to avoid a recursive lock acquisition in AtExitManager. |
+base::LazyInstance<UseNewEDKChecker>::Leaky g_use_new_checker = |
+ LAZY_INSTANCE_INITIALIZER; |
+ |
+bool UseNewEDK() { |
+ return g_use_new_checker.Get().use_new; |
} |
+} // namespace |
+ |
// Definitions of the system functions. |
extern "C" { |
MojoTimeTicks MojoGetTimeTicksNow() { |