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 <tuple> | 9 #include <tuple> |
10 #include <utility> | 10 #include <utility> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Callback to receive the nested message in a resource message or reply. | 52 // Callback to receive the nested message in a resource message or reply. |
53 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> | 53 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> |
54 nested_msg_callback; | 54 nested_msg_callback; |
55 }; | 55 }; |
56 | 56 |
57 void WriteHandle(int handle_index, | 57 void WriteHandle(int handle_index, |
58 const SerializedHandle& handle, | 58 const SerializedHandle& handle, |
59 base::Pickle* msg) { | 59 base::Pickle* msg) { |
60 SerializedHandle::WriteHeader(handle.header(), msg); | 60 SerializedHandle::WriteHeader(handle.header(), msg); |
61 | 61 |
62 if (handle.type() != SerializedHandle::INVALID) { | 62 if (handle.type() == SerializedHandle::SHARED_MEMORY) { |
63 // Now write the handle itself in POSIX style. | 63 // Now write the handle itself in POSIX style. |
64 // See ParamTraits<FileDescriptor>::Read for where these values are read. | 64 // This serialization must be kept in sync with |
| 65 // ParamTraits<SharedMemoryHandle>::Write and |
| 66 // ParamTraits<UnguessableToken>::Write. |
| 67 if (handle.shmem().IsValid()) { |
| 68 msg->WriteBool(true); // valid == true |
| 69 msg->WriteInt(handle_index); |
| 70 msg->WriteUInt64(handle.shmem().GetGUID().GetHighForSerialization()); |
| 71 msg->WriteUInt64(handle.shmem().GetGUID().GetLowForSerialization()); |
| 72 } else { |
| 73 msg->WriteBool(false); // valid == false |
| 74 } |
| 75 } else if (handle.type() != SerializedHandle::INVALID) { |
| 76 // Now write the handle itself in POSIX style. |
| 77 // This serialization must be kept in sync with |
| 78 // ParamTraits<FileDescriptor>::Write. |
65 msg->WriteBool(true); // valid == true | 79 msg->WriteBool(true); // valid == true |
66 msg->WriteInt(handle_index); | 80 msg->WriteInt(handle_index); |
67 } | 81 } |
68 } | 82 } |
69 | 83 |
70 // Define overloads for each kind of message parameter that requires special | 84 // Define overloads for each kind of message parameter that requires special |
71 // handling. See ScanTuple for how these get used. | 85 // handling. See ScanTuple for how these get used. |
72 | 86 |
73 // Overload to match SerializedHandle. | 87 // Overload to match SerializedHandle. |
74 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { | 88 void ScanParam(const SerializedHandle& handle, ScanningResults* results) { |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 fio_it->second->SetMaxWrittenOffset(offset_it->second); | 572 fio_it->second->SetMaxWrittenOffset(offset_it->second); |
559 } | 573 } |
560 } | 574 } |
561 break; | 575 break; |
562 } | 576 } |
563 } | 577 } |
564 } | 578 } |
565 | 579 |
566 } // namespace proxy | 580 } // namespace proxy |
567 } // namespace ppapi | 581 } // namespace ppapi |
OLD | NEW |