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

Unified Diff: chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc

Issue 1641353003: GpuArcVideoService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@arc-4-owen-ArcGpuVideoDecodeAccelerator
Patch Set: addressed Owen's comments Created 4 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
Index: chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc
diff --git a/chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc b/chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..490b3b44fbabc6330d4618fb8943ac89ceeaa495
--- /dev/null
+++ b/chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc
@@ -0,0 +1,80 @@
+// Copyright 2016 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 "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h"
+
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
+#include "base/thread_task_runner_handle.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/gpu_service_registry.h"
+#include "content/public/common/service_registry.h"
+
+namespace {
+
+void GetServiceOnIOThread(mojo::InterfacePtrInfo<arc::VideoHost>* ptr_info) {
+ arc::VideoHostPtr host_ptr;
+ content::ServiceRegistry* registry = content::GetGpuServiceRegistry();
+ registry->ConnectToRemoteService<arc::VideoHost>(mojo::GetProxy(&host_ptr));
+
+ // Unbind and reply back to UI thread.
+ *ptr_info = host_ptr.PassInterface();
+}
+
+} // namespace
+
+namespace arc {
+
+GpuArcVideoServiceHost::GpuArcVideoServiceHost(
+ arc::ArcBridgeService* bridge_service)
+ : ArcService(bridge_service),
+ binding_(this),
+ io_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::IO)),
+ weak_factory_(this) {
+ arc_bridge_service()->AddObserver(this);
+}
+
+GpuArcVideoServiceHost::~GpuArcVideoServiceHost() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ arc_bridge_service()->RemoveObserver(this);
+}
+
+void GpuArcVideoServiceHost::OnVideoInstanceReady() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ arc_bridge_service()->video_instance()->Init(
Luis Héctor Chávez 2016/03/16 19:07:54 I'd just add DCHECKs every time you use arc_bridge
kcwu 2016/03/17 08:07:44 Done.
+ binding_.CreateInterfacePtrAndBind());
+}
+
+void GpuArcVideoServiceHost::OnVideoInstanceClosed() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ service_ptr_.reset();
+}
+
+void GpuArcVideoServiceHost::OnRequestArcVideoAcceleratorChannel(
+ uint32_t pid,
+ const OnRequestArcVideoAcceleratorChannelCallback& callback) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ auto* ptr_info = new mojo::InterfacePtrInfo<arc::VideoHost>();
dcheng 2016/03/16 17:44:50 How about using PostTaskAndReplyWithResult rather
kcwu 2016/03/17 08:07:44 Done.
+
+ io_task_runner_->PostTaskAndReply(
+ FROM_HERE, base::Bind(&GetServiceOnIOThread, base::Unretained(ptr_info)),
+ base::Bind(&GpuArcVideoServiceHost::BindServiceAndCreateChannel,
+ weak_factory_.GetWeakPtr(), pid, callback,
+ base::Owned(ptr_info)));
+}
+
+void GpuArcVideoServiceHost::BindServiceAndCreateChannel(
+ uint32_t pid,
+ const OnRequestArcVideoAcceleratorChannelCallback& callback,
+ mojo::InterfacePtrInfo<arc::VideoHost>* ptr_info) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ service_ptr_.Bind(std::move(*ptr_info));
+ service_ptr_->OnRequestArcVideoAcceleratorChannel(pid, callback);
+}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698