| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 it != file_systems_.end(); ++it) | 286 it != file_systems_.end(); ++it) |
| 287 delete it->second; | 287 delete it->second; |
| 288 for (FileIOMap::iterator it = files_.begin(); it != files_.end(); ++it) | 288 for (FileIOMap::iterator it = files_.begin(); it != files_.end(); ++it) |
| 289 delete it->second; | 289 delete it->second; |
| 290 } | 290 } |
| 291 | 291 |
| 292 // Windows IPC differs from POSIX in that native handles are serialized in the | 292 // Windows IPC differs from POSIX in that native handles are serialized in the |
| 293 // message body, rather than passed in a separate FileDescriptorSet. Therefore, | 293 // message body, rather than passed in a separate FileDescriptorSet. Therefore, |
| 294 // on Windows, any message containing handles must be rewritten in the POSIX | 294 // on Windows, any message containing handles must be rewritten in the POSIX |
| 295 // format before we can send it to the NaCl plugin. | 295 // format before we can send it to the NaCl plugin. |
| 296 // On Mac, base::SharedMemoryHandle has a different serialization than | |
| 297 // base::FileDescriptor (which base::SharedMemoryHandle is typedef-ed to in | |
| 298 // OS_NACL). | |
| 299 bool NaClMessageScanner::ScanMessage( | 296 bool NaClMessageScanner::ScanMessage( |
| 300 const IPC::Message& msg, | 297 const IPC::Message& msg, |
| 301 uint32_t type, | 298 uint32_t type, |
| 302 std::vector<SerializedHandle>* handles, | 299 std::vector<SerializedHandle>* handles, |
| 303 scoped_ptr<IPC::Message>* new_msg_ptr) { | 300 scoped_ptr<IPC::Message>* new_msg_ptr) { |
| 304 DCHECK(handles); | 301 DCHECK(handles); |
| 305 DCHECK(handles->empty()); | 302 DCHECK(handles->empty()); |
| 306 DCHECK(new_msg_ptr); | 303 DCHECK(new_msg_ptr); |
| 307 DCHECK(!new_msg_ptr->get()); | 304 DCHECK(!new_msg_ptr->get()); |
| 308 | 305 |
| 309 bool rewrite_msg = | 306 bool rewrite_msg = |
| 310 #if defined(OS_WIN) || defined(OS_MACOSX) | 307 #if defined(OS_WIN) |
| 311 true; | 308 true; |
| 312 #else | 309 #else |
| 313 false; | 310 false; |
| 314 #endif | 311 #endif |
| 315 | 312 |
| 316 // We can't always tell from the message ID if rewriting is needed. Therefore, | 313 // We can't always tell from the message ID if rewriting is needed. Therefore, |
| 317 // scan any message types that might contain a handle. If we later determine | 314 // scan any message types that might contain a handle. If we later determine |
| 318 // that there are no handles, we can cancel the rewriting by clearing the | 315 // that there are no handles, we can cancel the rewriting by clearing the |
| 319 // results.new_msg pointer. | 316 // results.new_msg pointer. |
| 320 ScanningResults results; | 317 ScanningResults results; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 fio_it->second->SetMaxWrittenOffset(offset_it->second); | 515 fio_it->second->SetMaxWrittenOffset(offset_it->second); |
| 519 } | 516 } |
| 520 } | 517 } |
| 521 break; | 518 break; |
| 522 } | 519 } |
| 523 } | 520 } |
| 524 } | 521 } |
| 525 | 522 |
| 526 } // namespace proxy | 523 } // namespace proxy |
| 527 } // namespace ppapi | 524 } // namespace ppapi |
| OLD | NEW |