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 #ifndef COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
6 #define COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 6 #define COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 class Event; | 25 class Event; |
26 } | 26 } |
27 | 27 |
28 namespace native_viewport { | 28 namespace native_viewport { |
29 | 29 |
30 // A NativeViewportImpl is bound to a message pipe and to a PlatformViewport. | 30 // A NativeViewportImpl is bound to a message pipe and to a PlatformViewport. |
31 // The NativeViewportImpl's lifetime ends when either the message pipe is closed | 31 // The NativeViewportImpl's lifetime ends when either the message pipe is closed |
32 // or the PlatformViewport informs the NativeViewportImpl that it has been | 32 // or the PlatformViewport informs the NativeViewportImpl that it has been |
33 // destroyed. | 33 // destroyed. |
34 class NativeViewportImpl : public mojo::NativeViewport, | 34 class NativeViewportImpl : public mojo::NativeViewport, |
35 public PlatformViewport::Delegate, | 35 public PlatformViewport::Delegate { |
36 public mojo::ErrorHandler { | |
37 public: | 36 public: |
38 NativeViewportImpl(bool is_headless, | 37 NativeViewportImpl(bool is_headless, |
39 const scoped_refptr<gles2::GpuState>& gpu_state, | 38 const scoped_refptr<gles2::GpuState>& gpu_state, |
40 mojo::InterfaceRequest<mojo::NativeViewport> request, | 39 mojo::InterfaceRequest<mojo::NativeViewport> request, |
41 scoped_ptr<mojo::AppRefCount> app_refcount); | 40 scoped_ptr<mojo::AppRefCount> app_refcount); |
42 ~NativeViewportImpl() override; | 41 ~NativeViewportImpl() override; |
43 | 42 |
44 // NativeViewport implementation. | 43 // NativeViewport implementation. |
45 void Create(mojo::SizePtr size, const CreateCallback& callback) override; | 44 void Create(mojo::SizePtr size, const CreateCallback& callback) override; |
46 void RequestMetrics(const RequestMetricsCallback& callback) override; | 45 void RequestMetrics(const RequestMetricsCallback& callback) override; |
47 void Show() override; | 46 void Show() override; |
48 void Hide() override; | 47 void Hide() override; |
49 void Close() override; | 48 void Close() override; |
50 void SetSize(mojo::SizePtr size) override; | 49 void SetSize(mojo::SizePtr size) override; |
51 void GetContextProvider( | 50 void GetContextProvider( |
52 mojo::InterfaceRequest<mojo::ContextProvider> request) override; | 51 mojo::InterfaceRequest<mojo::ContextProvider> request) override; |
53 void SetEventDispatcher( | 52 void SetEventDispatcher( |
54 mojo::NativeViewportEventDispatcherPtr dispatcher) override; | 53 mojo::NativeViewportEventDispatcherPtr dispatcher) override; |
55 | 54 |
56 // PlatformViewport::Delegate implementation. | 55 // PlatformViewport::Delegate implementation. |
57 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) override; | 56 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) override; |
58 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | 57 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
59 float device_pixel_ratio) override; | 58 float device_pixel_ratio) override; |
60 void OnAcceleratedWidgetDestroyed() override; | 59 void OnAcceleratedWidgetDestroyed() override; |
61 bool OnEvent(mojo::EventPtr event) override; | 60 bool OnEvent(mojo::EventPtr event) override; |
62 void OnDestroyed() override; | 61 void OnDestroyed() override; |
63 | 62 |
64 // mojo::ErrorHandler implementation. | |
65 void OnConnectionError() override; | |
66 | |
67 private: | 63 private: |
68 // Callback when the dispatcher has processed a message we're waiting on | 64 // Callback when the dispatcher has processed a message we're waiting on |
69 // an ack from. |pointer_id| identifies the pointer the message was associated | 65 // an ack from. |pointer_id| identifies the pointer the message was associated |
70 // with. | 66 // with. |
71 void AckEvent(int32 pointer_id); | 67 void AckEvent(int32 pointer_id); |
72 | 68 |
73 bool is_headless_; | 69 bool is_headless_; |
74 scoped_ptr<mojo::AppRefCount> app_refcount_; | 70 scoped_ptr<mojo::AppRefCount> app_refcount_; |
75 scoped_ptr<PlatformViewport> platform_viewport_; | 71 scoped_ptr<PlatformViewport> platform_viewport_; |
76 scoped_ptr<OnscreenContextProvider> context_provider_; | 72 scoped_ptr<OnscreenContextProvider> context_provider_; |
77 bool sent_metrics_; | 73 bool sent_metrics_; |
78 mojo::ViewportMetricsPtr metrics_; | 74 mojo::ViewportMetricsPtr metrics_; |
79 CreateCallback create_callback_; | 75 CreateCallback create_callback_; |
80 RequestMetricsCallback metrics_callback_; | 76 RequestMetricsCallback metrics_callback_; |
81 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; | 77 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; |
82 mojo::Binding<mojo::NativeViewport> binding_; | 78 mojo::StrongBinding<mojo::NativeViewport> binding_; |
83 | 79 |
84 // Set of pointer_ids we've sent a move to and are waiting on an ack. | 80 // Set of pointer_ids we've sent a move to and are waiting on an ack. |
85 std::set<int32> pointers_waiting_on_ack_; | 81 std::set<int32> pointers_waiting_on_ack_; |
86 | 82 |
87 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; | 83 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; |
88 | 84 |
89 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); | 85 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); |
90 }; | 86 }; |
91 | 87 |
92 } // namespace native_viewport | 88 } // namespace native_viewport |
93 | 89 |
94 #endif // COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 90 #endif // COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
OLD | NEW |