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

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

Issue 287003004: Revert 270867 "Mojo: Internalize ServiceConnector<>" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "mojo/public/cpp/bindings/allocation_scope.h" 10 #include "mojo/public/cpp/bindings/allocation_scope.h"
(...skipping 10 matching lines...) Expand all
21 21
22 bool IsRateLimitedEventType(ui::Event* event) { 22 bool IsRateLimitedEventType(ui::Event* event) {
23 return event->type() == ui::ET_MOUSE_MOVED || 23 return event->type() == ui::ET_MOUSE_MOVED ||
24 event->type() == ui::ET_MOUSE_DRAGGED || 24 event->type() == ui::ET_MOUSE_DRAGGED ||
25 event->type() == ui::ET_TOUCH_MOVED; 25 event->type() == ui::ET_TOUCH_MOVED;
26 } 26 }
27 27
28 } 28 }
29 29
30 class NativeViewportImpl 30 class NativeViewportImpl
31 : public InterfaceImpl<mojo::NativeViewport>, 31 : public ServiceConnection<mojo::NativeViewport,
32 NativeViewportImpl,
33 shell::Context>,
32 public NativeViewportDelegate { 34 public NativeViewportDelegate {
33 public: 35 public:
34 NativeViewportImpl(shell::Context* context) 36 NativeViewportImpl()
35 : context_(context), 37 : widget_(gfx::kNullAcceleratedWidget),
36 widget_(gfx::kNullAcceleratedWidget),
37 waiting_for_event_ack_(false) {} 38 waiting_for_event_ack_(false) {}
38 virtual ~NativeViewportImpl() { 39 virtual ~NativeViewportImpl() {
39 // Destroy the NativeViewport early on as it may call us back during 40 // Destroy the NativeViewport early on as it may call us back during
40 // destruction and we want to be in a known state. 41 // destruction and we want to be in a known state.
41 native_viewport_.reset(); 42 native_viewport_.reset();
42 } 43 }
43 44
44 virtual void OnConnectionError() OVERRIDE {}
45
46 virtual void Create(const Rect& bounds) OVERRIDE { 45 virtual void Create(const Rect& bounds) OVERRIDE {
47 native_viewport_ = 46 native_viewport_ =
48 services::NativeViewport::Create(context_, this); 47 services::NativeViewport::Create(context(), this);
49 native_viewport_->Init(bounds); 48 native_viewport_->Init(bounds);
50 client()->OnCreated(); 49 client()->OnCreated();
51 OnBoundsChanged(bounds); 50 OnBoundsChanged(bounds);
52 } 51 }
53 52
54 virtual void Show() OVERRIDE { 53 virtual void Show() OVERRIDE {
55 native_viewport_->Show(); 54 native_viewport_->Show();
56 } 55 }
57 56
58 virtual void Hide() OVERRIDE { 57 virtual void Hide() OVERRIDE {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 client()->OnBoundsChanged(bounds); 167 client()->OnBoundsChanged(bounds);
169 } 168 }
170 169
171 virtual void OnDestroyed() OVERRIDE { 170 virtual void OnDestroyed() OVERRIDE {
172 command_buffer_.reset(); 171 command_buffer_.reset();
173 client()->OnDestroyed(); 172 client()->OnDestroyed();
174 base::MessageLoop::current()->Quit(); 173 base::MessageLoop::current()->Quit();
175 } 174 }
176 175
177 private: 176 private:
178 shell::Context* context_;
179 gfx::AcceleratedWidget widget_; 177 gfx::AcceleratedWidget widget_;
180 scoped_ptr<services::NativeViewport> native_viewport_; 178 scoped_ptr<services::NativeViewport> native_viewport_;
181 ScopedMessagePipeHandle command_buffer_handle_; 179 ScopedMessagePipeHandle command_buffer_handle_;
182 scoped_ptr<CommandBufferImpl> command_buffer_; 180 scoped_ptr<CommandBufferImpl> command_buffer_;
183 bool waiting_for_event_ack_; 181 bool waiting_for_event_ack_;
184 }; 182 };
185 183
186 } // namespace services 184 } // namespace services
187 } // namespace mojo 185 } // namespace mojo
188 186
189 187
190 MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* 188 MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application*
191 CreateNativeViewportService(mojo::shell::Context* context, 189 CreateNativeViewportService(mojo::shell::Context* context,
192 mojo::ScopedMessagePipeHandle shell_handle) { 190 mojo::ScopedMessagePipeHandle shell_handle) {
193 mojo::Application* app = new mojo::Application(shell_handle.Pass()); 191 mojo::Application* app = new mojo::Application(shell_handle.Pass());
194 app->AddService<mojo::services::NativeViewportImpl>(context); 192 app->AddServiceConnector(
193 new mojo::ServiceConnector<mojo::services::NativeViewportImpl,
194 mojo::shell::Context>(context));
195 return app; 195 return app;
196 } 196 }
197 197
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698