Use OzonePlatform::PlatformProperties::requires_mojo only after init

Some ozone platforms (e.g. Wayland) require mojo communication while
others either don't use mojo or use it only if OzoneDrmMojo feature is
enabled. |requires_mojo| shows whether a platform requires mojo or not.

|requires_mojo| is used in some places before OzonePlatform is
initialized.

Part of this usage is for populating InitParams used for OzonePlatform
initialization. These can easily be removed as each type of
OzonePlatform knows whether it requires mojo or not when it is being
initialized. There is no need to pass this value to the initialization
codes.

Other cases use this and other info to check whether mojo is actually
used or not. None of these cases really need to happen before
initialization and can be moved to after initialization.

This change is part of a larger effort to remove the need for
OzonePlatform instance before it is initialized.

This CL also cleans up some code in OzonePlatform implementations,
mostly using std::make_unique<> instead of new operator.

BUG=958387

Change-Id: Ie44c6e441389e1f119f6458bc4e1c15bdc1d83e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1604112
Reviewed-by: Robert Kroeger <[email protected]>
Reviewed-by: Jonathan Backer <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Commit-Queue: Mohsen Izadi <[email protected]>
Cr-Commit-Position: refs/heads/master@{#683452}
diff --git a/components/viz/host/gpu_host_impl.cc b/components/viz/host/gpu_host_impl.cc
index acdcfb5..6ef2f1f 100644
--- a/components/viz/host/gpu_host_impl.cc
+++ b/components/viz/host/gpu_host_impl.cc
@@ -272,6 +272,7 @@
 }
 
 #if defined(USE_OZONE)
+
 void GpuHostImpl::InitOzone() {
   // Ozone needs to send the primary DRM device to GPU service as early as
   // possible to ensure the latter always has a valid device.
@@ -280,9 +281,8 @@
   // The Ozone/Wayland requires mojo communication to be established to be
   // functional with a separate gpu process. Thus, using the PlatformProperties,
   // check if there is such a requirement.
-  if (features::IsOzoneDrmMojo() || ui::OzonePlatform::EnsureInstance()
-                                        ->GetPlatformProperties()
-                                        .requires_mojo) {
+  if (features::IsOzoneDrmMojo() ||
+      ui::OzonePlatform::GetInstance()->GetPlatformProperties().requires_mojo) {
     // TODO(rjkroege): Remove the legacy IPC code paths when no longer
     // necessary. https://crbug.com/806092
     auto interface_binder = base::BindRepeating(&GpuHostImpl::BindInterface,