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

Side by Side Diff: examples/spinning_cube/spinning_cube_app.cc

Issue 2004493002: Add a mojo::RunApplication() for running implementations of ApplicationImplBase. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_environment_no_instantiate
Patch Set: rebased Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « examples/echo/echo_benchmark.cc ('k') | examples/trace_me/trace_me_app.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <assert.h> 5 #include <assert.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "examples/spinning_cube/gles2_client_impl.h" 11 #include "examples/spinning_cube/gles2_client_impl.h"
12 #include "mojo/public/c/system/main.h" 12 #include "mojo/public/c/system/main.h"
13 #include "mojo/public/cpp/application/application_delegate.h" 13 #include "mojo/public/cpp/application/application_impl_base.h"
14 #include "mojo/public/cpp/application/application_impl.h"
15 #include "mojo/public/cpp/application/application_runner.h"
16 #include "mojo/public/cpp/application/connect.h" 14 #include "mojo/public/cpp/application/connect.h"
15 #include "mojo/public/cpp/application/run_application.h"
17 #include "mojo/public/cpp/application/service_provider_impl.h" 16 #include "mojo/public/cpp/application/service_provider_impl.h"
18 #include "mojo/public/cpp/system/macros.h" 17 #include "mojo/public/cpp/system/macros.h"
19 #include "mojo/public/cpp/utility/run_loop.h" 18 #include "mojo/public/cpp/utility/run_loop.h"
20 #include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h" 19 #include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h"
21 #include "mojo/services/native_viewport/interfaces/native_viewport_event_dispatc her.mojom.h" 20 #include "mojo/services/native_viewport/interfaces/native_viewport_event_dispatc her.mojom.h"
22 21
23 namespace examples { 22 namespace examples {
24 23
25 class SpinningCubeApp : public mojo::ApplicationDelegate, 24 class SpinningCubeApp : public mojo::ApplicationImplBase,
26 public mojo::NativeViewportEventDispatcher { 25 public mojo::NativeViewportEventDispatcher {
27 public: 26 public:
28 SpinningCubeApp() : dispatcher_binding_(this) {} 27 SpinningCubeApp() : dispatcher_binding_(this) {}
29 28
30 ~SpinningCubeApp() override { 29 ~SpinningCubeApp() override {
31 // TODO(darin): Fix shutdown so we don't need to leak this. 30 // TODO(darin): Fix shutdown so we don't need to leak this.
32 mojo::ignore_result(gles2_client_.release()); 31 mojo::ignore_result(gles2_client_.release());
33 } 32 }
34 33
35 void Initialize(mojo::ApplicationImpl* app) override { 34 // |ApplicationImplBase| overrides:
36 mojo::ConnectToService(app->shell(), "mojo:native_viewport_service", 35 void OnInitialize() override {
36 mojo::ConnectToService(shell(), "mojo:native_viewport_service",
37 GetProxy(&viewport_)); 37 GetProxy(&viewport_));
38 viewport_.set_connection_error_handler( 38 viewport_.set_connection_error_handler(
39 [this]() { OnViewportConnectionError(); }); 39 [this]() { OnViewportConnectionError(); });
40 40
41 SetEventDispatcher(); 41 SetEventDispatcher();
42 42
43 mojo::SizePtr size(mojo::Size::New()); 43 mojo::SizePtr size(mojo::Size::New());
44 size->width = 800; 44 size->width = 800;
45 size->height = 600; 45 size->height = 600;
46 46
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 mojo::NativeViewportPtr viewport_; 87 mojo::NativeViewportPtr viewport_;
88 mojo::ContextProviderPtr onscreen_context_provider_; 88 mojo::ContextProviderPtr onscreen_context_provider_;
89 mojo::Binding<NativeViewportEventDispatcher> dispatcher_binding_; 89 mojo::Binding<NativeViewportEventDispatcher> dispatcher_binding_;
90 90
91 MOJO_DISALLOW_COPY_AND_ASSIGN(SpinningCubeApp); 91 MOJO_DISALLOW_COPY_AND_ASSIGN(SpinningCubeApp);
92 }; 92 };
93 93
94 } // namespace examples 94 } // namespace examples
95 95
96 MojoResult MojoMain(MojoHandle application_request) { 96 MojoResult MojoMain(MojoHandle application_request) {
97 mojo::ApplicationRunner runner(std::unique_ptr<examples::SpinningCubeApp>( 97 examples::SpinningCubeApp spinning_cube_app;
98 new examples::SpinningCubeApp())); 98 mojo::RunApplication(application_request, &spinning_cube_app);
99 return runner.Run(application_request); 99 return MOJO_RESULT_OK;
100 } 100 }
OLDNEW
« no previous file with comments | « examples/echo/echo_benchmark.cc ('k') | examples/trace_me/trace_me_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698