| 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/renderer/pepper/pepper_plugin_delegate_impl.h" | 10 #include "content/renderer/pepper/pepper_helper_impl.h" | 
| 11 #include "content/renderer/render_view_impl.h" | 11 #include "content/renderer/render_view_impl.h" | 
| 12 #include "ipc/ipc_message_macros.h" | 12 #include "ipc/ipc_message_macros.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 | 15 | 
| 16 namespace content { | 16 namespace content { | 
| 17 | 17 | 
| 18 PepperBrowserConnection::PepperBrowserConnection( | 18 PepperBrowserConnection::PepperBrowserConnection(PepperHelperImpl* helper) | 
| 19     PepperPluginDelegateImpl* plugin_delegate) | 19     : helper_(helper), | 
| 20     : plugin_delegate_(plugin_delegate), |  | 
| 21       next_sequence_number_(1) { | 20       next_sequence_number_(1) { | 
| 22 } | 21 } | 
| 23 | 22 | 
| 24 PepperBrowserConnection::~PepperBrowserConnection() { | 23 PepperBrowserConnection::~PepperBrowserConnection() { | 
| 25 } | 24 } | 
| 26 | 25 | 
| 27 bool PepperBrowserConnection::OnMessageReceived(const IPC::Message& msg) { | 26 bool PepperBrowserConnection::OnMessageReceived(const IPC::Message& msg) { | 
| 28   bool handled = true; | 27   bool handled = true; | 
| 29   IPC_BEGIN_MESSAGE_MAP(PepperBrowserConnection, msg) | 28   IPC_BEGIN_MESSAGE_MAP(PepperBrowserConnection, msg) | 
| 30     IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostFromHostReply, | 29     IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostFromHostReply, | 
| 31                         OnMsgCreateResourceHostFromHostReply) | 30                         OnMsgCreateResourceHostFromHostReply) | 
| 32     IPC_MESSAGE_UNHANDLED(handled = false) | 31     IPC_MESSAGE_UNHANDLED(handled = false) | 
| 33   IPC_END_MESSAGE_MAP() | 32   IPC_END_MESSAGE_MAP() | 
| 34 | 33 | 
| 35   return handled; | 34   return handled; | 
| 36 } | 35 } | 
| 37 | 36 | 
| 38 void PepperBrowserConnection::SendBrowserCreate( | 37 void PepperBrowserConnection::SendBrowserCreate( | 
| 39     int child_process_id, | 38     int child_process_id, | 
| 40     PP_Instance instance, | 39     PP_Instance instance, | 
| 41     const IPC::Message& nested_msg, | 40     const IPC::Message& nested_msg, | 
| 42     const PendingResourceIDCallback& callback) { | 41     const PendingResourceIDCallback& callback) { | 
| 43   int32_t sequence_number = GetNextSequence(); | 42   int32_t sequence_number = GetNextSequence(); | 
| 44   pending_create_map_[sequence_number] = callback; | 43   pending_create_map_[sequence_number] = callback; | 
| 45   ppapi::proxy::ResourceMessageCallParams params(0, sequence_number); | 44   ppapi::proxy::ResourceMessageCallParams params(0, sequence_number); | 
| 46   plugin_delegate_->Send( | 45   helper_->Send(new PpapiHostMsg_CreateResourceHostFromHost( | 
| 47       new PpapiHostMsg_CreateResourceHostFromHost( | 46       helper_->routing_id(), | 
| 48           plugin_delegate_->routing_id(), | 47       child_process_id, | 
| 49           child_process_id, | 48       params, | 
| 50           params, | 49       instance, | 
| 51           instance, | 50       nested_msg)); | 
| 52           nested_msg)); |  | 
| 53 } | 51 } | 
| 54 | 52 | 
| 55 void PepperBrowserConnection::SendBrowserFileRefGetInfo( | 53 void PepperBrowserConnection::SendBrowserFileRefGetInfo( | 
| 56     int child_process_id, | 54     int child_process_id, | 
| 57     PP_Resource resource, | 55     PP_Resource resource, | 
| 58     const FileRefGetInfoCallback& callback) { | 56     const FileRefGetInfoCallback& callback) { | 
| 59   int32_t sequence_number = GetNextSequence(); | 57   int32_t sequence_number = GetNextSequence(); | 
| 60   get_info_map_[sequence_number] = callback; | 58   get_info_map_[sequence_number] = callback; | 
| 61   ppapi::proxy::ResourceMessageCallParams params(resource, sequence_number); | 59   ppapi::proxy::ResourceMessageCallParams params(resource, sequence_number); | 
| 62   plugin_delegate_->Send( | 60   helper_->Send(new PpapiHostMsg_FileRef_GetInfoForRenderer( | 
| 63       new PpapiHostMsg_FileRef_GetInfoForRenderer( | 61       helper_->routing_id(), child_process_id, params)); | 
| 64           plugin_delegate_->routing_id(), child_process_id, params)); |  | 
| 65 } | 62 } | 
| 66 | 63 | 
| 67 void PepperBrowserConnection::OnMsgCreateResourceHostFromHostReply( | 64 void PepperBrowserConnection::OnMsgCreateResourceHostFromHostReply( | 
| 68     int32_t sequence_number, | 65     int32_t sequence_number, | 
| 69     int pending_resource_host_id) { | 66     int pending_resource_host_id) { | 
| 70   // Check that the message is destined for the plugin this object is associated | 67   // Check that the message is destined for the plugin this object is associated | 
| 71   // with. | 68   // with. | 
| 72   std::map<int32_t, PendingResourceIDCallback>::iterator it = | 69   std::map<int32_t, PendingResourceIDCallback>::iterator it = | 
| 73       pending_create_map_.find(sequence_number); | 70       pending_create_map_.find(sequence_number); | 
| 74   if (it != pending_create_map_.end()) { | 71   if (it != pending_create_map_.end()) { | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 102   // manually check. | 99   // manually check. | 
| 103   int32_t ret = next_sequence_number_; | 100   int32_t ret = next_sequence_number_; | 
| 104   if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) | 101   if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) | 
| 105     next_sequence_number_ = 1;  // Skip 0 which is invalid. | 102     next_sequence_number_ = 1;  // Skip 0 which is invalid. | 
| 106   else | 103   else | 
| 107     next_sequence_number_++; | 104     next_sequence_number_++; | 
| 108   return ret; | 105   return ret; | 
| 109 } | 106 } | 
| 110 | 107 | 
| 111 }  // namespace content | 108 }  // namespace content | 
| OLD | NEW | 
|---|