• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "ppapi/host/resource_host.h"
6 
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"
11 
12 namespace ppapi {
13 namespace host {
14 
ResourceHost(PpapiHost * host,PP_Instance instance,PP_Resource resource)15 ResourceHost::ResourceHost(PpapiHost* host,
16                            PP_Instance instance,
17                            PP_Resource resource)
18     : host_(host),
19       pp_instance_(instance),
20       pp_resource_(resource) {
21 }
22 
~ResourceHost()23 ResourceHost::~ResourceHost() {
24   for (size_t i = 0; i < message_filters_.size(); ++i)
25     message_filters_[i]->OnFilterDestroyed();
26 }
27 
HandleMessage(const IPC::Message & msg,HostMessageContext * context)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))
33       return true;
34   }
35   // Run this ResourceHosts message handler.
36   RunMessageHandlerAndReply(msg, context);
37   return true;
38 }
39 
SetPPResourceForPendingHost(PP_Resource pp_resource)40 void ResourceHost::SetPPResourceForPendingHost(PP_Resource pp_resource) {
41   DCHECK(!pp_resource_);
42   pp_resource_ = pp_resource;
43   DidConnectPendingHostToResource();
44 }
45 
SendReply(const ReplyMessageContext & context,const IPC::Message & msg)46 void ResourceHost::SendReply(const ReplyMessageContext& context,
47                              const IPC::Message& msg) {
48   host_->SendReply(context, msg);
49 }
50 
IsCompositorHost()51 bool ResourceHost::IsCompositorHost() {
52   return false;
53 }
54 
IsFileRefHost()55 bool ResourceHost::IsFileRefHost() {
56   return false;
57 }
58 
IsFileSystemHost()59 bool ResourceHost::IsFileSystemHost() {
60   return false;
61 }
62 
IsMediaStreamVideoTrackHost()63 bool ResourceHost::IsMediaStreamVideoTrackHost() {
64   return false;
65 }
66 
IsGraphics2DHost()67 bool ResourceHost::IsGraphics2DHost() {
68   return false;
69 }
70 
AddFilter(scoped_refptr<ResourceMessageFilter> filter)71 void ResourceHost::AddFilter(scoped_refptr<ResourceMessageFilter> filter) {
72   message_filters_.push_back(filter);
73   filter->OnFilterAdded(this);
74 }
75 
76 }  // namespace host
77 }  // namespace ppapi
78