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

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

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/services/native_viewport/native_viewport_service.cc
diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc
index 9bec7eaca4372fd1f7d661c4a343d679e0091be1..96d9ec50ca42bc12ecd19b55e71278971e0b8fdc 100644
--- a/mojo/services/native_viewport/native_viewport_service.cc
+++ b/mojo/services/native_viewport/native_viewport_service.cc
@@ -7,7 +7,6 @@
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
#include "mojo/services/gles2/command_buffer_impl.h"
#include "mojo/services/native_viewport/native_viewport.h"
@@ -41,12 +40,12 @@ class NativeViewportImpl
native_viewport_.reset();
}
- virtual void Create(const Rect& bounds) OVERRIDE {
+ virtual void Create(RectPtr bounds) OVERRIDE {
native_viewport_ =
services::NativeViewport::Create(context_, this);
- native_viewport_->Init(bounds);
+ native_viewport_->Init(bounds.To<gfx::Rect>());
client()->OnCreated();
- OnBoundsChanged(bounds);
+ OnBoundsChanged(bounds.To<gfx::Rect>());
}
virtual void Show() OVERRIDE {
@@ -63,9 +62,8 @@ class NativeViewportImpl
native_viewport_->Close();
}
- virtual void SetBounds(const Rect& bounds) OVERRIDE {
- AllocationScope scope;
- native_viewport_->SetBounds(bounds);
+ virtual void SetBounds(RectPtr bounds) OVERRIDE {
+ native_viewport_->SetBounds(bounds.To<gfx::Rect>());
}
virtual void CreateGLES2Context(ScopedMessagePipeHandle client_handle)
@@ -117,38 +115,33 @@ class NativeViewportImpl
if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event))
return false;
- AllocationScope scope;
-
- Event::Builder event;
- event.set_action(ui_event->type());
- event.set_flags(ui_event->flags());
- event.set_time_stamp(ui_event->time_stamp().ToInternalValue());
+ EventPtr event(Event::New());
+ event->action = ui_event->type();
+ event->flags = ui_event->flags();
+ event->time_stamp = ui_event->time_stamp().ToInternalValue();
if (ui_event->IsMouseEvent() || ui_event->IsTouchEvent()) {
ui::LocatedEvent* located_event =
static_cast<ui::LocatedEvent*>(ui_event);
- Point::Builder location;
- location.set_x(located_event->location().x());
- location.set_y(located_event->location().y());
- event.set_location(location.Finish());
+ event->location = Point::New();
+ event->location->x = located_event->location().x();
+ event->location->y = located_event->location().y();
}
if (ui_event->IsTouchEvent()) {
ui::TouchEvent* touch_event = static_cast<ui::TouchEvent*>(ui_event);
- TouchData::Builder touch_data;
- touch_data.set_pointer_id(touch_event->touch_id());
- event.set_touch_data(touch_data.Finish());
+ event->touch_data = TouchData::New();
+ event->touch_data->pointer_id = touch_event->touch_id();
} else if (ui_event->IsKeyEvent()) {
ui::KeyEvent* key_event = static_cast<ui::KeyEvent*>(ui_event);
- KeyData::Builder key_data;
- key_data.set_key_code(key_event->key_code());
- key_data.set_is_char(key_event->is_char());
- event.set_key_data(key_data.Finish());
+ event->key_data = KeyData::New();
+ event->key_data->key_code = key_event->key_code();
+ event->key_data->is_char = key_event->is_char();
}
- client()->OnEvent(event.Finish(),
- base::Bind(&NativeViewportImpl::AckEvent,
- base::Unretained(this)));
+ client()->OnEvent(event.Pass(),
+ base::Bind(&NativeViewportImpl::AckEvent,
+ base::Unretained(this)));
waiting_for_event_ack_ = true;
return false;
}
@@ -161,8 +154,7 @@ class NativeViewportImpl
virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE {
CreateCommandBufferIfNeeded();
- AllocationScope scope;
- client()->OnBoundsChanged(bounds);
+ client()->OnBoundsChanged(Rect::From(bounds));
}
virtual void OnDestroyed() OVERRIDE {
« no previous file with comments | « mojo/services/gles2/command_buffer_type_conversions.cc ('k') | mojo/services/public/cpp/geometry/geometry_type_converters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698