| OLD | NEW |
| 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/proxy/plugin_resource.h" | 5 #include "ppapi/proxy/plugin_resource.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "ppapi/proxy/ppapi_messages.h" | 9 #include "ppapi/proxy/ppapi_messages.h" |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool PluginResource::SendResourceCall( | 103 bool PluginResource::SendResourceCall( |
| 104 Destination dest, | 104 Destination dest, |
| 105 const ResourceMessageCallParams& call_params, | 105 const ResourceMessageCallParams& call_params, |
| 106 const IPC::Message& nested_msg) { | 106 const IPC::Message& nested_msg) { |
| 107 return GetSender(dest)->Send( | 107 return GetSender(dest)->Send( |
| 108 new PpapiHostMsg_ResourceCall(call_params, nested_msg)); | 108 new PpapiHostMsg_ResourceCall(call_params, nested_msg)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 int32_t PluginResource::GenericSyncCall(Destination dest, | 111 int32_t PluginResource::GenericSyncCall( |
| 112 const IPC::Message& msg, | 112 Destination dest, |
| 113 IPC::Message* reply) { | 113 const IPC::Message& msg, |
| 114 IPC::Message* reply, |
| 115 ResourceMessageReplyParams* reply_params) { |
| 114 ResourceMessageCallParams params(pp_resource(), GetNextSequence()); | 116 ResourceMessageCallParams params(pp_resource(), GetNextSequence()); |
| 115 params.set_has_callback(); | 117 params.set_has_callback(); |
| 116 ResourceMessageReplyParams reply_params; | |
| 117 bool success = GetSender(dest)->Send(new PpapiHostMsg_ResourceSyncCall( | 118 bool success = GetSender(dest)->Send(new PpapiHostMsg_ResourceSyncCall( |
| 118 params, msg, &reply_params, reply)); | 119 params, msg, reply_params, reply)); |
| 119 if (success) | 120 if (success) |
| 120 return reply_params.result(); | 121 return reply_params->result(); |
| 121 return PP_ERROR_FAILED; | 122 return PP_ERROR_FAILED; |
| 122 } | 123 } |
| 123 | 124 |
| 124 int32_t PluginResource::GetNextSequence() { | 125 int32_t PluginResource::GetNextSequence() { |
| 125 // Return the value with wraparound, making sure we don't make a sequence | 126 // Return the value with wraparound, making sure we don't make a sequence |
| 126 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we | 127 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we |
| 127 // manually check. | 128 // manually check. |
| 128 int32_t ret = next_sequence_number_; | 129 int32_t ret = next_sequence_number_; |
| 129 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) | 130 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) |
| 130 next_sequence_number_ = 1; // Skip 0 which is invalid. | 131 next_sequence_number_ = 1; // Skip 0 which is invalid. |
| 131 else | 132 else |
| 132 next_sequence_number_++; | 133 next_sequence_number_++; |
| 133 return ret; | 134 return ret; |
| 134 } | 135 } |
| 135 | 136 |
| 136 } // namespace proxy | 137 } // namespace proxy |
| 137 } // namespace ppapi | 138 } // namespace ppapi |
| OLD | NEW |