Remove uses of base/lazy_instance

Now that we rely on threadsafe initialization we can stop using
base::LazyInstance to perform threadsafe initialization of function
level statics.

R=viettrungluu@chromium.org

Review URL: https://codereview.chromium.org/1686953003 .
diff --git a/mojo/gles2/control_thunks_impl.cc b/mojo/gles2/control_thunks_impl.cc
index 67e4bbb..ab0d48c 100644
--- a/mojo/gles2/control_thunks_impl.cc
+++ b/mojo/gles2/control_thunks_impl.cc
@@ -20,8 +20,8 @@
 
 // static
 ControlThunksImpl* ControlThunksImpl::Get() {
-  static base::LazyInstance<ControlThunksImpl>::Leaky thunks;
-  return thunks.Pointer();
+  static auto* thunks = new ControlThunksImpl;
+  return thunks;
 }
 
 MGLContext ControlThunksImpl::CreateContext(
diff --git a/mojo/gles2/control_thunks_impl.h b/mojo/gles2/control_thunks_impl.h
index c240939..13a794b 100644
--- a/mojo/gles2/control_thunks_impl.h
+++ b/mojo/gles2/control_thunks_impl.h
@@ -5,7 +5,6 @@
 #ifndef MOJO_GLES2_CONTROL_THUNKS_IMPL_H_
 #define MOJO_GLES2_CONTROL_THUNKS_IMPL_H_
 
-#include "base/lazy_instance.h"
 #include "base/macros.h"
 #include "base/threading/thread_local.h"
 #include "gpu/GLES2/gl2extchromium.h"
@@ -56,7 +55,6 @@
   gpu::gles2::GLES2Interface* CurrentGLES2Interface();
 
  private:
-  friend base::DefaultLazyInstanceTraits<gles2::ControlThunksImpl>;
   ControlThunksImpl();
   ~ControlThunksImpl();
 
diff --git a/mojo/message_pump/handle_watcher.cc b/mojo/message_pump/handle_watcher.cc
index 2465579..c330d31 100644
--- a/mojo/message_pump/handle_watcher.cc
+++ b/mojo/message_pump/handle_watcher.cc
@@ -8,7 +8,6 @@
 
 #include "base/atomic_sequence_num.h"
 #include "base/bind.h"
-#include "base/lazy_instance.h"
 #include "base/logging.h"
 #include "base/macros.h"
 #include "base/memory/singleton.h"
diff --git a/mojo/message_pump/message_pump_mojo.cc b/mojo/message_pump/message_pump_mojo.cc
index e7f7d10..1786ba1 100644
--- a/mojo/message_pump/message_pump_mojo.cc
+++ b/mojo/message_pump/message_pump_mojo.cc
@@ -8,7 +8,6 @@
 #include <vector>
 
 #include "base/debug/alias.h"
-#include "base/lazy_instance.h"
 #include "base/logging.h"
 #include "base/threading/thread_local.h"
 #include "base/time/time.h"
@@ -19,8 +18,10 @@
 namespace common {
 namespace {
 
-base::LazyInstance<base::ThreadLocalPointer<MessagePumpMojo> >::Leaky
-    g_tls_current_pump = LAZY_INSTANCE_INITIALIZER;
+base::ThreadLocalPointer<MessagePumpMojo>* CurrentPump() {
+  static auto* tls = new base::ThreadLocalPointer<MessagePumpMojo>;
+  return tls;
+}
 
 MojoDeadline TimeTicksToMojoDeadline(base::TimeTicks time_ticks,
                                      base::TimeTicks now) {
@@ -44,7 +45,7 @@
 
 struct MessagePumpMojo::RunState {
   RunState() : should_quit(false) {
-    CreateMessagePipe(NULL, &read_handle, &write_handle);
+    CreateMessagePipe(nullptr, &read_handle, &write_handle);
   }
 
   base::TimeTicks delayed_work_time;
@@ -60,15 +61,15 @@
   bool should_quit;
 };
 
-MessagePumpMojo::MessagePumpMojo() : run_state_(NULL), next_handler_id_(0) {
+MessagePumpMojo::MessagePumpMojo() : run_state_(nullptr), next_handler_id_(0) {
   DCHECK(!current())
       << "There is already a MessagePumpMojo instance on this thread.";
-  g_tls_current_pump.Pointer()->Set(this);
+  CurrentPump()->Set(this);
 }
 
 MessagePumpMojo::~MessagePumpMojo() {
   DCHECK_EQ(this, current());
-  g_tls_current_pump.Pointer()->Set(NULL);
+  CurrentPump()->Set(nullptr);
 }
 
 // static
@@ -78,7 +79,7 @@
 
 // static
 MessagePumpMojo* MessagePumpMojo::current() {
-  return g_tls_current_pump.Pointer()->Get();
+  return CurrentPump()->Get();
 }
 
 void MessagePumpMojo::AddHandler(MessagePumpMojoHandler* handler,
@@ -114,7 +115,7 @@
   // TODO: better deal with error handling.
   CHECK(run_state.read_handle.is_valid());
   CHECK(run_state.write_handle.is_valid());
-  RunState* old_state = NULL;
+  RunState* old_state = nullptr;
   {
     base::AutoLock auto_lock(run_state_lock_);
     old_state = run_state_;
@@ -188,8 +189,8 @@
   if (result == MOJO_RESULT_OK) {
     if (wait_many_result.index == 0) {
       // Control pipe was written to.
-      ReadMessageRaw(run_state.read_handle.get(), NULL, NULL, NULL, NULL,
-                     MOJO_READ_MESSAGE_FLAG_MAY_DISCARD);
+      ReadMessageRaw(run_state.read_handle.get(), nullptr, nullptr, nullptr,
+                     nullptr, MOJO_READ_MESSAGE_FLAG_MAY_DISCARD);
     } else {
       DCHECK(handlers_.find(
                  run_state_->wait_state->handles[wait_many_result.index]) !=
@@ -281,7 +282,7 @@
 
 void MessagePumpMojo::SignalControlPipe(const RunState& run_state) {
   const MojoResult result =
-      WriteMessageRaw(run_state.write_handle.get(), NULL, 0, NULL, 0,
+      WriteMessageRaw(run_state.write_handle.get(), nullptr, 0, nullptr, 0,
                       MOJO_WRITE_MESSAGE_FLAG_NONE);
   // If we can't write we likely won't wake up the thread and there is a strong
   // chance we'll deadlock.
diff --git a/shell/context.cc b/shell/context.cc
index 8569a1a..101ea61 100644
--- a/shell/context.cc
+++ b/shell/context.cc
@@ -9,9 +9,9 @@
 #include "base/base_switches.h"
 #include "base/bind.h"
 #include "base/command_line.h"
+#include "base/compiler_specific.h"
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
-#include "base/lazy_instance.h"
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/memory/scoped_vector.h"
@@ -53,19 +53,6 @@
 namespace shell {
 namespace {
 
-// Used to ensure we only init once.
-class Setup {
- public:
-  Setup() {
-    mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport());
-  }
-
-  ~Setup() {}
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(Setup);
-};
-
 ApplicationManager::Options MakeApplicationManagerOptions() {
   ApplicationManager::Options options;
   options.disable_cache = base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -253,8 +240,11 @@
 
 // static
 void Context::EnsureEmbedderIsInitialized() {
-  static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER;
-  setup.Get();
+  static bool initialized = ([]() {
+    mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport());
+    return true;
+  })();
+  ALLOW_UNUSED_LOCAL(initialized);
 }
 
 void Context::SetShellFileRoot(const base::FilePath& path) {