| 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 #ifndef PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_ | 5 #ifndef PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_ |
| 6 #define PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_ | 6 #define PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 NaClMessageScanner(); | 28 NaClMessageScanner(); |
| 29 ~NaClMessageScanner(); | 29 ~NaClMessageScanner(); |
| 30 | 30 |
| 31 // Scans the message for items that require special handling. Copies any | 31 // Scans the message for items that require special handling. Copies any |
| 32 // SerializedHandles in the message into |handles| and if the message must be | 32 // SerializedHandles in the message into |handles| and if the message must be |
| 33 // rewritten for NaCl, sets |new_msg_ptr| to the new message. If no handles | 33 // rewritten for NaCl, sets |new_msg_ptr| to the new message. If no handles |
| 34 // are found, |handles| is left unchanged. If no rewriting is needed, | 34 // are found, |handles| is left unchanged. If no rewriting is needed, |
| 35 // |new_msg_ptr| is left unchanged. | 35 // |new_msg_ptr| is left unchanged. |
| 36 // | 36 // |
| 37 // For normal messages, |type| is equivalent to |msg|.id(), but, if |msg| is |
| 38 // a reply to a synchronous message, |type| is the id of the original |
| 39 // message. |
| 40 // |
| 37 // See more explanation in the method definition. | 41 // See more explanation in the method definition. |
| 38 // | 42 // |
| 39 // See chrome/nacl/nacl_ipc_adapter.cc for where this is used to help convert | 43 // See chrome/nacl/nacl_ipc_adapter.cc for where this is used to help convert |
| 40 // native handles to NaClDescs. | 44 // native handles to NaClDescs. |
| 41 bool ScanMessage(const IPC::Message& msg, | 45 bool ScanMessage(const IPC::Message& msg, |
| 46 uint32_t type, |
| 42 std::vector<SerializedHandle>* handles, | 47 std::vector<SerializedHandle>* handles, |
| 43 scoped_ptr<IPC::Message>* new_msg_ptr); | 48 scoped_ptr<IPC::Message>* new_msg_ptr); |
| 44 | 49 |
| 45 // Scans an untrusted message for items that require special handling. If the | 50 // Scans an untrusted message for items that require special handling. If the |
| 46 // message had to be rewritten, sets |new_msg_ptr| to the new message. | 51 // message had to be rewritten, sets |new_msg_ptr| to the new message. |
| 47 void ScanUntrustedMessage(const IPC::Message& untrusted_msg, | 52 void ScanUntrustedMessage(const IPC::Message& untrusted_msg, |
| 48 scoped_ptr<IPC::Message>* new_msg_ptr); | 53 scoped_ptr<IPC::Message>* new_msg_ptr); |
| 49 | 54 |
| 50 // FileSystem information for quota auditing. | 55 // FileSystem information for quota auditing. |
| 51 class PPAPI_PROXY_EXPORT FileSystem { | 56 class PPAPI_PROXY_EXPORT FileSystem { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // plugin writes to greater maximum offsets. | 97 // plugin writes to greater maximum offsets. |
| 93 int64_t max_written_offset_; | 98 int64_t max_written_offset_; |
| 94 | 99 |
| 95 DISALLOW_COPY_AND_ASSIGN(FileIO); | 100 DISALLOW_COPY_AND_ASSIGN(FileIO); |
| 96 }; | 101 }; |
| 97 | 102 |
| 98 FileIO* GetFile(PP_Resource file_io); | 103 FileIO* GetFile(PP_Resource file_io); |
| 99 | 104 |
| 100 private: | 105 private: |
| 101 friend class NaClMessageScannerTest; | 106 friend class NaClMessageScannerTest; |
| 102 | |
| 103 void RegisterSyncMessageForReply(const IPC::Message& msg); | |
| 104 void AuditNestedMessage(PP_Resource resource, | 107 void AuditNestedMessage(PP_Resource resource, |
| 105 const IPC::Message& msg, | 108 const IPC::Message& msg, |
| 106 SerializedHandle* handle); | 109 SerializedHandle* handle); |
| 107 | 110 |
| 108 // When we send a synchronous message (from untrusted to trusted), we store | |
| 109 // its type here, so that later we can associate the reply with its type | |
| 110 // for scanning. | |
| 111 typedef std::map<int, uint32> PendingSyncMsgMap; | |
| 112 PendingSyncMsgMap pending_sync_msgs_; | |
| 113 | |
| 114 // We intercept FileSystem and FileIO messages to maintain information about | 111 // We intercept FileSystem and FileIO messages to maintain information about |
| 115 // file systems and open files. This is used by NaClQuotaDescs to calculate | 112 // file systems and open files. This is used by NaClQuotaDescs to calculate |
| 116 // quota consumption and check it against the reserved amount. | 113 // quota consumption and check it against the reserved amount. |
| 117 typedef std::map<int32_t, FileSystem*> FileSystemMap; | 114 typedef std::map<int32_t, FileSystem*> FileSystemMap; |
| 118 FileSystemMap file_systems_; | 115 FileSystemMap file_systems_; |
| 119 typedef std::map<int32_t, FileIO*> FileIOMap; | 116 typedef std::map<int32_t, FileIO*> FileIOMap; |
| 120 FileIOMap files_; | 117 FileIOMap files_; |
| 121 | 118 |
| 122 DISALLOW_COPY_AND_ASSIGN(NaClMessageScanner); | 119 DISALLOW_COPY_AND_ASSIGN(NaClMessageScanner); |
| 123 }; | 120 }; |
| 124 | 121 |
| 125 } // namespace proxy | 122 } // namespace proxy |
| 126 } // namespace ppapi | 123 } // namespace ppapi |
| 127 | 124 |
| 128 #endif // PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_ | 125 #endif // PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_ |
| OLD | NEW |