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

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

Issue 2349463003: MediaService: Implement GetChannelToken IPC (Closed)
Patch Set: base::UnguessableToken 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
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..f69222a298093ceb733619b40d912ee8579503a1 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(base::UnguessableToken channel_token)
tguilbert 2016/09/19 22:32:23 I think the official guidance danakj gave us is to
sandersd (OOO until July 31) 2016/09/19 22:40:33 Very well then.
+ : channel_token_(channel_token) {}
+
+ void OnFilterAdded(IPC::Channel* channel) override { channel_ = channel; }
+ 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() {}
« media/gpu/ipc/common/media_messages.h ('K') | « 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