Index: base/files/file_descriptor_watcher_posix.cc |
diff --git a/base/files/file_descriptor_watcher_posix.cc b/base/files/file_descriptor_watcher_posix.cc |
index 49ac5d43a4a6080fbb18e0d63138c2480232b0dc..082ad9c063bde4632f93fdc439963ef7923abdc0 100644 |
--- a/base/files/file_descriptor_watcher_posix.cc |
+++ b/base/files/file_descriptor_watcher_posix.cc |
@@ -5,7 +5,6 @@ |
#include "base/files/file_descriptor_watcher_posix.h" |
#include "base/bind.h" |
-#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/memory/ptr_util.h" |
#include "base/sequenced_task_runner.h" |
@@ -20,8 +19,11 @@ namespace { |
// MessageLoopForIO used to watch file descriptors for which callbacks are |
// registered from a given thread. |
-LazyInstance<ThreadLocalPointer<MessageLoopForIO>>::Leaky |
- tls_message_loop_for_io = LAZY_INSTANCE_INITIALIZER; |
+ThreadLocalPointer<MessageLoopForIO>* GetTLSMessageLoopForIO() { |
+ static auto tls_message_loop_for_io = |
+ new ThreadLocalPointer<MessageLoopForIO>(); |
+ return tls_message_loop_for_io; |
+} |
} // namespace |
@@ -152,7 +154,7 @@ FileDescriptorWatcher::Controller::Controller(MessageLoopForIO::Mode mode, |
const Closure& callback) |
: callback_(callback), |
message_loop_for_io_task_runner_( |
- tls_message_loop_for_io.Get().Get()->task_runner()), |
+ GetTLSMessageLoopForIO()->Get()->task_runner()), |
weak_factory_(this) { |
DCHECK(!callback_.is_null()); |
DCHECK(message_loop_for_io_task_runner_); |
@@ -185,12 +187,12 @@ void FileDescriptorWatcher::Controller::RunCallback() { |
FileDescriptorWatcher::FileDescriptorWatcher( |
MessageLoopForIO* message_loop_for_io) { |
DCHECK(message_loop_for_io); |
- DCHECK(!tls_message_loop_for_io.Get().Get()); |
- tls_message_loop_for_io.Get().Set(message_loop_for_io); |
+ DCHECK(!GetTLSMessageLoopForIO()); |
+ GetTLSMessageLoopForIO()->Set(message_loop_for_io); |
} |
FileDescriptorWatcher::~FileDescriptorWatcher() { |
- tls_message_loop_for_io.Get().Set(nullptr); |
+ GetTLSMessageLoopForIO()->Set(nullptr); |
} |
std::unique_ptr<FileDescriptorWatcher::Controller> |