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