| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 template <class MessageType> | 189 template <class MessageType> |
| 190 class MessageScannerImpl { | 190 class MessageScannerImpl { |
| 191 public: | 191 public: |
| 192 explicit MessageScannerImpl(const IPC::Message* msg) | 192 explicit MessageScannerImpl(const IPC::Message* msg) |
| 193 // The cast below is invalid. See https://crbug.com/520760. | 193 // The cast below is invalid. See https://crbug.com/520760. |
| 194 : msg_(static_cast<const MessageType*>(msg)) { | 194 : msg_(static_cast<const MessageType*>(msg)) { |
| 195 } | 195 } |
| 196 bool ScanMessage(ScanningResults* results) { | 196 bool ScanMessage(ScanningResults* results) { |
| 197 typename base::TupleTypes<typename MessageType::Schema::Param>::ValueTuple | 197 typename MessageType::Param params; |
| 198 params; | |
| 199 if (!MessageType::Read(msg_, ¶ms)) | 198 if (!MessageType::Read(msg_, ¶ms)) |
| 200 return false; | 199 return false; |
| 201 ScanTuple(params, results); | 200 ScanTuple(params, results); |
| 202 return true; | 201 return true; |
| 203 } | 202 } |
| 204 | 203 |
| 205 bool ScanSyncMessage(ScanningResults* results) { | 204 bool ScanSyncMessage(ScanningResults* results) { |
| 206 typename base::TupleTypes<typename MessageType::Schema::SendParam> | 205 typename MessageType::SendParam params; |
| 207 ::ValueTuple params; | |
| 208 if (!MessageType::ReadSendParam(msg_, ¶ms)) | 206 if (!MessageType::ReadSendParam(msg_, ¶ms)) |
| 209 return false; | 207 return false; |
| 210 // If we need to rewrite the message, write the message id first. | 208 // If we need to rewrite the message, write the message id first. |
| 211 if (results->new_msg) { | 209 if (results->new_msg) { |
| 212 results->new_msg->set_sync(); | 210 results->new_msg->set_sync(); |
| 213 int id = IPC::SyncMessage::GetMessageId(*msg_); | 211 int id = IPC::SyncMessage::GetMessageId(*msg_); |
| 214 results->new_msg->WriteInt(id); | 212 results->new_msg->WriteInt(id); |
| 215 } | 213 } |
| 216 ScanTuple(params, results); | 214 ScanTuple(params, results); |
| 217 return true; | 215 return true; |
| 218 } | 216 } |
| 219 | 217 |
| 220 bool ScanReply(ScanningResults* results) { | 218 bool ScanReply(ScanningResults* results) { |
| 221 typename base::TupleTypes<typename MessageType::Schema::ReplyParam> | 219 typename MessageType::ReplyParam params; |
| 222 ::ValueTuple params; | |
| 223 if (!MessageType::ReadReplyParam(msg_, ¶ms)) | 220 if (!MessageType::ReadReplyParam(msg_, ¶ms)) |
| 224 return false; | 221 return false; |
| 225 // If we need to rewrite the message, write the message id first. | 222 // If we need to rewrite the message, write the message id first. |
| 226 if (results->new_msg) { | 223 if (results->new_msg) { |
| 227 results->new_msg->set_reply(); | 224 results->new_msg->set_reply(); |
| 228 int id = IPC::SyncMessage::GetMessageId(*msg_); | 225 int id = IPC::SyncMessage::GetMessageId(*msg_); |
| 229 results->new_msg->WriteInt(id); | 226 results->new_msg->WriteInt(id); |
| 230 } | 227 } |
| 231 ScanTuple(params, results); | 228 ScanTuple(params, results); |
| 232 return true; | 229 return true; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 fio_it->second->SetMaxWrittenOffset(offset_it->second); | 558 fio_it->second->SetMaxWrittenOffset(offset_it->second); |
| 562 } | 559 } |
| 563 } | 560 } |
| 564 break; | 561 break; |
| 565 } | 562 } |
| 566 } | 563 } |
| 567 } | 564 } |
| 568 | 565 |
| 569 } // namespace proxy | 566 } // namespace proxy |
| 570 } // namespace ppapi | 567 } // namespace ppapi |
| OLD | NEW |