Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 // so when we audit the nested message, we know which resource it is for. | 44 // so when we audit the nested message, we know which resource it is for. |
| 45 PP_Resource pp_resource; | 45 PP_Resource pp_resource; |
| 46 // Callback to receive the nested message in a resource message or reply. | 46 // Callback to receive the nested message in a resource message or reply. |
| 47 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> | 47 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> |
| 48 nested_msg_callback; | 48 nested_msg_callback; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 void WriteHandle(int handle_index, | 51 void WriteHandle(int handle_index, |
| 52 const SerializedHandle& handle, | 52 const SerializedHandle& handle, |
| 53 IPC::Message* msg) { | 53 IPC::Message* msg) { |
| 54 SerializedHandle::WriteHeader(handle.header(), msg); | 54 SerializedHandle::WriteHeader(handle.header(), msg); |
|
Mark Seaborn
2014/09/08 16:26:53
BTW, this has a return valid that isn't checked he
teravest
2014/09/08 20:25:28
I inspected SerializedHandle::WriteHeader and foun
| |
| 55 | 55 |
| 56 // Now write the handle itself in POSIX style. | 56 if (handle.type() != SerializedHandle::INVALID) { |
|
Mark Seaborn
2014/09/08 16:26:52
Where is the corresponding reader for this format?
teravest
2014/09/08 20:25:27
The valid field is read out here:
https://code.goo
| |
| 57 msg->WriteBool(true); // valid == true | 57 // Now write the handle itself in POSIX style. |
| 58 msg->WriteInt(handle_index); | 58 msg->WriteBool(true); // valid == true |
| 59 msg->WriteInt(handle_index); | |
| 60 } | |
| 59 } | 61 } |
| 60 | 62 |
| 61 // Define overloads for each kind of message parameter that requires special | 63 // Define overloads for each kind of message parameter that requires special |
| 62 // handling. See ScanTuple for how these get used. | 64 // handling. See ScanTuple for how these get used. |
| 63 | 65 |
| 64 // Overload to match SerializedHandle. | 66 // Overload to match SerializedHandle. |
| 65 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { | 67 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { |
| 66 results->handles.push_back(handle); | 68 results->handles.push_back(handle); |
| 67 if (results->new_msg) | 69 if (results->new_msg) |
| 68 WriteHandle(results->handle_index++, handle, results->new_msg.get()); | 70 WriteHandle(results->handle_index++, handle, results->new_msg.get()); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 // that there are no handles, we can cancel the rewriting by clearing the | 313 // that there are no handles, we can cancel the rewriting by clearing the |
| 312 // results.new_msg pointer. | 314 // results.new_msg pointer. |
| 313 ScanningResults results; | 315 ScanningResults results; |
| 314 results.nested_msg_callback = | 316 results.nested_msg_callback = |
| 315 base::Bind(&NaClMessageScanner::AuditNestedMessage, | 317 base::Bind(&NaClMessageScanner::AuditNestedMessage, |
| 316 base::Unretained(this)); | 318 base::Unretained(this)); |
| 317 switch (type) { | 319 switch (type) { |
| 318 CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) | 320 CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) |
| 319 CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) | 321 CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) |
| 320 CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply) | 322 CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply) |
| 323 CASE_FOR_REPLY(PpapiHostMsg_OpenResource) | |
| 321 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer) | 324 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer) |
| 322 CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple) | 325 CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple) |
| 323 CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall) | 326 CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall) |
| 324 CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory) | 327 CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory) |
| 325 default: | 328 default: |
| 326 // Do nothing for messages we don't know. | 329 // Do nothing for messages we don't know. |
| 327 break; | 330 break; |
| 328 } | 331 } |
| 329 | 332 |
| 330 // Only messages containing handles need to be rewritten. If no handles are | 333 // Only messages containing handles need to be rewritten. If no handles are |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 fio_it->second->SetMaxWrittenOffset(offset_it->second); | 512 fio_it->second->SetMaxWrittenOffset(offset_it->second); |
| 510 } | 513 } |
| 511 } | 514 } |
| 512 break; | 515 break; |
| 513 } | 516 } |
| 514 } | 517 } |
| 515 } | 518 } |
| 516 | 519 |
| 517 } // namespace proxy | 520 } // namespace proxy |
| 518 } // namespace ppapi | 521 } // namespace ppapi |
| OLD | NEW |