Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1224)

Unified Diff: mojo/services/native_viewport/main.cc

Issue 477923004: Create native_viewport_service, don't build it into mojo_shell unless Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove workaround for thunks Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cbff350bbf08b128750bfa1209b9e5e16625468f
--- /dev/null
+++ b/mojo/services/native_viewport/main.cc
@@ -0,0 +1,79 @@
+// 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/message_loop/message_loop.h"
+#include "gpu/command_buffer/service/mailbox_manager.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_runner_chromium.h"
+#include "mojo/public/cpp/application/interface_factory_impl.h"
+#include "mojo/services/native_viewport/gpu_impl.h"
+#include "mojo/services/native_viewport/native_viewport_impl.h"
+#include "ui/gl/gl_share_group.h"
+#include "ui/gl/gl_surface.h"
+
+namespace mojo {
+
+class NativeViewportAppDelegate : public ApplicationDelegate,
+ public InterfaceFactory<NativeViewport>,
+ public InterfaceFactory<Gpu> {
+ public:
+ NativeViewportAppDelegate()
+ : share_group_(new gfx::GLShareGroup),
+ mailbox_manager_(new gpu::gles2::MailboxManager) {}
+ virtual ~NativeViewportAppDelegate() {}
+
+ private:
+ // ApplicationDelegate implementation.
+ virtual void Initialize(ApplicationImpl* application) OVERRIDE {
+ app_ = application;
+#if !defined(COMPONENT_BUILD)
+ gfx::GLSurface::InitializeOneOff();
+#endif
+ }
+
+ virtual bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) OVERRIDE {
+ connection->AddService<NativeViewport>(this);
+ connection->AddService<Gpu>(this);
+ return true;
+ }
+
+ // InterfaceFactory<NativeViewport> implementation.
+ virtual void Create(ApplicationConnection* connection,
+ InterfaceRequest<NativeViewport> request) OVERRIDE {
+ BindToRequest(new NativeViewportImpl(app_), &request);
+ }
+
+ // InterfaceFactory<Gpu> implementation.
+ virtual void Create(ApplicationConnection* connection,
+ InterfaceRequest<Gpu> request) OVERRIDE {
+ BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()),
+ &request);
+ }
+
+ ApplicationImpl* app_;
+ scoped_refptr<gfx::GLShareGroup> share_group_;
+ scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
+ DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate);
+};
+}
Ben Goodger (Google) 2014/09/02 22:24:16 nit: NL after
DaveMoore 2014/09/02 22:39:06 Done.
+class NativeViewportAppDelegate : public mojo::ApplicationDelegate {
+ public:
+ virtual bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) OVERRIDE {
+ connection->AddService(&native_viewport_factory_);
+ return true;
+ }
+
+ private:
+ mojo::InterfaceFactoryImpl<mojo::NativeViewportImpl> native_viewport_factory_;
+};
+
+MojoResult MojoMain(MojoHandle shell_handle) {
+ mojo::ApplicationRunnerChromium runner(new mojo::NativeViewportAppDelegate);
+ runner.set_message_loop_type(base::MessageLoop::TYPE_UI);
+ return runner.Run(shell_handle);
+}

Powered by Google App Engine
This is Rietveld 408576698