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

Unified Diff: content/browser/renderer_host/pepper/browser_ppapi_host_impl.h

Issue 605593002: PPAPI: Support sending browser-hosted resources synchronously Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix content_browsertests Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
index bd0c61d7c59d72ecb34c47b4ea16e2e704b65c2b..11e912e430706f19d95df3bb9b6914ba7f93a3d7 100644
--- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
+++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/containers/scoped_ptr_hash_map.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
@@ -28,6 +29,89 @@
namespace content {
+class BrowserMessageFilter;
+class BrowserPpapiHostImpl;
+class PendingHostCreator {
+ public:
+ PendingHostCreator(int routing_id,
+ int sequence_id,
+ size_t nested_msgs_size);
+ ~PendingHostCreator();
+
+ // Adds the given resource host as a pending one. The host is remembered as
+ // host number |index|, and will ultimately be sent to the plugin to be
+ // attached to a real resource.
+ void AddPendingResourceHost(size_t index, int host_id);
+
+ bool finished() const {
+ return completed_so_far_ == host_ids_.size();
+ }
+
+ int routing_id() const { return routing_id_; }
+ int sequence_id() const { return sequence_id_; }
+ const std::vector<int>& host_ids() const { return host_ids_; }
+
+ // Swap host_ids with host_ids_, to avoid copying.
+ void TakePendingResourceHostIdsAndReset(std::vector<int>* host_ids);
+
+ private:
+ int routing_id_;
+ int sequence_id_;
+ std::vector<int> host_ids_;
+ size_t completed_so_far_;
+};
+
+// TODO(dmichael) Rename and move this to its own file.
+class InstanceData {
+ public:
+ explicit InstanceData(PP_Instance instance,
+ BrowserPpapiHostImpl* host,
+ IPC::Sender* renderer_sender,
+ PepperRendererInstanceData renderer_data);
+ InstanceData(const InstanceData& instance_data);
+ ~InstanceData();
+
+ const PepperRendererInstanceData& renderer_data() const {
+ return renderer_data_;
+ }
+
+ void CreateResourceHostsFromHost(
+ int routing_id,
+ const ppapi::proxy::ResourceMessageCallParams& params,
+ const std::vector<IPC::Message>& nested_msgs);
+ void GetAllPendingResourceHosts(scoped_ptr<IPC::Message> reply_msg);
+ void RendererDidReceiveHosts(int sequence);
+ private:
+ typedef base::ScopedPtrHashMap<int, PendingHostCreator> HostCreatorMap;
+
+ void SendCompletedResourceHosts(const PendingHostCreator& creator);
+ void SendSyncReplyIfNecessary();
+ void AddPendingResourceHost(PendingHostCreator* creator,
+ int sequence,
+ size_t index,
+ scoped_ptr<ppapi::host::ResourceHost> host);
+ PP_Instance instance_;
+
+ // Weak; host_ owns the InstanceData.
+ BrowserPpapiHostImpl* host_;
+
+ IPC::Sender* renderer_sender_;
+
+ // Maps sequence number to PendingHostCreator.
+ HostCreatorMap host_creator_map_;
+ size_t finished_creators_;
+ // Valid if we are building up a reply to a sync request for this instance.
+ // If null, we are in "normal" mode, where we send created hosts
+ // asynchronously. If valid, this is the reply message to send back to the
+ // renderer to unblock it. Note we only need 1, because the renderer will
+ // be blocked and unable to make another sync request until after we are
+ // finished servicing this one.
+ scoped_ptr<IPC::Message> reply_for_sync_request_;
+ PepperRendererInstanceData renderer_data_;
+
+ base::WeakPtrFactory<InstanceData> weak_ptr_factory_;
+};
+
class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
public:
// The creator is responsible for calling set_plugin_process_handle as soon
@@ -69,9 +153,20 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
// or destroyed. They allow us to maintain a mapping of PP_Instance to data
// associated with the instance including view IDs in the browser process.
void AddInstance(PP_Instance instance,
- const PepperRendererInstanceData& instance_data);
+ const PepperRendererInstanceData& instance_data,
+ IPC::Sender* renderer_sender);
void DeleteInstance(PP_Instance instance);
+ void CreateResourceHostsFromHost(
+ int routing_id,
+ const ppapi::proxy::ResourceMessageCallParams& params,
+ PP_Instance instance,
+ const std::vector<IPC::Message>& nested_msgs);
+ void RendererDidReceiveHosts(PP_Instance instance, int sequence);
+ bool GetAllPendingResourceHosts(
+ PP_Instance instance,
+ scoped_ptr<IPC::Message> reply_msg);
+
scoped_refptr<IPC::MessageFilter> message_filter() {
return message_filter_;
}
@@ -125,9 +220,14 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
scoped_refptr<SSLContextHelper> ssl_context_helper_;
+ // PendingHostCreator keeps track of a set of hosts that are being created
+ // for a single request message from the renderer. See the body for its
+ // definition.
+ class PendingHostCreator;
+
// Tracks all PP_Instances in this plugin and associated renderer-related
// data.
- typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap;
+ typedef std::map<PP_Instance, InstanceData> InstanceMap;
InstanceMap instance_map_;
scoped_refptr<HostMessageFilter> message_filter_;
« no previous file with comments | « content/browser/ppapi_plugin_process_host.cc ('k') | content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698