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

Unified Diff: content/renderer/pepper/pepper_browser_connection.cc

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/renderer/pepper/pepper_browser_connection.cc
diff --git a/content/renderer/pepper/pepper_browser_connection.cc b/content/renderer/pepper/pepper_browser_connection.cc
index 892506ede2f22526f71e64034407459c69121ee6..e26b479f8d339e048633e488276ce6d4ae15a314 100644
--- a/content/renderer/pepper/pepper_browser_connection.cc
+++ b/content/renderer/pepper/pepper_browser_connection.cc
@@ -13,6 +13,7 @@
#include "ipc/ipc_message_macros.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/proxy/serialized_structs.h"
namespace content {
@@ -53,30 +54,63 @@ void PepperBrowserConnection::DidDeleteInProcessInstance(PP_Instance instance) {
Send(new ViewHostMsg_DidDeleteInProcessInstance(instance));
}
-void PepperBrowserConnection::SendBrowserCreate(
+int32_t PepperBrowserConnection::SendBrowserCreate(
int child_process_id,
PP_Instance instance,
const std::vector<IPC::Message>& nested_msgs,
- const PendingResourceIDCallback& callback) {
+ const PendingResourceCallback& callback) {
int32_t sequence_number = GetNextSequence();
- pending_create_map_[sequence_number] = callback;
+ pending_create_map_.insert(
+ std::map<int32_t, PendingResource>::value_type(
+ sequence_number,
+ PendingResource(child_process_id, instance, callback)));
ppapi::proxy::ResourceMessageCallParams params(0, sequence_number);
Send(new PpapiHostMsg_CreateResourceHostsFromHost(
routing_id(), child_process_id, params, instance, nested_msgs));
+ return sequence_number;
+}
+
+void PepperBrowserConnection::GetAllPendingBrowserHosts(
+ PP_Instance instance,
+ int child_process_id,
+ std::vector<ppapi::proxy::CompletedBrowserResourceHosts>* result) {
+ Send(new PpapiHostMsg_GetAllPendingResourceHosts(routing_id(),
+ child_process_id,
+ instance,
+ result));
+ // We just got all the responses that were pending, and we may not receive a
+ // reply for all of them. Just ignore any replies we do get.
+ pending_create_map_.clear();
+}
+
+PepperBrowserConnection::PendingResource::PendingResource(
+ int child_process_id_param,
+ PP_Instance instance_param,
+ const PendingResourceCallback& callback_param)
+ : child_process_id(child_process_id_param),
+ instance(instance_param),
+ callback(callback_param) {
+}
+
+PepperBrowserConnection::PendingResource::~PendingResource() {
}
void PepperBrowserConnection::OnMsgCreateResourceHostsFromHostReply(
- int32_t sequence_number,
- const std::vector<int>& pending_resource_host_ids) {
+ const ppapi::proxy::CompletedBrowserResourceHosts& hosts) {
// Check that the message is destined for the plugin this object is associated
// with.
- std::map<int32_t, PendingResourceIDCallback>::iterator it =
- pending_create_map_.find(sequence_number);
+ std::map<int32_t, PendingResource>::iterator it =
+ pending_create_map_.find(hosts.sequence_id);
if (it != pending_create_map_.end()) {
- it->second.Run(pending_resource_host_ids);
+ it->second.callback.Run(hosts);
+ Send(new PpapiHostMsg_CreateResourceHostsFromHostReplyAck(
+ it->second.child_process_id,
+ it->second.instance,
+ hosts.sequence_id));
pending_create_map_.erase(it);
} else {
- NOTREACHED();
+ // This can happen if we already received the pending hosts via
+ // sending GetAllPendingResourceHosts synchronously.
}
}
« no previous file with comments | « content/renderer/pepper/pepper_browser_connection.h ('k') | content/renderer/pepper/pepper_file_chooser_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698