Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: third_party/mojo/src/mojo/edk/embedder/entrypoints.cc

Issue 1646223002: Fix race in UseNewEDK(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/sanitizers/tsan_suppressions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9f853b509ef1037d6d007aa6b8ee51fbf5b576b8 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,15 +18,22 @@ 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;
+};
+
+base::LazyInstance<UseNewEDKChecker> g_use_new_checker =
+ LAZY_INSTANCE_INITIALIZER;
+
+bool UseNewEDK() {
+ return g_use_new_checker.Get().use_new;
}
+
}
// Definitions of the system functions.
« no previous file with comments | « build/sanitizers/tsan_suppressions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698