OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 class NativeViewportImpl | 30 class NativeViewportImpl |
31 : public ServiceConnection<mojo::NativeViewport, | 31 : public ServiceConnection<mojo::NativeViewport, |
32 NativeViewportImpl, | 32 NativeViewportImpl, |
33 shell::Context>, | 33 shell::Context>, |
34 public NativeViewportDelegate { | 34 public NativeViewportDelegate { |
35 public: | 35 public: |
36 NativeViewportImpl() | 36 NativeViewportImpl() |
37 : widget_(gfx::kNullAcceleratedWidget), | 37 : widget_(gfx::kNullAcceleratedWidget), |
38 waiting_for_event_ack_(false) {} | 38 waiting_for_event_ack_(false) {} |
39 virtual ~NativeViewportImpl() { | 39 virtual ~NativeViewportImpl() {} |
40 // Destroy the NativeViewport early on as it may call us back during | |
41 // destruction and we want to be in a known state. | |
42 native_viewport_.reset(); | |
43 } | |
44 | 40 |
45 virtual void Create(const Rect& bounds) OVERRIDE { | 41 virtual void Create(const Rect& bounds) OVERRIDE { |
46 native_viewport_ = | 42 native_viewport_ = |
47 services::NativeViewport::Create(context(), this); | 43 services::NativeViewport::Create(context(), this); |
48 native_viewport_->Init(bounds); | 44 native_viewport_->Init(bounds); |
49 client()->OnCreated(); | 45 client()->OnCreated(); |
50 OnBoundsChanged(bounds); | 46 OnBoundsChanged(bounds); |
51 } | 47 } |
52 | 48 |
53 virtual void Show() OVERRIDE { | 49 virtual void Show() OVERRIDE { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* | 187 MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* |
192 CreateNativeViewportService(mojo::shell::Context* context, | 188 CreateNativeViewportService(mojo::shell::Context* context, |
193 mojo::ScopedShellHandle shell_handle) { | 189 mojo::ScopedShellHandle shell_handle) { |
194 mojo::Application* app = new mojo::Application(shell_handle.Pass()); | 190 mojo::Application* app = new mojo::Application(shell_handle.Pass()); |
195 app->AddServiceConnector( | 191 app->AddServiceConnector( |
196 new mojo::ServiceConnector<mojo::services::NativeViewportImpl, | 192 new mojo::ServiceConnector<mojo::services::NativeViewportImpl, |
197 mojo::shell::Context>(context)); | 193 mojo::shell::Context>(context)); |
198 return app; | 194 return app; |
199 } | 195 } |
200 | 196 |
OLD | NEW |