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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
55 | 55 |
56 // Now write the handle itself in POSIX style. | 56 if (handle.type() != SerializedHandle::INVALID) { |
57 msg->WriteBool(true); // valid == true | 57 // Now write the handle itself in POSIX style. |
58 msg->WriteInt(handle_index); | 58 // See ParamTraits<FileDescriptor>::Read for where these values are read. |
| 59 msg->WriteBool(true); // valid == true |
| 60 msg->WriteInt(handle_index); |
| 61 } |
59 } | 62 } |
60 | 63 |
61 // Define overloads for each kind of message parameter that requires special | 64 // Define overloads for each kind of message parameter that requires special |
62 // handling. See ScanTuple for how these get used. | 65 // handling. See ScanTuple for how these get used. |
63 | 66 |
64 // Overload to match SerializedHandle. | 67 // Overload to match SerializedHandle. |
65 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { | 68 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { |
66 results->handles.push_back(handle); | 69 results->handles.push_back(handle); |
67 if (results->new_msg) | 70 if (results->new_msg) |
68 WriteHandle(results->handle_index++, handle, results->new_msg.get()); | 71 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 | 314 // that there are no handles, we can cancel the rewriting by clearing the |
312 // results.new_msg pointer. | 315 // results.new_msg pointer. |
313 ScanningResults results; | 316 ScanningResults results; |
314 results.nested_msg_callback = | 317 results.nested_msg_callback = |
315 base::Bind(&NaClMessageScanner::AuditNestedMessage, | 318 base::Bind(&NaClMessageScanner::AuditNestedMessage, |
316 base::Unretained(this)); | 319 base::Unretained(this)); |
317 switch (type) { | 320 switch (type) { |
318 CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) | 321 CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) |
319 CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) | 322 CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) |
320 CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply) | 323 CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply) |
| 324 CASE_FOR_REPLY(PpapiHostMsg_OpenResource) |
321 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_Create) | 325 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_Create) |
322 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer) | 326 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer) |
323 CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple) | 327 CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple) |
324 CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall) | 328 CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall) |
325 CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory) | 329 CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory) |
326 default: | 330 default: |
327 // Do nothing for messages we don't know. | 331 // Do nothing for messages we don't know. |
328 break; | 332 break; |
329 } | 333 } |
330 | 334 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 fio_it->second->SetMaxWrittenOffset(offset_it->second); | 514 fio_it->second->SetMaxWrittenOffset(offset_it->second); |
511 } | 515 } |
512 } | 516 } |
513 break; | 517 break; |
514 } | 518 } |
515 } | 519 } |
516 } | 520 } |
517 | 521 |
518 } // namespace proxy | 522 } // namespace proxy |
519 } // namespace ppapi | 523 } // namespace ppapi |
OLD | NEW |