Chromium Code Reviews| Index: ui/ozone/public/surface_factory_ozone.cc |
| diff --git a/ui/ozone/public/surface_factory_ozone.cc b/ui/ozone/public/surface_factory_ozone.cc |
| index 1c57038d32452d9eecc4bea34178b9b65e8265af..615395fc756599549e95e911e56cb05b4ab9bafb 100644 |
| --- a/ui/ozone/public/surface_factory_ozone.cc |
| +++ b/ui/ozone/public/surface_factory_ozone.cc |
| @@ -7,28 +7,33 @@ |
| #include <stdlib.h> |
| #include "base/command_line.h" |
| +#include "base/lazy_instance.h" |
| #include "ui/ozone/public/native_pixmap.h" |
| #include "ui/ozone/public/surface_ozone_canvas.h" |
| #include "ui/ozone/public/surface_ozone_egl.h" |
| namespace ui { |
| -// static |
| -SurfaceFactoryOzone* SurfaceFactoryOzone::impl_ = NULL; |
| +namespace { |
| + |
| +base::LazyInstance<SurfaceFactoryOzone*>::Leaky g_impl = |
|
spang
2015/05/07 17:20:45
Please drop these unrelated changes.
I don't thin
dshwang
2015/05/15 18:11:20
Done.
|
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| +} // namespace |
| SurfaceFactoryOzone::SurfaceFactoryOzone() { |
| - DCHECK(!impl_) << "There should only be a single SurfaceFactoryOzone."; |
| - impl_ = this; |
| + DCHECK(!g_impl.Get()) << "There should only be a single SurfaceFactoryOzone."; |
| + *g_impl.Pointer() = this; |
| } |
| SurfaceFactoryOzone::~SurfaceFactoryOzone() { |
| - DCHECK_EQ(impl_, this); |
| - impl_ = NULL; |
| + DCHECK_EQ(g_impl.Get(), this); |
| + *g_impl.Pointer() = nullptr; |
| } |
| SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() { |
| - DCHECK(impl_) << "No SurfaceFactoryOzone implementation set."; |
| - return impl_; |
| + DCHECK(g_impl.Get()) << "No SurfaceFactoryOzone implementation set."; |
| + return g_impl.Get(); |
| } |
| intptr_t SurfaceFactoryOzone::GetNativeDisplay() { |
| @@ -65,7 +70,7 @@ const int32* SurfaceFactoryOzone::GetEGLSurfaceProperties( |
| ui::OverlayCandidatesOzone* SurfaceFactoryOzone::GetOverlayCandidates( |
| gfx::AcceleratedWidget w) { |
| - return NULL; |
| + return nullptr; |
| } |
| scoped_refptr<ui::NativePixmap> SurfaceFactoryOzone::CreateNativePixmap( |
| @@ -73,7 +78,7 @@ scoped_refptr<ui::NativePixmap> SurfaceFactoryOzone::CreateNativePixmap( |
| gfx::Size size, |
| BufferFormat format, |
| BufferUsage usage) { |
| - return NULL; |
| + return nullptr; |
| } |
| bool SurfaceFactoryOzone::ScheduleOverlayPlane( |