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

Side by Side Diff: media/gpu/ipc/service/media_gpu_channel_manager.cc

Issue 2526953003: Add MediaGpuChannelManager::LookupChannel(). (Closed)
Patch Set: Implement MockGpuVideoAcceleratorFactories::GetCommandBufferRouteId(). Created 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/gpu/ipc/service/media_gpu_channel_manager.h" 5 #include "media/gpu/ipc/service/media_gpu_channel_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "gpu/ipc/service/gpu_channel.h" 10 #include "gpu/ipc/service/gpu_channel.h"
11 #include "gpu/ipc/service/gpu_channel_manager.h" 11 #include "gpu/ipc/service/gpu_channel_manager.h"
12 #include "ipc/ipc_message_macros.h" 12 #include "ipc/ipc_message_macros.h"
13 #include "ipc/param_traits_macros.h" 13 #include "ipc/param_traits_macros.h"
14 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" 14 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h"
15 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" 15 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
16 #include "media/gpu/ipc/service/media_gpu_channel.h" 16 #include "media/gpu/ipc/service/media_gpu_channel.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 MediaGpuChannelManager::MediaGpuChannelManager( 20 MediaGpuChannelManager::MediaGpuChannelManager(
21 gpu::GpuChannelManager* channel_manager) 21 gpu::GpuChannelManager* channel_manager)
22 : channel_manager_(channel_manager) {} 22 : channel_manager_(channel_manager) {}
23 23
24 MediaGpuChannelManager::~MediaGpuChannelManager() {} 24 MediaGpuChannelManager::~MediaGpuChannelManager() {}
25 25
26 void MediaGpuChannelManager::AddChannel(int32_t client_id) { 26 void MediaGpuChannelManager::AddChannel(int32_t client_id) {
27 gpu::GpuChannel* gpu_channel = channel_manager_->LookupChannel(client_id); 27 gpu::GpuChannel* gpu_channel = channel_manager_->LookupChannel(client_id);
28 DCHECK(gpu_channel); 28 DCHECK(gpu_channel);
29 base::UnguessableToken channel_token = base::UnguessableToken::Create();
29 std::unique_ptr<MediaGpuChannel> media_gpu_channel( 30 std::unique_ptr<MediaGpuChannel> media_gpu_channel(
30 new MediaGpuChannel(gpu_channel)); 31 new MediaGpuChannel(gpu_channel, channel_token));
31 gpu_channel->SetUnhandledMessageListener(media_gpu_channel.get()); 32 gpu_channel->SetUnhandledMessageListener(media_gpu_channel.get());
32 media_gpu_channels_[client_id] = std::move(media_gpu_channel); 33 media_gpu_channels_[client_id] = std::move(media_gpu_channel);
34 channel_to_token_[client_id] = channel_token;
35 token_to_channel_[channel_token] = client_id;
33 } 36 }
34 37
35 void MediaGpuChannelManager::RemoveChannel(int32_t client_id) { 38 void MediaGpuChannelManager::RemoveChannel(int32_t client_id) {
36 media_gpu_channels_.erase(client_id); 39 media_gpu_channels_.erase(client_id);
40 const auto it = channel_to_token_.find(client_id);
41 if (it != channel_to_token_.end()) {
42 token_to_channel_.erase(it->second);
43 channel_to_token_.erase(it);
44 }
37 } 45 }
38 46
39 void MediaGpuChannelManager::DestroyAllChannels() { 47 void MediaGpuChannelManager::DestroyAllChannels() {
40 media_gpu_channels_.clear(); 48 media_gpu_channels_.clear();
49 token_to_channel_.clear();
50 channel_to_token_.clear();
51 }
52
53 gpu::GpuChannel* MediaGpuChannelManager::LookupChannel(
54 const base::UnguessableToken& channel_token) {
55 const auto it = token_to_channel_.find(channel_token);
56 if (it == token_to_channel_.end())
57 return nullptr;
58 return channel_manager_->LookupChannel(it->second);
41 } 59 }
42 60
43 } // namespace media 61 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/ipc/service/media_gpu_channel_manager.h ('k') | media/mojo/clients/mojo_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698