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

Side by Side Diff: mojo/services/native_viewport/native_viewport_service.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: convert everything over, remove ApplicationConnection::AddService Created 6 years, 5 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 | Annotate | Revision Log
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 "mojo/services/native_viewport/native_viewport_service.h" 5 #include "mojo/services/native_viewport/native_viewport_service.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "mojo/public/cpp/application/application_delegate.h" 11 #include "mojo/public/cpp/application/application_delegate.h"
12 #include "mojo/public/cpp/application/context_interface_factory.h"
12 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 13 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
13 #include "mojo/services/gles2/command_buffer_impl.h" 14 #include "mojo/services/gles2/command_buffer_impl.h"
14 #include "mojo/services/native_viewport/native_viewport.h" 15 #include "mojo/services/native_viewport/native_viewport.h"
15 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 16 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
16 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 17 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
17 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom. h" 18 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom. h"
18 #include "ui/events/event.h" 19 #include "ui/events/event.h"
19 20
20 namespace mojo { 21 namespace mojo {
21 namespace services { 22 namespace services {
22 namespace { 23 namespace {
23 24
24 bool IsRateLimitedEventType(ui::Event* event) { 25 bool IsRateLimitedEventType(ui::Event* event) {
25 return event->type() == ui::ET_MOUSE_MOVED || 26 return event->type() == ui::ET_MOUSE_MOVED ||
26 event->type() == ui::ET_MOUSE_DRAGGED || 27 event->type() == ui::ET_MOUSE_DRAGGED ||
27 event->type() == ui::ET_TOUCH_MOVED; 28 event->type() == ui::ET_TOUCH_MOVED;
28 } 29 }
29 30
30 } // namespace 31 } // namespace
31 32
32 class NativeViewportImpl 33 class NativeViewportImpl : public InterfaceImpl<mojo::NativeViewport>,
33 : public InterfaceImpl<mojo::NativeViewport>, 34 public NativeViewportDelegate {
34 public NativeViewportDelegate {
35 public: 35 public:
36 NativeViewportImpl(ApplicationConnection* connection, 36 explicit NativeViewportImpl(shell::Context* context)
37 shell::Context* context)
38 : context_(context), 37 : context_(context),
39 widget_(gfx::kNullAcceleratedWidget), 38 widget_(gfx::kNullAcceleratedWidget),
40 waiting_for_event_ack_(false), 39 waiting_for_event_ack_(false),
41 weak_factory_(this) {} 40 weak_factory_(this) {}
42 virtual ~NativeViewportImpl() { 41 virtual ~NativeViewportImpl() {
43 // Destroy the NativeViewport early on as it may call us back during 42 // Destroy the NativeViewport early on as it may call us back during
44 // destruction and we want to be in a known state. 43 // destruction and we want to be in a known state.
45 native_viewport_.reset(); 44 native_viewport_.reset();
46 } 45 }
47 46
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 147
149 shell::Context* context_; 148 shell::Context* context_;
150 gfx::AcceleratedWidget widget_; 149 gfx::AcceleratedWidget widget_;
151 scoped_ptr<services::NativeViewport> native_viewport_; 150 scoped_ptr<services::NativeViewport> native_viewport_;
152 InterfaceRequest<CommandBuffer> command_buffer_request_; 151 InterfaceRequest<CommandBuffer> command_buffer_request_;
153 scoped_ptr<CommandBufferImpl> command_buffer_; 152 scoped_ptr<CommandBufferImpl> command_buffer_;
154 bool waiting_for_event_ack_; 153 bool waiting_for_event_ack_;
155 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; 154 base::WeakPtrFactory<NativeViewportImpl> weak_factory_;
156 }; 155 };
157 156
158 class NVSDelegate : public ApplicationDelegate { 157 class NVSDelegate
158 : public ApplicationDelegate,
159 public ContextInterfaceFactory<NativeViewportImpl, mojo::shell::Context> {
darin (slow to review) 2014/07/15 06:10:38 nit: you are already inside the mojo:: namespace,
159 public: 160 public:
160 NVSDelegate(shell::Context* context) : context_(context) {} 161 explicit NVSDelegate(shell::Context* context)
162 : ContextInterfaceFactory(context) {}
161 virtual ~NVSDelegate() {} 163 virtual ~NVSDelegate() {}
162 164
165 // ApplicationDelegate implementation.
163 virtual bool ConfigureIncomingConnection( 166 virtual bool ConfigureIncomingConnection(
164 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { 167 ApplicationConnection* connection) OVERRIDE {
165 connection->AddService<NativeViewportImpl>(context_); 168 connection->AddServiceFactory(this);
166 return true; 169 return true;
167 } 170 }
168
169 private:
170 mojo::shell::Context* context_;
171 }; 171 };
172 172
173 } // namespace services 173 } // namespace services
174 } // namespace mojo 174 } // namespace mojo
175 175
176 MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* 176 MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl*
177 CreateNativeViewportService( 177 CreateNativeViewportService(
178 mojo::shell::Context* context, 178 mojo::shell::Context* context,
179 mojo::ScopedMessagePipeHandle service_provider_handle) { 179 mojo::ScopedMessagePipeHandle service_provider_handle) {
180 mojo::ApplicationImpl* app = new mojo::ApplicationImpl( 180 mojo::ApplicationImpl* app = new mojo::ApplicationImpl(
181 new mojo::services::NVSDelegate(context), service_provider_handle.Pass()); 181 new mojo::services::NVSDelegate(context), service_provider_handle.Pass());
182 return app; 182 return app;
183 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698