Use blink::WebSandboxFlags directly in content.
[chromium-blink-merge.git] / content / renderer / gpu / stream_texture_host_android.cc
blobfe63557ca2bd806b8b68ca508e3fc03e96c43bca
1 // Copyright (c) 2012 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.
5 #include "content/renderer/gpu/stream_texture_host_android.h"
7 #include "content/common/gpu/client/gpu_channel_host.h"
8 #include "content/common/gpu/gpu_messages.h"
9 #include "content/renderer/render_thread_impl.h"
10 #include "ipc/ipc_message_macros.h"
12 namespace content {
14 StreamTextureHost::StreamTextureHost(GpuChannelHost* channel)
15 : stream_id_(0),
16 listener_(NULL),
17 channel_(channel),
18 weak_ptr_factory_(this) {
19 DCHECK(channel);
22 StreamTextureHost::~StreamTextureHost() {
23 if (channel_.get() && stream_id_)
24 channel_->RemoveRoute(stream_id_);
27 bool StreamTextureHost::BindToCurrentThread(int32 stream_id,
28 Listener* listener) {
29 listener_ = listener;
30 if (channel_.get() && stream_id && !stream_id_) {
31 stream_id_ = stream_id;
32 channel_->AddRoute(stream_id, weak_ptr_factory_.GetWeakPtr());
33 channel_->Send(new GpuStreamTextureMsg_StartListening(stream_id));
34 return true;
37 return false;
40 bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) {
41 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message)
43 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable,
44 OnFrameAvailable);
45 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_MatrixChanged,
46 OnMatrixChanged);
47 IPC_MESSAGE_UNHANDLED(handled = false)
48 IPC_END_MESSAGE_MAP()
49 DCHECK(handled);
50 return handled;
53 void StreamTextureHost::OnChannelError() {
56 void StreamTextureHost::OnFrameAvailable() {
57 if (listener_)
58 listener_->OnFrameAvailable();
61 void StreamTextureHost::OnMatrixChanged(
62 const GpuStreamTextureMsg_MatrixChanged_Params& params) {
63 static_assert(sizeof(params) == sizeof(float) * 16,
64 "bad GpuStreamTextureMsg MatrixChanged_Params format");
65 if (listener_)
66 listener_->OnMatrixChanged((const float*)&params);
69 } // namespace content