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

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 Pawel's comments 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 base::NonThreadSafe {
dcheng 2015/12/29 00:43:23 Ditto, use ThreadChecker.
kcwu 2015/12/29 03:36:32 Done.
19 public:
20 // |owner| outlives AcceleratorStub.
21 AcceleratorStub(GpuArcVideoService* owner) : owner_(owner) {}
dcheng 2015/12/29 00:43:23 explicit
kcwu 2015/12/29 03:36:32 Done.
22
23 ~AcceleratorStub() override {
24 DCHECK(CalledOnValidThread());
25 channel_->Close();
26 }
27
28 IPC::ChannelHandle CreateChannel(
29 base::WaitableEvent* shutdown_event,
30 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) {
31 IPC::ChannelHandle handle =
32 IPC::Channel::GenerateVerifiedChannelID("arc-video");
33 channel_ = IPC::SyncChannel::Create(handle, IPC::Channel::MODE_SERVER, this,
34 io_task_runner, false, shutdown_event);
35 #if defined(OS_POSIX)
36 base::ScopedFD client_fd = channel_->TakeClientFileDescriptor();
37 DCHECK(client_fd.is_valid());
38 handle.socket = base::FileDescriptor(std::move(client_fd));
39 #endif
40 return handle;
41 }
42
43 // IPC::Sender implementation:
44 bool Send(IPC::Message* msg) override {
45 DCHECK(msg);
46 return channel_->Send(msg);
47 }
48
49 // IPC::Listener implementation:
50 void OnChannelError() override {
51 DCHECK(CalledOnValidThread());
52 // RemoveClient will delete |this|.
53 owner_->RemoveClient(this);
54 }
55
56 // IPC::Listener implementation:
57 bool OnMessageReceived(const IPC::Message& msg) override {
58 DCHECK(CalledOnValidThread());
59
60 // TODO(kcwu) Add handlers here.
61 return false;
62 }
63
64 private:
65 GpuArcVideoService* owner_;
dcheng 2015/12/29 00:43:23 GpuArcVideoService* const
kcwu 2015/12/29 03:36:32 Done.
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(CalledOnValidThread());
76
77 accelerator_stubs_.clear();
78 }
79
80 void GpuArcVideoService::CreateChannel(const CreateChannelCallback& callback) {
81 DCHECK(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 accelerator_stubs_.erase(stub);
94 }
95
96 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698