OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 "components/arc/video/arc_video_bridge.h" | |
6 | |
7 #include <utility> | |
8 | |
9 namespace arc { | |
10 | |
11 ArcVideoBridge::ArcVideoBridge( | |
12 scoped_ptr<VideoHostDelegate> video_host_delegate) | |
13 : video_host_delegate_(std::move(video_host_delegate)), | |
14 binding_(video_host_delegate_.get()) {} | |
15 | |
16 ArcVideoBridge::~ArcVideoBridge() { | |
17 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | |
18 if (bridge_service) { | |
19 bridge_service->RemoveObserver(this); | |
20 } | |
21 } | |
22 | |
23 void ArcVideoBridge::StartObservingBridgeServiceChanges() { | |
24 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | |
25 DCHECK(bridge_service); | |
26 bridge_service->AddObserver(this); | |
27 | |
28 // If VideoInstance was ready before we AddObserver(), we won't get | |
29 // OnVideoInstanceReady events. For such case, we have to call it explicitly. | |
30 if (bridge_service->video_instance()) | |
31 OnVideoInstanceReady(); | |
32 } | |
33 | |
34 void ArcVideoBridge::OnStateChanged(arc::ArcBridgeService::State state) { | |
35 switch (state) { | |
36 case arc::ArcBridgeService::State::STOPPING: | |
37 video_host_delegate_->Shutdown(); | |
hidehiko
2016/01/05 08:41:05
Shutdown() sounds like we will never reuse this (s
kcwu
2016/01/06 06:12:41
Done.
| |
38 break; | |
39 default: | |
40 break; | |
41 } | |
42 } | |
43 | |
44 void ArcVideoBridge::OnVideoInstanceReady() { | |
45 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | |
46 DCHECK(bridge_service); | |
47 | |
48 arc::VideoHostPtr host; | |
49 binding_.Bind(mojo::GetProxy(&host)); | |
50 bridge_service->video_instance()->Init(std::move(host)); | |
51 } | |
52 | |
53 } // namespace arc | |
OLD | NEW |