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

Unified Diff: media/gpu/ipc/service/media_channel.cc

Issue 2349463003: MediaService: Implement GetChannelToken IPC (Closed)
Patch Set: Nits Created 4 years, 3 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
« no previous file with comments | « media/gpu/ipc/common/media_messages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/ipc/service/media_channel.cc
diff --git a/media/gpu/ipc/service/media_channel.cc b/media/gpu/ipc/service/media_channel.cc
index 0d1023180190ed3a1377e1406d32dd9c94e445e5..28d58235f75902ef1d297c65cec46843e67ee62b 100644
--- a/media/gpu/ipc/service/media_channel.cc
+++ b/media/gpu/ipc/service/media_channel.cc
@@ -4,7 +4,9 @@
#include "media/gpu/ipc/service/media_channel.h"
+#include "base/unguessable_token.h"
#include "gpu/ipc/service/gpu_channel.h"
+#include "ipc/message_filter.h"
#include "media/gpu/ipc/common/media_messages.h"
#include "media/gpu/ipc/service/gpu_video_decode_accelerator.h"
#include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
@@ -55,7 +57,41 @@ class MediaChannelDispatchHelper {
DISALLOW_COPY_AND_ASSIGN(MediaChannelDispatchHelper);
};
-MediaChannel::MediaChannel(gpu::GpuChannel* channel) : channel_(channel) {}
+// Filter to respond to GetChannelToken on the IO thread.
+class MediaChannelFilter : public IPC::MessageFilter {
+ public:
+ explicit MediaChannelFilter(const base::UnguessableToken& channel_token)
+ : channel_token_(channel_token) {}
+
+ void OnFilterAdded(IPC::Channel* channel) override { channel_ = channel; }
dcheng 2016/09/19 22:47:35 Do we need this override?
sandersd (OOO until July 31) 2016/09/19 22:55:49 No, it could have been safely passed AFAIK. Is the
dcheng 2016/09/19 23:05:58 I misread this originally. I guess it's a pretty c
+ bool Send(IPC::Message* msg) { return channel_->Send(msg); }
+
+ bool OnMessageReceived(const IPC::Message& msg) override {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(MediaChannelFilter, msg)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetChannelToken,
+ OnGetChannelToken)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+ }
+
+ void OnGetChannelToken(IPC::Message* reply_message) {
+ GpuCommandBufferMsg_GetChannelToken::WriteReplyParams(reply_message,
+ channel_token_);
+ Send(reply_message);
+ }
+
+ private:
+ ~MediaChannelFilter() override {}
+
+ IPC::Channel* channel_;
+ base::UnguessableToken channel_token_;
+};
+
+MediaChannel::MediaChannel(gpu::GpuChannel* channel) : channel_(channel) {
+ channel_->AddFilter(new MediaChannelFilter(base::UnguessableToken::Create()));
+}
MediaChannel::~MediaChannel() {}
« no previous file with comments | « media/gpu/ipc/common/media_messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698