Craig Stout | 4802bc7 | 2015-08-28 15:00:11 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SERVICES_NATIVE_VIEWPORT_APP_DELEGATE_H_ |
| 6 | #define SERVICES_NATIVE_VIEWPORT_APP_DELEGATE_H_ |
| 7 | |
| 8 | #include <algorithm> |
| 9 | |
| 10 | #include "base/bind.h" |
| 11 | #include "base/command_line.h" |
| 12 | #include "base/macros.h" |
| 13 | #include "base/message_loop/message_loop.h" |
| 14 | #include "mojo/application/application_runner_chromium.h" |
| 15 | #include "mojo/common/tracing_impl.h" |
| 16 | #include "mojo/public/c/system/main.h" |
| 17 | #include "mojo/public/cpp/application/application_delegate.h" |
| 18 | #include "mojo/public/cpp/application/application_impl.h" |
Viet-Trung Luu | 84765c4 | 2015-10-10 01:07:51 -0700 | [diff] [blame] | 19 | #include "mojo/services/native_viewport/cpp/args.h" |
Craig Stout | 4802bc7 | 2015-08-28 15:00:11 -0700 | [diff] [blame] | 20 | #include "services/gles2/gpu_impl.h" |
| 21 | #include "services/native_viewport/native_viewport_impl.h" |
| 22 | #include "ui/events/event_switches.h" |
| 23 | #include "ui/gl/gl_surface.h" |
| 24 | |
Craig Stout | 4802bc7 | 2015-08-28 15:00:11 -0700 | [diff] [blame] | 25 | namespace native_viewport { |
| 26 | |
Viet-Trung Luu | d21f93b | 2016-05-12 16:35:38 -0700 | [diff] [blame^] | 27 | class NativeViewportAppDelegate |
| 28 | : public mojo::ApplicationDelegate, |
| 29 | public mojo::InterfaceFactory<mojo::NativeViewport>, |
| 30 | public mojo::InterfaceFactory<mojo::Gpu> { |
Craig Stout | 4802bc7 | 2015-08-28 15:00:11 -0700 | [diff] [blame] | 31 | public: |
| 32 | NativeViewportAppDelegate(); |
| 33 | ~NativeViewportAppDelegate() override; |
| 34 | |
| 35 | // mojo::ApplicationDelegate implementation. |
| 36 | void Initialize(mojo::ApplicationImpl* application) override; |
| 37 | |
Viet-Trung Luu | d21f93b | 2016-05-12 16:35:38 -0700 | [diff] [blame^] | 38 | bool ConfigureIncomingConnection( |
| 39 | mojo::ApplicationConnection* connection) override; |
Craig Stout | 4802bc7 | 2015-08-28 15:00:11 -0700 | [diff] [blame] | 40 | |
Viet-Trung Luu | d21f93b | 2016-05-12 16:35:38 -0700 | [diff] [blame^] | 41 | // mojo::InterfaceFactory<mojo::NativeViewport> implementation. |
| 42 | void Create(const mojo::ConnectionContext& connection_context, |
| 43 | mojo::InterfaceRequest<mojo::NativeViewport> request) override; |
Craig Stout | 4802bc7 | 2015-08-28 15:00:11 -0700 | [diff] [blame] | 44 | |
Viet-Trung Luu | d21f93b | 2016-05-12 16:35:38 -0700 | [diff] [blame^] | 45 | // mojo::InterfaceFactory<mojo::Gpu> implementation. |
| 46 | void Create(const mojo::ConnectionContext& connection_context, |
| 47 | mojo::InterfaceRequest<mojo::Gpu> request) override; |
Craig Stout | 4802bc7 | 2015-08-28 15:00:11 -0700 | [diff] [blame] | 48 | |
| 49 | private: |
| 50 | void InitLogging(mojo::ApplicationImpl* application); |
| 51 | |
| 52 | mojo::ApplicationImpl* application_; |
| 53 | scoped_refptr<gles2::GpuState> gpu_state_; |
| 54 | bool is_headless_; |
| 55 | mojo::TracingImpl tracing_; |
| 56 | |
| 57 | DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
| 58 | }; |
| 59 | |
| 60 | } // namespace native_viewport |
| 61 | |
| 62 | #endif |