Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: ppapi/proxy/nacl_message_scanner.h

Issue 53123002: Rename HandleConverter to NaClMessageScanner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment tweaks. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 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_HANDLE_CONVERTER_H_ 5 #ifndef PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_
6 #define PPAPI_PROXY_HANDLE_CONVERTER_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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "ppapi/proxy/ppapi_proxy_export.h" 13 #include "ppapi/proxy/ppapi_proxy_export.h"
14 14
15 namespace IPC { 15 namespace IPC {
16 class Message; 16 class Message;
17 } 17 }
18 18
19 namespace ppapi { 19 namespace ppapi {
20 namespace proxy { 20 namespace proxy {
21 21
22 class SerializedHandle; 22 class SerializedHandle;
23 23
24 class PPAPI_PROXY_EXPORT HandleConverter { 24 class PPAPI_PROXY_EXPORT NaClMessageScanner {
25 public: 25 public:
26 HandleConverter(); 26 NaClMessageScanner();
27 27
28 // Convert the native handles in |msg| to NaCl style. 28 // Scans the message for items that require special handling. Copies any
29 // In some cases (e.g., Windows), we need to re-write the contents of the 29 // SerializedHandles in the message into |handles| and if the message must be
30 // message; in those cases, |new_msg_ptr| will be set to the new message. 30 // rewritten for NaCl, sets |new_msg_ptr| to the new message. If no handles
31 // If |msg| is already in a good form for NaCl, |new_msg_ptr| is left NULL. 31 // are found, |handles| is left unchanged. If no rewriting is needed,
32 // See the explanation in the body of the method. 32 // |new_msg_ptr| is left unchanged.
33 // 33 //
34 // In either case, all the handles in |msg| are extracted into |handles| so 34 // See more explanation in the method definition.
35 // that they can be converted to NaClDesc handles. 35 //
36 // See chrome/nacl/nacl_ipc_adapter.cc for where this gets used. 36 // See chrome/nacl/nacl_ipc_adapter.cc for where this is used to help convert
37 bool ConvertNativeHandlesToPosix(const IPC::Message& msg, 37 // native handles to NaClDescs.
38 std::vector<SerializedHandle>* handles, 38 bool ScanMessage(const IPC::Message& msg,
39 scoped_ptr<IPC::Message>* new_msg_ptr); 39 std::vector<SerializedHandle>* handles,
40 scoped_ptr<IPC::Message>* new_msg_ptr);
40 41
41 // This method informs HandleConverter that a sync message is being sent so 42 // This method informs NaClMessageScanner that a sync message is being sent
42 // that it can associate reply messages with their type. 43 // so that it can associate reply messages with their type.
43 // 44 //
44 // Users of HandleConverter must call this when they send a synchronous 45 // Users of NaClMessageScanner must call this when they send a synchronous
45 // message, otherwise HandleConverter won't be able to convert handles in 46 // message, otherwise NaClMessageScanner won't scan replies.
46 // replies.
47 void RegisterSyncMessageForReply(const IPC::Message& msg); 47 void RegisterSyncMessageForReply(const IPC::Message& msg);
48 48
49 private: 49 private:
50 // When we send a synchronous message (from untrusted to trusted), we store 50 // When we send a synchronous message (from untrusted to trusted), we store
51 // its type here, so that later we can associate the reply with its type 51 // its type here, so that later we can associate the reply with its type
52 // and potentially translate handles in the message. 52 // for scanning.
53 typedef std::map<int, uint32> PendingSyncMsgMap; 53 typedef std::map<int, uint32> PendingSyncMsgMap;
54 PendingSyncMsgMap pending_sync_msgs_; 54 PendingSyncMsgMap pending_sync_msgs_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(HandleConverter); 56 DISALLOW_COPY_AND_ASSIGN(NaClMessageScanner);
57 }; 57 };
58 58
59 } // namespace proxy 59 } // namespace proxy
60 } // namespace ppapi 60 } // namespace ppapi
61 61
62 #endif // PPAPI_PROXY_HANDLE_CONVERTER_H_ 62 #endif // PPAPI_PROXY_NACL_MESSAGE_SCANNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698