 +    if (output_device)
 +      return output_device;
 +  }
- #if defined(USE_AURA)
-   if (service_manager::ServiceManagerIsRemote()) {
-     NOTREACHED();
+   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+   if (command_line->HasSwitch(switches::kHeadless))
+     return base::WrapUnique(new cc::SoftwareOutputDevice);
 diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
-index 76f8f38..cbf6d98 100644
+index 92696ad..7da8159 100644
 --- a/ui/compositor/compositor.h
 +++ b/ui/compositor/compositor.h
 @@ -18,6 +18,7 @@

 // Compositor object to take care of GPU painting.
 // A Browser compositor object is responsible for generating the final
 // displayable form of pixels comprising a single widget's contents. It draws an
@@ -211,6 +221,9 @@ class COMPOSITOR_EXPORT Compositor
   // Schedules a redraw of the layer tree associated with this compositor.
   void ScheduleDraw();
 

   // Sets the root of the layer tree drawn by this Compositor. The root layer
   // must have no parent. The compositor's root layer is reset if the root layer
   // is destroyed. NULL can be passed to reset the root layer, in which case the
@@ -398,6 +411,8 @@ class COMPOSITOR_EXPORT Compositor
   ui::ContextFactory* context_factory_;
   ui::ContextFactoryPrivate* context_factory_private_;
 
+  CompositorDelegate* delegate_ = nullptr;
+
