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

Unified Diff: components/arc/video/arc_video_bridge.cc

Issue 1451353002: Implement GpuArcVideoService for arc video accelerator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Owen's comments: split GpuArcVideoServiceHost and named the new code arc::ArcVideoBridge Created 5 years 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: components/arc/video/arc_video_bridge.cc
diff --git a/components/arc/video/arc_video_bridge.cc b/components/arc/video/arc_video_bridge.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4a27391dffbc2d1525f8748e176dd9ebd7ba90a5
--- /dev/null
+++ b/components/arc/video/arc_video_bridge.cc
@@ -0,0 +1,53 @@
+// Copyright 2015 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 "components/arc/video/arc_video_bridge.h"
+
+#include <utility>
+
+namespace arc {
+
+ArcVideoBridge::ArcVideoBridge(
+ scoped_ptr<VideoHostDelegate> video_host_delegate)
+ : video_host_delegate_(std::move(video_host_delegate)),
+ binding_(video_host_delegate_.get()) {}
+
+ArcVideoBridge::~ArcVideoBridge() {
+ arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
+ if (bridge_service) {
+ bridge_service->RemoveObserver(this);
+ }
+}
+
+void ArcVideoBridge::StartObservingBridgeServiceChanges() {
+ arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
+ DCHECK(bridge_service);
+ bridge_service->AddObserver(this);
+
+ // If VideoInstance was ready before we AddObserver(), we won't get
+ // OnVideoInstanceReady events. For such case, we have to call it explicitly.
+ if (bridge_service->video_instance())
+ OnVideoInstanceReady();
+}
+
+void ArcVideoBridge::OnStateChanged(arc::ArcBridgeService::State state) {
+ switch (state) {
+ case arc::ArcBridgeService::State::STOPPING:
+ video_host_delegate_->Shutdown();
+ break;
+ default:
+ break;
+ }
+}
+
+void ArcVideoBridge::OnVideoInstanceReady() {
+ arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
+ DCHECK(bridge_service);
+
+ arc::VideoHostPtr host;
+ binding_.Bind(mojo::GetProxy(&host));
+ bridge_service->video_instance()->Init(std::move(host));
+}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698