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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/mojo/clients/mojo_android_overlay.h"
6
7 #include "services/service_manager/public/cpp/connect.h"
8 #include "services/service_manager/public/interfaces/interface_provider.mojom.h"
9
10 namespace media {
11
12 MojoAndroidOverlay::MojoAndroidOverlay(
13 service_manager::mojom::InterfaceProvider* interface_provider,
14 const AndroidOverlay::Config& config)
15 : interface_provider_(interface_provider), config_(config) {
16 // Connect to the provider service.
17 mojom::AndroidOverlayProviderPtr provider_ptr;
18 service_manager::GetInterface<mojom::AndroidOverlayProvider>(
19 interface_provider_, &provider_ptr_);
20
21 // Fill in details of |config| into |mojo_config|. Our caller could do this
22 // too, but since we want to retain |config_| anyway, we do it here.
23 mojom::AndroidOverlayConfigPtr mojo_config =
24 mojom::AndroidOverlayConfig::New();
25 mojo_config->routing_token = config_.routing_token;
26 mojo_config->rect = config_.rect;
27
28 mojom::AndroidOverlayClientPtr ptr;
29 binding_ = base::MakeUnique<mojo::Binding<mojom::AndroidOverlayClient>>(
30 this, mojo::MakeRequest(&ptr));
31
32 provider_ptr_->CreateOverlay(mojo::MakeRequest(&overlay_ptr_), std::move(ptr),
33 std::move(mojo_config));
34 }
35
36 MojoAndroidOverlay::~MojoAndroidOverlay() {
37 // Dropping |overlay_ptr_| will signal to the implementation that we're done
38 // with the surface. If a synchronous destroy is pending, then it can be
39 // allowed to continue.
40 }
41
42 void MojoAndroidOverlay::ScheduleLayout(const gfx::Rect& rect) {
43 // If we haven't gotten the surface yet, then ignore this.
44 if (!received_surface_)
45 return;
46
47 overlay_ptr_->ScheduleLayout(rect);
48 }
49
50 const base::android::JavaRef<jobject>& MojoAndroidOverlay::GetJavaSurface()
51 const {
52 return surface_.j_surface();
53 }
54
55 void MojoAndroidOverlay::OnSurfaceReady(uint64_t surface_key) {
56 // TODO(liberato): ask binder for the surface here, and fill in |surface_|.
57 received_surface_ = true;
58 config_.ready_cb.Run();
59 }
60
61 void MojoAndroidOverlay::OnDestroyed() {
62 // Note that |overlay_ptr_| might not be bound yet, or we might not have ever
63 // gotten a surface. Regardless, the overlay cannot be used.
64
65 if (!received_surface_)
66 config_.failed_cb.Run();
67 else
68 config_.destroyed_cb.Run();
69
70 // Note: we do not delete |overlay_ptr_| here. Our client must delete us to
71 // signal that we should do that, since it still might be in use.
72 }
73
74 } // namespace media
OLDNEW
« 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