Chromium Code Reviews| Index: mojo/services/native_viewport/main.cc |
| diff --git a/mojo/services/native_viewport/main.cc b/mojo/services/native_viewport/main.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e017232e06b60807ebda530c09475ea81c7c4c6f |
| --- /dev/null |
| +++ b/mojo/services/native_viewport/main.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/at_exit.h" |
| +#include "base/command_line.h" |
| +#include "base/message_loop/message_loop.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/services/native_viewport/native_viewport_impl.h" |
| +#include "ui/gl/gl_surface.h" |
| + |
| +namespace mojo { |
| + |
| +class NativeViewportAppDelegate : public ApplicationDelegate, |
| + public InterfaceFactory<NativeViewport> { |
| + public: |
| + NativeViewportAppDelegate() {} |
| + virtual ~NativeViewportAppDelegate() {} |
| + |
| + virtual bool ConfigureIncomingConnection( |
| + ApplicationConnection* connection) OVERRIDE { |
| + connection->AddService(this); |
| + return true; |
| + } |
| + |
| + virtual void Create(ApplicationConnection* connection, |
| + InterfaceRequest<NativeViewport> request) OVERRIDE { |
| + BindToRequest(new NativeViewportImpl, &request); |
|
Ben Goodger (Google)
2014/08/15 21:59:41
Can you just use a InterfaceFactoryImpl member var
|
| + } |
| +}; |
| + |
| +} // namespace mojo |
| + |
| +extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( |
| + MojoHandle shell_handle) { |
| + base::CommandLine::Init(0, NULL); |
| +#if !defined(COMPONENT_BUILD) |
| + base::AtExitManager at_exit; |
| + gfx::GLSurface::InitializeOneOff(); |
| +#endif |
| + |
| + mojo::NativeViewportAppDelegate delegate; |
| + { |
| + base::MessageLoop loop(base::MessageLoop::TYPE_UI); |
| + mojo::ApplicationImpl app(&delegate, shell_handle); |
| + loop.Run(); |
| + } |
| + return MOJO_RESULT_OK; |
| +} |