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

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

Issue 316713002: Wire input events through the ViewManagerClient interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 6 years, 6 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/services/native_viewport/DEPS ('k') | mojo/services/public/cpp/input_events/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 336f497162f019814ab8b5df9813ead2954b65d1..e0465bc6eae0657ac29a7b9f31acacf30bb98034 100644
--- a/mojo/services/native_viewport/native_viewport_service.cc
+++ b/mojo/services/native_viewport/native_viewport_service.cc
@@ -5,6 +5,7 @@
#include "mojo/services/native_viewport/native_viewport_service.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
@@ -12,6 +13,7 @@
#include "mojo/services/native_viewport/native_viewport.h"
#include "mojo/services/native_viewport/native_viewport.mojom.h"
#include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
+#include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
#include "ui/events/event.h"
namespace mojo {
@@ -33,7 +35,8 @@ class NativeViewportImpl
NativeViewportImpl(shell::Context* context)
: context_(context),
widget_(gfx::kNullAcceleratedWidget),
- waiting_for_event_ack_(false) {}
+ waiting_for_event_ack_(false),
+ weak_factory_(this) {}
virtual ~NativeViewportImpl() {
// Destroy the NativeViewport early on as it may call us back during
// destruction and we want to be in a known state.
@@ -112,33 +115,10 @@ class NativeViewportImpl
if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event))
return false;
- 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);
- 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);
- 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);
- 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.Pass(),
- base::Bind(&NativeViewportImpl::AckEvent,
- base::Unretained(this)));
+ client()->OnEvent(
+ TypeConverter<EventPtr, ui::Event>::ConvertFrom(*ui_event),
+ base::Bind(&NativeViewportImpl::AckEvent,
+ weak_factory_.GetWeakPtr()));
waiting_for_event_ack_ = true;
return false;
}
@@ -167,6 +147,7 @@ class NativeViewportImpl
InterfaceRequest<CommandBuffer> command_buffer_request_;
scoped_ptr<CommandBufferImpl> command_buffer_;
bool waiting_for_event_ack_;
+ base::WeakPtrFactory<NativeViewportImpl> weak_factory_;
};
} // namespace services
« no previous file with comments | « mojo/services/native_viewport/DEPS ('k') | mojo/services/public/cpp/input_events/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698