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

Unified Diff: mojo/examples/compositor_app/compositor_app.cc

Issue 162213002: Change mojo demo apps to use Application. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add shell() to ServiceFactory::Owner Created 6 years, 10 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
« no previous file with comments | « mojo/examples/aura_demo/aura_demo.cc ('k') | mojo/examples/launcher/launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/compositor_app/compositor_app.cc
diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc
index dce027c42c33d2b0918b534fec32f4b41c0d5764..05ffa71d224711978e4c4d63c396e3e8c33173a6 100644
--- a/mojo/examples/compositor_app/compositor_app.cc
+++ b/mojo/examples/compositor_app/compositor_app.cc
@@ -10,6 +10,7 @@
#include "mojo/public/bindings/allocation_scope.h"
#include "mojo/public/bindings/remote_ptr.h"
#include "mojo/public/gles2/gles2_cpp.h"
+#include "mojo/public/shell/application.h"
#include "mojo/public/system/core.h"
#include "mojo/public/system/macros.h"
#include "mojo/services/native_viewport/geometry_conversions.h"
@@ -30,67 +31,46 @@
namespace mojo {
namespace examples {
-class SampleApp : public ShellClient {
+class SampleApp : public Application, public NativeViewportClient {
public:
- explicit SampleApp(ScopedShellHandle shell_handle)
- : shell_(shell_handle.Pass(), this) {
- InterfacePipe<NativeViewport, AnyInterface> pipe;
+ explicit SampleApp(MojoHandle shell_handle) : Application(shell_handle) {
+ InterfacePipe<NativeViewport, AnyInterface> viewport_pipe;
AllocationScope scope;
- shell_->Connect("mojo:mojo_native_viewport_service",
- pipe.handle_to_peer.Pass());
-
- native_viewport_client_.reset(
- new NativeViewportClientImpl(pipe.handle_to_self.Pass()));
+ shell()->Connect("mojo:mojo_native_viewport_service",
+ viewport_pipe.handle_to_peer.Pass());
+
+ viewport_.reset(viewport_pipe.handle_to_self.Pass(), this);
+ viewport_->Create(gfx::Rect(10, 10, 800, 600));
+ viewport_->Show();
+ ScopedMessagePipeHandle gles2_handle;
+ ScopedMessagePipeHandle gles2_client_handle;
+ CreateMessagePipe(&gles2_handle, &gles2_client_handle);
+
+ viewport_->CreateGLES2Context(gles2_client_handle.Pass());
+ host_.reset(new CompositorHost(gles2_handle.Pass()));
}
- virtual void AcceptConnection(const mojo::String& url,
- ScopedMessagePipeHandle handle) MOJO_OVERRIDE {
- NOTREACHED() << "SampleApp can't be connected to.";
+ virtual void OnCreated() MOJO_OVERRIDE {
}
- private:
- class NativeViewportClientImpl : public NativeViewportClient {
- public:
- explicit NativeViewportClientImpl(
- ScopedNativeViewportHandle viewport_handle)
- : viewport_(viewport_handle.Pass(), this) {
- AllocationScope allocation;
- viewport_->Create(gfx::Rect(10, 10, 800, 600));
- viewport_->Show();
- ScopedMessagePipeHandle gles2_handle;
- ScopedMessagePipeHandle gles2_client_handle;
- CreateMessagePipe(&gles2_handle, &gles2_client_handle);
-
- viewport_->CreateGLES2Context(gles2_client_handle.Pass());
- host_.reset(new CompositorHost(gles2_handle.Pass()));
- }
-
- virtual ~NativeViewportClientImpl() {}
-
- virtual void OnCreated() MOJO_OVERRIDE {
- }
-
- virtual void OnDestroyed() MOJO_OVERRIDE {
- base::MessageLoop::current()->Quit();
- }
+ virtual void OnDestroyed() MOJO_OVERRIDE {
+ base::MessageLoop::current()->Quit();
+ }
- virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE {
- host_->SetSize(bounds.size());
- }
+ virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE {
+ host_->SetSize(bounds.size());
+ }
- virtual void OnEvent(const Event& event) MOJO_OVERRIDE {
- if (!event.location().is_null()) {
- viewport_->AckEvent(event);
- }
+ virtual void OnEvent(const Event& event) MOJO_OVERRIDE {
+ if (!event.location().is_null()) {
+ viewport_->AckEvent(event);
}
+ }
- private:
- RemotePtr<NativeViewport> viewport_;
- scoped_ptr<CompositorHost> host_;
- };
- RemotePtr<Shell> shell_;
- scoped_ptr<NativeViewportClientImpl> native_viewport_client_;
+ private:
+ RemotePtr<NativeViewport> viewport_;
+ scoped_ptr<CompositorHost> host_;
};
} // namespace examples
@@ -101,10 +81,7 @@ extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain(
base::MessageLoop loop;
mojo::GLES2Initializer gles2;
- mojo::examples::SampleApp app(
- mojo::MakeScopedHandle(mojo::ShellHandle(shell_handle)).Pass());
-
+ mojo::examples::SampleApp app(shell_handle);
loop.Run();
-
return MOJO_RESULT_OK;
}
« no previous file with comments | « mojo/examples/aura_demo/aura_demo.cc ('k') | mojo/examples/launcher/launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698