IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / renderer / gpu / stream_texture_host_android.cc
blob0c202bf3a474aef1060f2588eebb6c8d913d41d4
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 : route_id_(MSG_ROUTING_NONE),
16 stream_id_(0),
17 listener_(NULL),
18 channel_(channel),
19 weak_ptr_factory_(this) {
20 DCHECK(channel);
23 StreamTextureHost::~StreamTextureHost() {
24 if (channel_.get() && route_id_ != MSG_ROUTING_NONE)
25 channel_->RemoveRoute(route_id_);
28 bool StreamTextureHost::Initialize(int32 stream_id) {
29 if (channel_.get() && stream_id) {
30 if (channel_->Send(new GpuChannelMsg_RegisterStreamTextureProxy(
31 stream_id, &route_id_))) {
32 stream_id_ = stream_id;
33 channel_->AddRoute(route_id_, weak_ptr_factory_.GetWeakPtr());
35 return true;
38 return false;
41 bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) {
42 bool handled = true;
43 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message)
44 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable,
45 OnFrameAvailable);
46 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_MatrixChanged,
47 OnMatrixChanged);
48 IPC_MESSAGE_UNHANDLED(handled = false)
49 IPC_END_MESSAGE_MAP()
50 DCHECK(handled);
51 return handled;
54 void StreamTextureHost::EstablishPeer(int32 primary_id, int32 secondary_id) {
55 if (channel_.get()) {
56 channel_->Send(new GpuChannelMsg_EstablishStreamTexture(
57 stream_id_, primary_id, secondary_id));
60 void StreamTextureHost::OnChannelError() {
63 void StreamTextureHost::OnFrameAvailable() {
64 if (listener_)
65 listener_->OnFrameAvailable();
68 void StreamTextureHost::OnMatrixChanged(
69 const GpuStreamTextureMsg_MatrixChanged_Params& params) {
70 COMPILE_ASSERT(sizeof(params) == sizeof(float) * 16,
71 bad_GpuStreamTextureMsg_MatrixChanged_Params_format);
72 if (listener_)
73 listener_->OnMatrixChanged((const float*)&params);
76 } // namespace content