Index: services/native_viewport/main.cc |
diff --git a/services/native_viewport/main.cc b/services/native_viewport/main.cc |
index 2e8dd7ad33bfc30382ad18eb736347e0c01efca1..cff828bb1306a10b24d922082d583d8c4b228bb3 100644 |
--- a/services/native_viewport/main.cc |
+++ b/services/native_viewport/main.cc |
@@ -2,100 +2,20 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include <algorithm> |
- |
-#include "base/command_line.h" |
-#include "base/macros.h" |
-#include "base/message_loop/message_loop.h" |
-#include "mojo/application/application_runner_chromium.h" |
-#include "mojo/common/tracing_impl.h" |
-#include "mojo/public/c/system/main.h" |
-#include "mojo/public/cpp/application/application_connection.h" |
-#include "mojo/public/cpp/application/application_delegate.h" |
-#include "mojo/public/cpp/application/application_impl.h" |
-#include "mojo/public/cpp/application/interface_factory_impl.h" |
-#include "mojo/services/native_viewport/public/cpp/args.h" |
-#include "services/gles2/gpu_impl.h" |
-#include "services/native_viewport/native_viewport_impl.h" |
-#include "ui/events/event_switches.h" |
-#include "ui/gl/gl_surface.h" |
- |
-using mojo::ApplicationConnection; |
-using mojo::Gpu; |
-using mojo::NativeViewport; |
- |
-namespace native_viewport { |
- |
-class NativeViewportAppDelegate : public mojo::ApplicationDelegate, |
- public mojo::InterfaceFactory<NativeViewport>, |
- public mojo::InterfaceFactory<Gpu> { |
- public: |
- NativeViewportAppDelegate() : is_headless_(false) {} |
- ~NativeViewportAppDelegate() override {} |
- |
- private: |
- // mojo::ApplicationDelegate implementation. |
- void Initialize(mojo::ApplicationImpl* application) override { |
- application_ = application; |
- tracing_.Initialize(application); |
- |
- // Apply the switch for kTouchEvents to CommandLine (if set). This allows |
- // redirecting the mouse to a touch device on X for testing. |
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
- const std::string touch_event_string("--" + |
- std::string(switches::kTouchDevices)); |
- auto touch_iter = std::find(application->args().begin(), |
- application->args().end(), touch_event_string); |
- if (touch_iter != application->args().end() && |
- ++touch_iter != application->args().end()) { |
- command_line->AppendSwitchASCII(touch_event_string, *touch_iter); |
- } |
- |
- if (application->HasArg(mojo::kUseTestConfig)) |
- gfx::GLSurface::InitializeOneOffForTests(); |
- else if (application->HasArg(mojo::kUseOSMesa)) |
- gfx::GLSurface::InitializeOneOff(gfx::kGLImplementationOSMesaGL); |
- else |
- gfx::GLSurface::InitializeOneOff(); |
- |
- is_headless_ = application->HasArg(mojo::kUseHeadlessConfig); |
- } |
- |
- bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
- connection->AddService<NativeViewport>(this); |
- connection->AddService<Gpu>(this); |
- return true; |
- } |
- |
- // mojo::InterfaceFactory<NativeViewport> implementation. |
- void Create(ApplicationConnection* connection, |
- mojo::InterfaceRequest<NativeViewport> request) override { |
- if (!gpu_state_.get()) |
- gpu_state_ = new gles2::GpuState; |
- new NativeViewportImpl(application_, is_headless_, gpu_state_, |
- request.Pass()); |
- } |
- |
- // mojo::InterfaceFactory<Gpu> implementation. |
- void Create(ApplicationConnection* connection, |
- mojo::InterfaceRequest<Gpu> request) override { |
- if (!gpu_state_.get()) |
- gpu_state_ = new gles2::GpuState; |
- new gles2::GpuImpl(request.Pass(), gpu_state_); |
- } |
- |
- mojo::ApplicationImpl* application_; |
- scoped_refptr<gles2::GpuState> gpu_state_; |
- bool is_headless_; |
- mojo::TracingImpl tracing_; |
- |
- DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
-}; |
-} |
+#if defined(USE_OZONE) |
+#include "services/native_viewport/ozone/app_delegate_ozone.h" |
+#else |
+#include "services/native_viewport/app_delegate.h" |
+#endif |
MojoResult MojoMain(MojoHandle application_request) { |
+#if defined(USE_OZONE) |
+ mojo::ApplicationRunnerChromium runner( |
+ new native_viewport::NativeViewportOzoneAppDelegate); |
+#else |
mojo::ApplicationRunnerChromium runner( |
new native_viewport::NativeViewportAppDelegate); |
+#endif |
runner.set_message_loop_type(base::MessageLoop::TYPE_UI); |
return runner.Run(application_request); |
} |