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 "ppapi/host/resource_host.h"
7 #include "base/logging.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/host/ppapi_host.h"
10 #include "ppapi/host/resource_message_filter.h"
15 ResourceHost::ResourceHost(PpapiHost
* host
,
19 pp_instance_(instance
),
20 pp_resource_(resource
) {
23 ResourceHost::~ResourceHost() {
24 for (size_t i
= 0; i
< message_filters_
.size(); ++i
)
25 message_filters_
[i
]->OnFilterDestroyed();
28 bool ResourceHost::HandleMessage(const IPC::Message
& msg
,
29 HostMessageContext
* context
) {
30 // First see if the message is handled off-thread by message filters.
31 for (size_t i
= 0; i
< message_filters_
.size(); ++i
) {
32 if (message_filters_
[i
]->HandleMessage(msg
, context
))
35 // Run this ResourceHosts message handler.
36 RunMessageHandlerAndReply(msg
, context
);
40 void ResourceHost::SetPPResourceForPendingHost(PP_Resource pp_resource
) {
41 DCHECK(!pp_resource_
);
42 pp_resource_
= pp_resource
;
43 DidConnectPendingHostToResource();
46 void ResourceHost::SendReply(const ReplyMessageContext
& context
,
47 const IPC::Message
& msg
) {
48 host_
->SendReply(context
, msg
);
51 bool ResourceHost::IsCompositorHost() {
55 bool ResourceHost::IsFileRefHost() {
59 bool ResourceHost::IsFileSystemHost() {
63 bool ResourceHost::IsMediaStreamVideoTrackHost() {
67 bool ResourceHost::IsGraphics2DHost() {
71 void ResourceHost::AddFilter(scoped_refptr
<ResourceMessageFilter
> filter
) {
72 message_filters_
.push_back(filter
);
73 filter
->OnFilterAdded(this);