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

Unified Diff: media/mojo/clients/mojo_android_overlay.cc

Issue 2688193002: Mojo framework for AndroidOverlay. (Closed)
Patch Set: fixed mojo manifest bug introduced by rebase Created 3 years, 9 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
« no previous file with comments | « media/mojo/clients/mojo_android_overlay.h ('k') | media/mojo/clients/mojo_android_overlay_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/clients/mojo_android_overlay.cc
diff --git a/media/mojo/clients/mojo_android_overlay.cc b/media/mojo/clients/mojo_android_overlay.cc
new file mode 100644
index 0000000000000000000000000000000000000000..636a50f0231551d0b16ccdfc4524dc02e13a14dd
--- /dev/null
+++ b/media/mojo/clients/mojo_android_overlay.cc
@@ -0,0 +1,74 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/mojo/clients/mojo_android_overlay.h"
+
+#include "services/service_manager/public/cpp/connect.h"
+#include "services/service_manager/public/interfaces/interface_provider.mojom.h"
+
+namespace media {
+
+MojoAndroidOverlay::MojoAndroidOverlay(
+ service_manager::mojom::InterfaceProvider* interface_provider,
+ const AndroidOverlay::Config& config)
+ : interface_provider_(interface_provider), config_(config) {
+ // Connect to the provider service.
+ mojom::AndroidOverlayProviderPtr provider_ptr;
+ service_manager::GetInterface<mojom::AndroidOverlayProvider>(
+ interface_provider_, &provider_ptr_);
+
+ // Fill in details of |config| into |mojo_config|. Our caller could do this
+ // too, but since we want to retain |config_| anyway, we do it here.
+ mojom::AndroidOverlayConfigPtr mojo_config =
+ mojom::AndroidOverlayConfig::New();
+ mojo_config->routing_token = config_.routing_token;
+ mojo_config->rect = config_.rect;
+
+ mojom::AndroidOverlayClientPtr ptr;
+ binding_ = base::MakeUnique<mojo::Binding<mojom::AndroidOverlayClient>>(
+ this, mojo::MakeRequest(&ptr));
+
+ provider_ptr_->CreateOverlay(mojo::MakeRequest(&overlay_ptr_), std::move(ptr),
+ std::move(mojo_config));
+}
+
+MojoAndroidOverlay::~MojoAndroidOverlay() {
+ // Dropping |overlay_ptr_| will signal to the implementation that we're done
+ // with the surface. If a synchronous destroy is pending, then it can be
+ // allowed to continue.
+}
+
+void MojoAndroidOverlay::ScheduleLayout(const gfx::Rect& rect) {
+ // If we haven't gotten the surface yet, then ignore this.
+ if (!received_surface_)
+ return;
+
+ overlay_ptr_->ScheduleLayout(rect);
+}
+
+const base::android::JavaRef<jobject>& MojoAndroidOverlay::GetJavaSurface()
+ const {
+ return surface_.j_surface();
+}
+
+void MojoAndroidOverlay::OnSurfaceReady(uint64_t surface_key) {
+ // TODO(liberato): ask binder for the surface here, and fill in |surface_|.
+ received_surface_ = true;
+ config_.ready_cb.Run();
+}
+
+void MojoAndroidOverlay::OnDestroyed() {
+ // Note that |overlay_ptr_| might not be bound yet, or we might not have ever
+ // gotten a surface. Regardless, the overlay cannot be used.
+
+ if (!received_surface_)
+ config_.failed_cb.Run();
+ else
+ config_.destroyed_cb.Run();
+
+ // Note: we do not delete |overlay_ptr_| here. Our client must delete us to
+ // signal that we should do that, since it still might be in use.
+}
+
+} // namespace media
« no previous file with comments | « media/mojo/clients/mojo_android_overlay.h ('k') | media/mojo/clients/mojo_android_overlay_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698