OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/native_viewport/native_viewport_impl.h" | 5 #include "components/native_viewport/native_viewport_impl.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "components/gles2/gpu_state.h" | 12 #include "components/gles2/gpu_state.h" |
13 #include "components/native_viewport/platform_viewport_headless.h" | 13 #include "components/native_viewport/platform_viewport_headless.h" |
14 #include "mojo/converters/geometry/geometry_type_converters.h" | 14 #include "mojo/converters/geometry/geometry_type_converters.h" |
15 #include "third_party/mojo/src/mojo/public/cpp/application/interface_factory.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/application/interface_factory.h" |
16 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
17 | 17 |
18 namespace native_viewport { | 18 namespace native_viewport { |
19 | 19 |
20 NativeViewportImpl::NativeViewportImpl( | 20 NativeViewportImpl::NativeViewportImpl( |
21 bool is_headless, | 21 bool is_headless, |
22 const scoped_refptr<gles2::GpuState>& gpu_state, | 22 const scoped_refptr<gles2::GpuState>& gpu_state, |
23 mojo::InterfaceRequest<mojo::NativeViewport> request) | 23 mojo::InterfaceRequest<mojo::NativeViewport> request, |
| 24 scoped_ptr<mojo::ServiceRefcount> service_refcount) |
24 : is_headless_(is_headless), | 25 : is_headless_(is_headless), |
| 26 service_refcount_(service_refcount.Pass()), |
25 context_provider_(gpu_state), | 27 context_provider_(gpu_state), |
26 sent_metrics_(false), | 28 sent_metrics_(false), |
27 metrics_(mojo::ViewportMetrics::New()), | 29 metrics_(mojo::ViewportMetrics::New()), |
28 binding_(this, request.Pass()), | 30 binding_(this, request.Pass()), |
29 weak_factory_(this) { | 31 weak_factory_(this) { |
30 binding_.set_error_handler(this); | 32 binding_.set_error_handler(this); |
31 } | 33 } |
32 | 34 |
33 NativeViewportImpl::~NativeViewportImpl() { | 35 NativeViewportImpl::~NativeViewportImpl() { |
34 // Destroy the NativeViewport early on as it may call us back during | 36 // Destroy the NativeViewport early on as it may call us back during |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 145 |
144 default: | 146 default: |
145 break; | 147 break; |
146 } | 148 } |
147 | 149 |
148 event_dispatcher_->OnEvent(event.Pass(), callback); | 150 event_dispatcher_->OnEvent(event.Pass(), callback); |
149 return false; | 151 return false; |
150 } | 152 } |
151 | 153 |
152 void NativeViewportImpl::OnDestroyed() { | 154 void NativeViewportImpl::OnDestroyed() { |
153 // This will signal a connection error and cause us to delete |this|. | 155 delete this; |
154 binding_.Close(); | |
155 } | 156 } |
156 | 157 |
157 void NativeViewportImpl::OnConnectionError() { | 158 void NativeViewportImpl::OnConnectionError() { |
158 binding_.set_error_handler(nullptr); | 159 binding_.set_error_handler(nullptr); |
159 delete this; | 160 delete this; |
160 } | 161 } |
161 | 162 |
162 void NativeViewportImpl::AckEvent(int32 pointer_id) { | 163 void NativeViewportImpl::AckEvent(int32 pointer_id) { |
163 pointers_waiting_on_ack_.erase(pointer_id); | 164 pointers_waiting_on_ack_.erase(pointer_id); |
164 } | 165 } |
165 | 166 |
166 } // namespace native_viewport | 167 } // namespace native_viewport |
OLD | NEW |