| 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 "ppapi/proxy/nacl_message_scanner.h" | 5 #include "ppapi/proxy/nacl_message_scanner.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // Resource id for resource messages. Save this when scanning resource replies | 48 // Resource id for resource messages. Save this when scanning resource replies |
| 49 // so when we audit the nested message, we know which resource it is for. | 49 // so when we audit the nested message, we know which resource it is for. |
| 50 PP_Resource pp_resource; | 50 PP_Resource pp_resource; |
| 51 // Callback to receive the nested message in a resource message or reply. | 51 // Callback to receive the nested message in a resource message or reply. |
| 52 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> | 52 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> |
| 53 nested_msg_callback; | 53 nested_msg_callback; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 void WriteHandle(int handle_index, | 56 void WriteHandle(int handle_index, |
| 57 const SerializedHandle& handle, | 57 const SerializedHandle& handle, |
| 58 IPC::Message* msg) { | 58 base::Pickle* msg) { |
| 59 SerializedHandle::WriteHeader(handle.header(), msg); | 59 SerializedHandle::WriteHeader(handle.header(), msg); |
| 60 | 60 |
| 61 if (handle.type() != SerializedHandle::INVALID) { | 61 if (handle.type() != SerializedHandle::INVALID) { |
| 62 // Now write the handle itself in POSIX style. | 62 // Now write the handle itself in POSIX style. |
| 63 // See ParamTraits<FileDescriptor>::Read for where these values are read. | 63 // See ParamTraits<FileDescriptor>::Read for where these values are read. |
| 64 msg->WriteBool(true); // valid == true | 64 msg->WriteBool(true); // valid == true |
| 65 msg->WriteBool(false); // brokerable == false | 65 msg->WriteBool(false); // brokerable == false |
| 66 msg->WriteInt(handle_index); | 66 msg->WriteInt(handle_index); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Define overloads for each kind of message parameter that requires special | 70 // Define overloads for each kind of message parameter that requires special |
| 71 // handling. See ScanTuple for how these get used. | 71 // handling. See ScanTuple for how these get used. |
| 72 | 72 |
| 73 // Overload to match SerializedHandle. | 73 // Overload to match SerializedHandle. |
| 74 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { | 74 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { |
| 75 results->handles.push_back(handle); | 75 results->handles.push_back(handle); |
| 76 if (results->new_msg) | 76 if (results->new_msg) |
| 77 WriteHandle(results->handle_index++, handle, results->new_msg.get()); | 77 WriteHandle(results->handle_index++, handle, results->new_msg.get()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void HandleWriter(int* handle_index, | 80 void HandleWriter(int* handle_index, |
| 81 IPC::Message* m, | 81 base::Pickle* m, |
| 82 const SerializedHandle& handle) { | 82 const SerializedHandle& handle) { |
| 83 WriteHandle((*handle_index)++, handle, m); | 83 WriteHandle((*handle_index)++, handle, m); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Overload to match SerializedVar, which can contain handles. | 86 // Overload to match SerializedVar, which can contain handles. |
| 87 void ScanParam(const SerializedVar& var, ScanningResults* results) { | 87 void ScanParam(const SerializedVar& var, ScanningResults* results) { |
| 88 std::vector<SerializedHandle*> var_handles = var.GetHandles(); | 88 std::vector<SerializedHandle*> var_handles = var.GetHandles(); |
| 89 // Copy any handles and then rewrite the message. | 89 // Copy any handles and then rewrite the message. |
| 90 for (size_t i = 0; i < var_handles.size(); ++i) | 90 for (size_t i = 0; i < var_handles.size(); ++i) |
| 91 results->handles.push_back(*var_handles[i]); | 91 results->handles.push_back(*var_handles[i]); |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 fio_it->second->SetMaxWrittenOffset(offset_it->second); | 560 fio_it->second->SetMaxWrittenOffset(offset_it->second); |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 break; | 563 break; |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namespace proxy | 568 } // namespace proxy |
| 569 } // namespace ppapi | 569 } // namespace ppapi |
| OLD | NEW |