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

Unified Diff: services/native_viewport/native_viewport_impl.h

Issue 878933005: Remove NativeViewportClient (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: services/native_viewport/native_viewport_impl.h
diff --git a/services/native_viewport/native_viewport_impl.h b/services/native_viewport/native_viewport_impl.h
index da11d64b55ecd7d1af53443d81b9ead79203fc79..5485ee183c7200603f270357882073104fcfc4b3 100644
--- a/services/native_viewport/native_viewport_impl.h
+++ b/services/native_viewport/native_viewport_impl.h
@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "cc/surfaces/surface_id.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/gpu/public/interfaces/gpu.mojom.h"
#include "mojo/services/native_viewport/public/interfaces/native_viewport.mojom.h"
#include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
@@ -25,15 +26,27 @@ class ApplicationImpl;
namespace native_viewport {
class ViewportSurface;
-class NativeViewportImpl : public mojo::InterfaceImpl<mojo::NativeViewport>,
- public PlatformViewport::Delegate {
+// A NativeViewportImpl is bound to a message pipe and to a PlatformViewport.
+// The NativeViewportImpl's lifetime ends when either the message pipe is closed
+// or the PlatformViewport informs the NativeViewportImpl that it has been
+// destroyed.
+class NativeViewportImpl : public mojo::NativeViewport,
+ public PlatformViewport::Delegate,
+ public mojo::ErrorHandler {
+ using CreateCallback = mojo::Callback<void(uint64_t native_viewport_id,
+ mojo::ViewportMetricsPtr metrics)>;
+ using MetricsCallback =
+ mojo::Callback<void(mojo::ViewportMetricsPtr metrics)>;
+
public:
- NativeViewportImpl(mojo::ApplicationImpl* app, bool is_headless);
+ NativeViewportImpl(mojo::ApplicationImpl* app,
+ bool is_headless,
+ mojo::InterfaceRequest<mojo::NativeViewport> request);
~NativeViewportImpl() override;
// InterfaceImpl<NativeViewport> implementation.
- void Create(mojo::SizePtr size,
- const mojo::Callback<void(uint64_t)>& callback) override;
+ void Create(mojo::SizePtr size, const CreateCallback& callback) override;
+ void RequestMetrics(const MetricsCallback& callback) override;
void Show() override;
void Hide() override;
void Close() override;
@@ -48,22 +61,26 @@ class NativeViewportImpl : public mojo::InterfaceImpl<mojo::NativeViewport>,
bool OnEvent(ui::Event* ui_event) override;
void OnDestroyed() override;
+ // mojo::ErrorHandler implementation.
+ void OnConnectionError() override;
+
void AckEvent();
private:
- void ProcessOnMetricsChanged();
-
bool is_headless_;
scoped_ptr<PlatformViewport> platform_viewport_;
scoped_ptr<ViewportSurface> viewport_surface_;
uint64_t widget_id_;
+ bool sent_metrics_;
mojo::ViewportMetricsPtr metrics_;
mojo::GpuPtr gpu_service_;
mojo::SurfacePtr surface_;
cc::SurfaceId child_surface_id_;
bool waiting_for_event_ack_;
- mojo::Callback<void(uint64_t)> create_callback_;
+ CreateCallback create_callback_;
+ MetricsCallback metrics_callback_;
mojo::NativeViewportEventDispatcherPtr event_dispatcher_;
+ mojo::Binding<mojo::NativeViewport> binding_;
base::WeakPtrFactory<NativeViewportImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl);

Powered by Google App Engine
This is Rietveld 408576698