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

Side by Side 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: modify content gui client hook 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h"
6
7 #include "base/location.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/gpu_service_registry.h"
13 #include "content/public/common/service_registry.h"
14
15 namespace {
16
17 mojo::InterfacePtrInfo<arc::VideoHost> GetServiceOnIOThread() {
18 arc::VideoHostPtr host_ptr;
19 content::ServiceRegistry* registry = content::GetGpuServiceRegistry();
20 registry->ConnectToRemoteService<arc::VideoHost>(mojo::GetProxy(&host_ptr));
dcheng 2016/03/24 20:29:14 Shouldn't this autodeduce?
kcwu 2016/03/28 13:17:34 Done.
21
22 // Unbind and reply back to UI thread.
23 return host_ptr.PassInterface();
24 }
25
26 } // namespace
27
28 namespace arc {
29
30 GpuArcVideoServiceHost::GpuArcVideoServiceHost(
31 arc::ArcBridgeService* bridge_service)
32 : ArcService(bridge_service), binding_(this), weak_factory_(this) {
33 arc_bridge_service()->AddObserver(this);
34 }
35
36 GpuArcVideoServiceHost::~GpuArcVideoServiceHost() {
37 DCHECK(thread_checker_.CalledOnValidThread());
38 arc_bridge_service()->RemoveObserver(this);
39 }
40
41 void GpuArcVideoServiceHost::OnVideoInstanceReady() {
42 DCHECK(thread_checker_.CalledOnValidThread());
43 auto video_instance = arc_bridge_service()->video_instance();
44 DCHECK(video_instance);
45 video_instance->Init(binding_.CreateInterfacePtrAndBind());
46 }
47
48 void GpuArcVideoServiceHost::OnVideoInstanceClosed() {
49 DCHECK(thread_checker_.CalledOnValidThread());
50 service_ptr_.reset();
51 }
52
53 void GpuArcVideoServiceHost::OnRequestArcVideoAcceleratorChannel(
54 uint32_t pid,
55 const OnRequestArcVideoAcceleratorChannelCallback& callback) {
56 DCHECK(thread_checker_.CalledOnValidThread());
57
58 content::BrowserThread::PostTaskAndReplyWithResult(
59 content::BrowserThread::IO, FROM_HERE, base::Bind(&GetServiceOnIOThread),
60 base::Bind(&GpuArcVideoServiceHost::BindServiceAndCreateChannel,
61 weak_factory_.GetWeakPtr(), pid, callback));
62 }
63
64 void GpuArcVideoServiceHost::BindServiceAndCreateChannel(
65 uint32_t pid,
66 const OnRequestArcVideoAcceleratorChannelCallback& callback,
67 mojo::InterfacePtrInfo<arc::VideoHost> ptr_info) {
68 DCHECK(thread_checker_.CalledOnValidThread());
69
70 service_ptr_.Bind(std::move(ptr_info));
71 service_ptr_->OnRequestArcVideoAcceleratorChannel(pid, callback);
72 }
73
74 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698