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( | 111 int32_t PluginResource::GenericSyncCall(Destination dest, |
112 Destination dest, | 112 const IPC::Message& msg, |
113 const IPC::Message& msg, | 113 IPC::Message* reply) { |
114 IPC::Message* reply, | |
115 ResourceMessageReplyParams* reply_params) { | |
116 ResourceMessageCallParams params(pp_resource(), GetNextSequence()); | 114 ResourceMessageCallParams params(pp_resource(), GetNextSequence()); |
117 params.set_has_callback(); | 115 params.set_has_callback(); |
| 116 ResourceMessageReplyParams reply_params; |
118 bool success = GetSender(dest)->Send(new PpapiHostMsg_ResourceSyncCall( | 117 bool success = GetSender(dest)->Send(new PpapiHostMsg_ResourceSyncCall( |
119 params, msg, reply_params, reply)); | 118 params, msg, &reply_params, reply)); |
120 if (success) | 119 if (success) |
121 return reply_params->result(); | 120 return reply_params.result(); |
122 return PP_ERROR_FAILED; | 121 return PP_ERROR_FAILED; |
123 } | 122 } |
124 | 123 |
125 int32_t PluginResource::GetNextSequence() { | 124 int32_t PluginResource::GetNextSequence() { |
126 // Return the value with wraparound, making sure we don't make a sequence | 125 // Return the value with wraparound, making sure we don't make a sequence |
127 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we | 126 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we |
128 // manually check. | 127 // manually check. |
129 int32_t ret = next_sequence_number_; | 128 int32_t ret = next_sequence_number_; |
130 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) | 129 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) |
131 next_sequence_number_ = 1; // Skip 0 which is invalid. | 130 next_sequence_number_ = 1; // Skip 0 which is invalid. |
132 else | 131 else |
133 next_sequence_number_++; | 132 next_sequence_number_++; |
134 return ret; | 133 return ret; |
135 } | 134 } |
136 | 135 |
137 } // namespace proxy | 136 } // namespace proxy |
138 } // namespace ppapi | 137 } // namespace ppapi |
OLD | NEW |