| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/host/ppapi_host.h" | 5 #include "ppapi/host/ppapi_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/host/host_factory.h" | 9 #include "ppapi/host/host_factory.h" |
| 10 #include "ppapi/host/host_message_context.h" | 10 #include "ppapi/host/host_message_context.h" |
| 11 #include "ppapi/host/instance_message_filter.h" | 11 #include "ppapi/host/instance_message_filter.h" |
| 12 #include "ppapi/host/resource_host.h" | 12 #include "ppapi/host/resource_host.h" |
| 13 #include "ppapi/proxy/ppapi_messages.h" | 13 #include "ppapi/proxy/ppapi_messages.h" |
| 14 #include "ppapi/proxy/resource_message_params.h" | 14 #include "ppapi/proxy/resource_message_params.h" |
| 15 #include "ppapi/shared_impl/host_resource.h" | 15 #include "ppapi/shared_impl/host_resource.h" |
| 16 #include "ppapi/shared_impl/ppapi_message_tracker.h" | |
| 17 | 16 |
| 18 namespace ppapi { | 17 namespace ppapi { |
| 19 namespace host { | 18 namespace host { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 // Put a cap on the maximum number of resources so we don't explode if the | 22 // Put a cap on the maximum number of resources so we don't explode if the |
| 24 // renderer starts spamming us. | 23 // renderer starts spamming us. |
| 25 const size_t kMaxResourcesPerPlugin = 1 << 14; | 24 const size_t kMaxResourcesPerPlugin = 1 << 14; |
| 26 | 25 |
| 27 } // namespace | 26 } // namespace |
| 28 | 27 |
| 29 PpapiHost::PpapiHost(IPC::Sender* sender, | 28 PpapiHost::PpapiHost(IPC::Sender* sender, |
| 30 const PpapiPermissions& perms) | 29 const PpapiPermissions& perms) |
| 31 : sender_(sender), | 30 : sender_(sender), |
| 32 permissions_(perms) { | 31 permissions_(perms) { |
| 33 } | 32 } |
| 34 | 33 |
| 35 PpapiHost::~PpapiHost() { | 34 PpapiHost::~PpapiHost() { |
| 36 // Delete these explicitly before destruction since then the host is still | 35 // Delete these explicitly before destruction since then the host is still |
| 37 // technically alive in case one of the filters accesses us from the | 36 // technically alive in case one of the filters accesses us from the |
| 38 // destructor. | 37 // destructor. |
| 39 instance_message_filters_.clear(); | 38 instance_message_filters_.clear(); |
| 40 } | 39 } |
| 41 | 40 |
| 42 bool PpapiHost::Send(IPC::Message* msg) { | 41 bool PpapiHost::Send(IPC::Message* msg) { |
| 43 ScopedTrackPpapiMessage track_ppapi_message; | |
| 44 return sender_->Send(msg); | 42 return sender_->Send(msg); |
| 45 } | 43 } |
| 46 | 44 |
| 47 bool PpapiHost::OnMessageReceived(const IPC::Message& msg) { | 45 bool PpapiHost::OnMessageReceived(const IPC::Message& msg) { |
| 48 ScopedTrackPpapiMessage track_ppapi_message; | |
| 49 bool handled = true; | 46 bool handled = true; |
| 50 IPC_BEGIN_MESSAGE_MAP(PpapiHost, msg) | 47 IPC_BEGIN_MESSAGE_MAP(PpapiHost, msg) |
| 51 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCall, | 48 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCall, |
| 52 OnHostMsgResourceCall) | 49 OnHostMsgResourceCall) |
| 53 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreated, | 50 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreated, |
| 54 OnHostMsgResourceCreated) | 51 OnHostMsgResourceCreated) |
| 55 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceDestroyed, | 52 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceDestroyed, |
| 56 OnHostMsgResourceDestroyed) | 53 OnHostMsgResourceDestroyed) |
| 57 IPC_MESSAGE_UNHANDLED(handled = false) | 54 IPC_MESSAGE_UNHANDLED(handled = false) |
| 58 IPC_END_MESSAGE_MAP() | 55 IPC_END_MESSAGE_MAP() |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 resources_.erase(found); | 149 resources_.erase(found); |
| 153 } | 150 } |
| 154 | 151 |
| 155 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) { | 152 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) { |
| 156 ResourceMap::iterator found = resources_.find(resource); | 153 ResourceMap::iterator found = resources_.find(resource); |
| 157 return found == resources_.end() ? NULL : found->second.get(); | 154 return found == resources_.end() ? NULL : found->second.get(); |
| 158 } | 155 } |
| 159 | 156 |
| 160 } // namespace host | 157 } // namespace host |
| 161 } // namespace ppapi | 158 } // namespace ppapi |
| OLD | NEW |