Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_SERIALIZED_FLASH_MENU_H_ | 5 #ifndef PPAPI_PROXY_HANDLE_CONVERTER_H_ |
| 6 #define PPAPI_PROXY_SERIALIZED_FLASH_MENU_H_ | 6 #define PPAPI_PROXY_HANDLE_CONVERTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 12 #include "ppapi/proxy/ppapi_proxy_export.h" | 13 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 13 | 14 |
| 14 class PickleIterator; | |
| 15 | |
| 16 struct PP_Flash_Menu; | |
| 17 | |
| 18 namespace IPC { | 15 namespace IPC { |
| 19 class Message; | 16 class Message; |
| 20 } | 17 } |
| 21 | 18 |
| 22 namespace ppapi { | 19 namespace ppapi { |
| 23 namespace proxy { | 20 namespace proxy { |
| 24 | 21 |
| 25 class PPAPI_PROXY_EXPORT SerializedFlashMenu { | 22 class SerializedHandle; |
| 23 | |
| 24 class PPAPI_PROXY_EXPORT HandleConverter { | |
| 26 public: | 25 public: |
| 27 SerializedFlashMenu(); | 26 HandleConverter(); |
| 28 ~SerializedFlashMenu(); | |
| 29 | 27 |
| 30 bool SetPPMenu(const PP_Flash_Menu* menu); | 28 // Convert the native handles in |msg| to NaCl style. In some cases (e.g., |
| 29 // Windows), we need to re-write the contents of the message; in those cases, | |
| 30 // a new message will be returned. If |msg| is already in a good form for | |
| 31 // NaCl, a NULL scoped_ptr is returned. See explanation in the body of the | |
| 32 // method. | |
| 33 // | |
| 34 // In either case, all the handles in |msg| are extracted into |handles| so | |
| 35 // that they can be converted to NaClDesc handles. | |
| 36 // See chrome/nacl/nacl_ipc_adapter.cc for where this gets used. | |
| 37 bool ConvertNativeHandlesToPosix(const IPC::Message& msg, | |
|
teravest
2013/01/15 21:14:34
It feels gross to me to use a scoped_ptr<> as an o
dmichael (off chromium)
2013/01/15 23:18:59
I struggled with a good way to do this. I also con
dmichael (off chromium)
2013/01/15 23:47:06
FWIW I checked, and scoped_ptr<Foo>* is not withou
| |
| 38 std::vector<SerializedHandle>* handles, | |
| 39 scoped_ptr<IPC::Message>* new_msg_ptr); | |
| 31 | 40 |
| 32 const PP_Flash_Menu* pp_menu() const { return pp_menu_; } | 41 // |SendingSyncMessage| allows HandleConverter to know what sync messages are |
|
teravest
2013/01/15 21:14:34
The name here is a little funny. Even RegisterSync
bbudge
2013/01/15 22:20:25
+1 or even RegisterSyncMessageForReply.
dmichael (off chromium)
2013/01/15 23:18:59
I didn't like it either :-)
Thanks for the good s
| |
| 33 | 42 // being sent, so that it can associate reply messages with their type. |
| 34 void WriteToMessage(IPC::Message* m) const; | 43 // |
| 35 bool ReadFromMessage(const IPC::Message* m, PickleIterator* iter); | 44 // Users of HandleConverter must call this when they send a synchronous |
| 45 // message, otherwise HandleConverter won't be able to convert handles in | |
| 46 // replies. | |
| 47 void SendingSyncMessage(const IPC::Message& msg); | |
| 36 | 48 |
| 37 private: | 49 private: |
| 38 const PP_Flash_Menu* pp_menu_; | 50 // When we send a synchronous message (from untrusted to trusted), we store |
| 39 bool own_menu_; | 51 // its type here, so that later we can associate the reply with its type |
| 40 DISALLOW_COPY_AND_ASSIGN(SerializedFlashMenu); | 52 // and potentially translate handles in the message. |
| 53 typedef std::map<int, uint32> PendingSyncMsgMap; | |
| 54 PendingSyncMsgMap pending_sync_msgs_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(HandleConverter); | |
| 41 }; | 57 }; |
| 42 | 58 |
| 43 } // namespace proxy | 59 } // namespace proxy |
| 44 } // namespace ppapi | 60 } // namespace ppapi |
| 45 | 61 |
| 46 #endif // PPAPI_PROXY_SERIALIZED_FLASH_MENU_H_ | 62 #endif // PPAPI_PROXY_HANDLE_CONVERTER_H_ |
| OLD | NEW |