| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/pepper/pepper_browser_connection.h" | 5 #include "content/renderer/pepper/pepper_browser_connection.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // Check if the message is an in-process reply. | 29 // Check if the message is an in-process reply. |
| 30 if (PepperInProcessRouter::OnPluginMsgReceived(msg)) | 30 if (PepperInProcessRouter::OnPluginMsgReceived(msg)) |
| 31 return true; | 31 return true; |
| 32 | 32 |
| 33 bool handled = true; | 33 bool handled = true; |
| 34 IPC_BEGIN_MESSAGE_MAP(PepperBrowserConnection, msg) | 34 IPC_BEGIN_MESSAGE_MAP(PepperBrowserConnection, msg) |
| 35 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHostReply, | 35 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHostReply, |
| 36 OnMsgCreateResourceHostsFromHostReply) | 36 OnMsgCreateResourceHostsFromHostReply) |
| 37 IPC_MESSAGE_UNHANDLED(handled = false) | 37 IPC_MESSAGE_UNHANDLED(handled = false) |
| 38 IPC_END_MESSAGE_MAP() | 38 IPC_END_MESSAGE_MAP() |
| 39 | |
| 40 return handled; | 39 return handled; |
| 41 } | 40 } |
| 42 | 41 |
| 43 void PepperBrowserConnection::DidCreateInProcessInstance( | 42 void PepperBrowserConnection::DidCreateInProcessInstance( |
| 44 PP_Instance instance, | 43 PP_Instance instance, |
| 45 int render_view_id, | 44 int render_view_id, |
| 46 const GURL& document_url, | 45 const GURL& document_url, |
| 47 const GURL& plugin_url) { | 46 const GURL& plugin_url) { |
| 48 Send(new ViewHostMsg_DidCreateInProcessInstance( | 47 Send(new ViewHostMsg_DidCreateInProcessInstance( |
| 49 instance, | 48 instance, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 67 pending_create_map_[sequence_number] = callback; | 66 pending_create_map_[sequence_number] = callback; |
| 68 ppapi::proxy::ResourceMessageCallParams params(0, sequence_number); | 67 ppapi::proxy::ResourceMessageCallParams params(0, sequence_number); |
| 69 Send(new PpapiHostMsg_CreateResourceHostsFromHost( | 68 Send(new PpapiHostMsg_CreateResourceHostsFromHost( |
| 70 routing_id(), | 69 routing_id(), |
| 71 child_process_id, | 70 child_process_id, |
| 72 params, | 71 params, |
| 73 instance, | 72 instance, |
| 74 nested_msgs)); | 73 nested_msgs)); |
| 75 } | 74 } |
| 76 | 75 |
| 77 void PepperBrowserConnection::SendBrowserFileRefGetInfo( | |
| 78 int child_process_id, | |
| 79 const std::vector<PP_Resource>& resources, | |
| 80 const FileRefGetInfoCallback& callback) { | |
| 81 int32_t sequence_number = GetNextSequence(); | |
| 82 get_info_map_[sequence_number] = callback; | |
| 83 Send(new PpapiHostMsg_FileRef_GetInfoForRenderer( | |
| 84 routing_id(), child_process_id, sequence_number, resources)); | |
| 85 } | |
| 86 | |
| 87 void PepperBrowserConnection::OnMsgCreateResourceHostsFromHostReply( | 76 void PepperBrowserConnection::OnMsgCreateResourceHostsFromHostReply( |
| 88 int32_t sequence_number, | 77 int32_t sequence_number, |
| 89 const std::vector<int>& pending_resource_host_ids) { | 78 const std::vector<int>& pending_resource_host_ids) { |
| 90 // Check that the message is destined for the plugin this object is associated | 79 // Check that the message is destined for the plugin this object is associated |
| 91 // with. | 80 // with. |
| 92 std::map<int32_t, PendingResourceIDCallback>::iterator it = | 81 std::map<int32_t, PendingResourceIDCallback>::iterator it = |
| 93 pending_create_map_.find(sequence_number); | 82 pending_create_map_.find(sequence_number); |
| 94 if (it != pending_create_map_.end()) { | 83 if (it != pending_create_map_.end()) { |
| 95 it->second.Run(pending_resource_host_ids); | 84 it->second.Run(pending_resource_host_ids); |
| 96 pending_create_map_.erase(it); | 85 pending_create_map_.erase(it); |
| 97 } else { | 86 } else { |
| 98 NOTREACHED(); | 87 NOTREACHED(); |
| 99 } | 88 } |
| 100 } | 89 } |
| 101 | 90 |
| 102 void PepperBrowserConnection::OnMsgFileRefGetInfoReply( | |
| 103 int32_t sequence_number, | |
| 104 const std::vector<PP_Resource>& resources, | |
| 105 const std::vector<PP_FileSystemType>& types, | |
| 106 const std::vector<std::string>& file_system_url_specs, | |
| 107 const std::vector<base::FilePath>& external_paths) { | |
| 108 // Check that the message is destined for the plugin this object is associated | |
| 109 // with. | |
| 110 std::map<int32_t, FileRefGetInfoCallback>::iterator it = | |
| 111 get_info_map_.find(sequence_number); | |
| 112 if (it != get_info_map_.end()) { | |
| 113 FileRefGetInfoCallback callback = it->second; | |
| 114 get_info_map_.erase(it); | |
| 115 callback.Run(resources, types, file_system_url_specs, external_paths); | |
| 116 } else { | |
| 117 NOTREACHED(); | |
| 118 } | |
| 119 } | |
| 120 | |
| 121 int32_t PepperBrowserConnection::GetNextSequence() { | 91 int32_t PepperBrowserConnection::GetNextSequence() { |
| 122 // Return the value with wraparound, making sure we don't make a sequence | 92 // Return the value with wraparound, making sure we don't make a sequence |
| 123 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we | 93 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we |
| 124 // manually check. | 94 // manually check. |
| 125 int32_t ret = next_sequence_number_; | 95 int32_t ret = next_sequence_number_; |
| 126 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) | 96 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) |
| 127 next_sequence_number_ = 1; // Skip 0 which is invalid. | 97 next_sequence_number_ = 1; // Skip 0 which is invalid. |
| 128 else | 98 else |
| 129 next_sequence_number_++; | 99 next_sequence_number_++; |
| 130 return ret; | 100 return ret; |
| 131 } | 101 } |
| 132 | 102 |
| 133 } // namespace content | 103 } // namespace content |
| OLD | NEW |