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/proxy/serialized_handle.h" |
15 #include "ppapi/shared_impl/host_resource.h" | 16 #include "ppapi/shared_impl/host_resource.h" |
16 | 17 |
17 namespace ppapi { | 18 namespace ppapi { |
18 namespace host { | 19 namespace host { |
19 | 20 |
| 21 using proxy::SerializedHandle; |
| 22 |
20 namespace { | 23 namespace { |
21 | 24 |
22 // Put a cap on the maximum number of resources so we don't explode if the | 25 // Put a cap on the maximum number of resources so we don't explode if the |
23 // renderer starts spamming us. | 26 // renderer starts spamming us. |
24 const size_t kMaxResourcesPerPlugin = 1 << 14; | 27 const size_t kMaxResourcesPerPlugin = 1 << 14; |
25 | 28 |
26 } // namespace | 29 } // namespace |
27 | 30 |
28 PpapiHost::PpapiHost(IPC::Sender* sender, | 31 PpapiHost::PpapiHost(IPC::Sender* sender, |
29 const PpapiPermissions& perms) | 32 const PpapiPermissions& perms) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 context.params, | 95 context.params, |
93 msg)); | 96 msg)); |
94 } else { | 97 } else { |
95 Send(new PpapiPluginMsg_ResourceReply(context.params, msg)); | 98 Send(new PpapiPluginMsg_ResourceReply(context.params, msg)); |
96 } | 99 } |
97 } | 100 } |
98 } | 101 } |
99 | 102 |
100 void PpapiHost::SendUnsolicitedReply(PP_Resource resource, | 103 void PpapiHost::SendUnsolicitedReply(PP_Resource resource, |
101 const IPC::Message& msg) { | 104 const IPC::Message& msg) { |
102 TRACE_EVENT2("ppapi proxy", "PpapiHost::SendUnsolicitedReply", | 105 SendUnsolicitedReplyWithHandles( |
| 106 resource, msg, std::vector<SerializedHandle>()); |
| 107 } |
| 108 |
| 109 void PpapiHost::SendUnsolicitedReplyWithHandles( |
| 110 PP_Resource resource, |
| 111 const IPC::Message& msg, |
| 112 const std::vector<SerializedHandle>& handles) { |
| 113 TRACE_EVENT2("ppapi proxy", "PpapiHost::SendUnsolicitedReplyWithHandles", |
103 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), | 114 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), |
104 "Line", IPC_MESSAGE_ID_LINE(msg.type())); | 115 "Line", IPC_MESSAGE_ID_LINE(msg.type())); |
105 DCHECK(resource); // If this fails, host is probably pending. | 116 DCHECK(resource); // If this fails, host is probably pending. |
106 proxy::ResourceMessageReplyParams params(resource, 0); | 117 proxy::ResourceMessageReplyParams params(resource, 0); |
| 118 for (std::vector<SerializedHandle>::const_iterator it = handles.begin(); |
| 119 it != handles.end(); ++it) { |
| 120 params.AppendHandle(*it); |
| 121 } |
107 Send(new PpapiPluginMsg_ResourceReply(params, msg)); | 122 Send(new PpapiPluginMsg_ResourceReply(params, msg)); |
108 } | 123 } |
109 | 124 |
110 scoped_ptr<ResourceHost> PpapiHost::CreateResourceHost( | 125 scoped_ptr<ResourceHost> PpapiHost::CreateResourceHost( |
111 const proxy::ResourceMessageCallParams& params, | 126 const proxy::ResourceMessageCallParams& params, |
112 PP_Instance instance, | 127 PP_Instance instance, |
113 const IPC::Message& nested_msg) { | 128 const IPC::Message& nested_msg) { |
114 scoped_ptr<ResourceHost> resource_host; | 129 scoped_ptr<ResourceHost> resource_host; |
115 DCHECK(!host_factory_filters_.empty()); // Caller forgot to add a factory. | 130 DCHECK(!host_factory_filters_.empty()); // Caller forgot to add a factory. |
116 for (size_t i = 0; i < host_factory_filters_.size(); i++) { | 131 for (size_t i = 0; i < host_factory_filters_.size(); i++) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 resources_.erase(found); | 276 resources_.erase(found); |
262 } | 277 } |
263 | 278 |
264 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const { | 279 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const { |
265 ResourceMap::const_iterator found = resources_.find(resource); | 280 ResourceMap::const_iterator found = resources_.find(resource); |
266 return found == resources_.end() ? NULL : found->second.get(); | 281 return found == resources_.end() ? NULL : found->second.get(); |
267 } | 282 } |
268 | 283 |
269 } // namespace host | 284 } // namespace host |
270 } // namespace ppapi | 285 } // namespace ppapi |
OLD | NEW |