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

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

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 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 side-by-side diff with in-line comments
Download patch
Index: mojo/examples/sample_app/sample_app.cc
diff --git a/mojo/examples/sample_app/sample_app.cc b/mojo/examples/sample_app/sample_app.cc
index 27e8796e7d2ba0f1c78c6071c23d5ac6149951e8..d8c1199beeb9fb328419334175d03fffe021cbef 100644
--- a/mojo/examples/sample_app/sample_app.cc
+++ b/mojo/examples/sample_app/sample_app.cc
@@ -6,7 +6,6 @@
#include <string>
#include "mojo/examples/sample_app/gles2_client_impl.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "mojo/public/cpp/environment/environment.h"
#include "mojo/public/cpp/gles2/gles2.h"
#include "mojo/public/cpp/shell/application.h"
@@ -35,18 +34,14 @@ class SampleApp : public Application, public NativeViewportClient {
ConnectTo("mojo:mojo_native_viewport_service", &viewport_);
viewport_->SetClient(this);
- AllocationScope scope;
-
- Rect::Builder rect;
- Point::Builder point;
- point.set_x(10);
- point.set_y(10);
- rect.set_position(point.Finish());
- Size::Builder size;
- size.set_width(800);
- size.set_height(600);
- rect.set_size(size.Finish());
- viewport_->Create(rect.Finish());
+ RectPtr rect(Rect::New());
+ rect->position = Point::New();
+ rect->position->x = 10;
+ rect->position->y = 10;
+ rect->size = Size::New();
+ rect->size->width = 800;
+ rect->size->height = 600;
+ viewport_->Create(rect.Pass());
viewport_->Show();
MessagePipe gles2_pipe;
@@ -66,14 +61,17 @@ class SampleApp : public Application, public NativeViewportClient {
RunLoop::current()->Quit();
}
- virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE {
- gles2_client_->SetSize(bounds.size());
+ virtual void OnBoundsChanged(RectPtr bounds) MOJO_OVERRIDE {
+ assert(bounds);
+ assert(bounds->size);
+ gles2_client_->SetSize(*bounds->size);
}
- virtual void OnEvent(const Event& event,
+ virtual void OnEvent(EventPtr event,
const Callback<void()>& callback) MOJO_OVERRIDE {
- if (!event.location().is_null())
- gles2_client_->HandleInputEvent(event);
+ assert(event);
+ if (event->location)
+ gles2_client_->HandleInputEvent(*event);
callback.Run();
}

Powered by Google App Engine
This is Rietveld 408576698