Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: ppapi/host/ppapi_host.cc

Issue 119853003: [PPAPI] Implement an IOStreamResource for data transmission between plugin and renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ppapi::proxy::SerializedHandle;
yzshen1 2014/01/03 21:51:41 nit: no need to have ppapi::
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
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 SendUnsolicitedReplyWithHandle(resource, msg, SerializedHandle());
106 }
107
108 void PpapiHost::SendUnsolicitedReplyWithHandle(PP_Resource resource,
109 const IPC::Message& msg,
110 const SerializedHandle& handle) {
dmichael (off chromium) 2014/01/03 18:05:29 Maybe this accept a vector of handles? Then SendUn
111 TRACE_EVENT2("ppapi proxy", "PpapiHost::SendUnsolicitedReplyWithHandle",
103 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), 112 "Class", IPC_MESSAGE_ID_CLASS(msg.type()),
104 "Line", IPC_MESSAGE_ID_LINE(msg.type())); 113 "Line", IPC_MESSAGE_ID_LINE(msg.type()));
105 DCHECK(resource); // If this fails, host is probably pending. 114 DCHECK(resource); // If this fails, host is probably pending.
106 proxy::ResourceMessageReplyParams params(resource, 0); 115 proxy::ResourceMessageReplyParams params(resource, 0);
116 if (handle.IsHandleValid())
117 params.AppendHandle(handle);
107 Send(new PpapiPluginMsg_ResourceReply(params, msg)); 118 Send(new PpapiPluginMsg_ResourceReply(params, msg));
108 } 119 }
109 120
110 scoped_ptr<ResourceHost> PpapiHost::CreateResourceHost( 121 scoped_ptr<ResourceHost> PpapiHost::CreateResourceHost(
111 const proxy::ResourceMessageCallParams& params, 122 const proxy::ResourceMessageCallParams& params,
112 PP_Instance instance, 123 PP_Instance instance,
113 const IPC::Message& nested_msg) { 124 const IPC::Message& nested_msg) {
114 scoped_ptr<ResourceHost> resource_host; 125 scoped_ptr<ResourceHost> resource_host;
115 DCHECK(!host_factory_filters_.empty()); // Caller forgot to add a factory. 126 DCHECK(!host_factory_filters_.empty()); // Caller forgot to add a factory.
116 for (size_t i = 0; i < host_factory_filters_.size(); i++) { 127 for (size_t i = 0; i < host_factory_filters_.size(); i++) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 resources_.erase(found); 272 resources_.erase(found);
262 } 273 }
263 274
264 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const { 275 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const {
265 ResourceMap::const_iterator found = resources_.find(resource); 276 ResourceMap::const_iterator found = resources_.find(resource);
266 return found == resources_.end() ? NULL : found->second.get(); 277 return found == resources_.end() ? NULL : found->second.get();
267 } 278 }
268 279
269 } // namespace host 280 } // namespace host
270 } // namespace ppapi 281 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698