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

Side by Side Diff: content/common/gpu/media/gpu_arc_video_service.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 4 years, 11 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 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 "content/common/gpu/media/gpu_arc_video_service.h"
6
7 #include "base/logging.h"
8 #include "content/common/gpu/gpu_messages.h"
9 #include "ipc/ipc_listener.h"
10 #include "ipc/ipc_message_macros.h"
11 #include "ipc/ipc_sync_channel.h"
12
13 namespace content {
14
15 // TODO(kcwu) implement ArcVideoAccelerator::Client.
16 class GpuArcVideoService::AcceleratorStub : public IPC::Listener,
17 public IPC::Sender {
18 public:
19 // |owner| outlives AcceleratorStub.
20 explicit AcceleratorStub(GpuArcVideoService* owner) : owner_(owner) {}
21
22 ~AcceleratorStub() override {
23 DCHECK(thread_checker_.CalledOnValidThread());
24 channel_->Close();
25 }
26
27 IPC::ChannelHandle CreateChannel(
28 base::WaitableEvent* shutdown_event,
29 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) {
30 IPC::ChannelHandle handle =
31 IPC::Channel::GenerateVerifiedChannelID("arc-video");
32 channel_ = IPC::SyncChannel::Create(handle, IPC::Channel::MODE_SERVER, this,
33 io_task_runner, false, shutdown_event);
34 #if defined(OS_POSIX)
35 base::ScopedFD client_fd = channel_->TakeClientFileDescriptor();
36 DCHECK(client_fd.is_valid());
37 handle.socket = base::FileDescriptor(std::move(client_fd));
38 #endif
39 return handle;
40 }
41
42 // IPC::Sender implementation:
43 bool Send(IPC::Message* msg) override {
44 DCHECK(msg);
45 return channel_->Send(msg);
46 }
47
48 // IPC::Listener implementation:
49 void OnChannelError() override {
50 DCHECK(thread_checker_.CalledOnValidThread());
51 // RemoveClient will delete |this|.
52 owner_->RemoveClient(this);
53 }
54
55 // IPC::Listener implementation:
56 bool OnMessageReceived(const IPC::Message& msg) override {
jbauman 2015/12/30 01:29:29 This seems reasonable, but have you considered usi
kcwu 2015/12/30 09:40:33 Yes, I will migrate to mojo later.
57 DCHECK(thread_checker_.CalledOnValidThread());
58
59 // TODO(kcwu) Add handlers here.
60 return false;
61 }
62
63 private:
64 base::ThreadChecker thread_checker_;
65 GpuArcVideoService* const owner_;
66 scoped_ptr<IPC::SyncChannel> channel_;
67 };
68
69 GpuArcVideoService::GpuArcVideoService(
70 base::WaitableEvent* shutdown_event,
71 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
72 : shutdown_event_(shutdown_event), io_task_runner_(io_task_runner) {}
73
74 GpuArcVideoService::~GpuArcVideoService() {
75 DCHECK(thread_checker_.CalledOnValidThread());
76
77 accelerator_stubs_.clear();
Pawel Osciak 2015/12/30 07:39:15 Nit: do we need to call this explicitly? Should ha
kcwu 2015/12/30 09:40:33 Done.
78 }
79
80 void GpuArcVideoService::CreateChannel(const CreateChannelCallback& callback) {
81 DCHECK(thread_checker_.CalledOnValidThread());
82
83 scoped_ptr<AcceleratorStub> stub(new AcceleratorStub(this));
84
85 IPC::ChannelHandle handle =
86 stub->CreateChannel(shutdown_event_, io_task_runner_);
87 accelerator_stubs_[stub.get()] = std::move(stub);
88
89 callback.Run(handle);
90 }
91
92 void GpuArcVideoService::RemoveClient(AcceleratorStub* stub) {
93 DCHECK(thread_checker_.CalledOnValidThread());
94
95 accelerator_stubs_.erase(stub);
96 }
97
98 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698