| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 IPC_IPC_SYNC_MESSAGE_H_ | 5 #ifndef IPC_IPC_SYNC_MESSAGE_H_ |
| 6 #define IPC_IPC_SYNC_MESSAGE_H_ | 6 #define IPC_IPC_SYNC_MESSAGE_H_ |
| 7 | 7 |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif | 10 #endif |
| 11 #include <string> | 11 #include <string> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 struct SyncHeader { | 70 struct SyncHeader { |
| 71 // unique ID (unique per sender) | 71 // unique ID (unique per sender) |
| 72 int message_id; | 72 int message_id; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 static bool ReadSyncHeader(const Message& msg, SyncHeader* header); | 75 static bool ReadSyncHeader(const Message& msg, SyncHeader* header); |
| 76 static bool WriteSyncHeader(Message* msg, const SyncHeader& header); | 76 static bool WriteSyncHeader(Message* msg, const SyncHeader& header); |
| 77 | 77 |
| 78 MessageReplyDeserializer* deserializer_; | 78 MessageReplyDeserializer* deserializer_; |
| 79 base::WaitableEvent* pump_messages_event_; | 79 base::WaitableEvent* pump_messages_event_; |
| 80 | |
| 81 static uint32 next_id_; // for generation of unique ids | |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 // Used to deserialize parameters from a reply to a synchronous message | 82 // Used to deserialize parameters from a reply to a synchronous message |
| 85 class MessageReplyDeserializer { | 83 class MessageReplyDeserializer { |
| 86 public: | 84 public: |
| 87 virtual ~MessageReplyDeserializer() {} | 85 virtual ~MessageReplyDeserializer() {} |
| 88 bool SerializeOutputParameters(const Message& msg); | 86 bool SerializeOutputParameters(const Message& msg); |
| 89 private: | 87 private: |
| 90 // Derived classes need to implement this, using the given iterator (which | 88 // Derived classes need to implement this, using the given iterator (which |
| 91 // is skipped past the header for synchronous messages). | 89 // is skipped past the header for synchronous messages). |
| 92 virtual bool SerializeOutputParameters(const Message& msg, void* iter) = 0; | 90 virtual bool SerializeOutputParameters(const Message& msg, void* iter) = 0; |
| 93 }; | 91 }; |
| 94 | 92 |
| 93 // When sending a synchronous message, this structure contains an object |
| 94 // that knows how to deserialize the response. |
| 95 struct PendingSyncMsg { |
| 96 PendingSyncMsg(int id, |
| 97 MessageReplyDeserializer* d, |
| 98 base::WaitableEvent* e) |
| 99 : id(id), deserializer(d), done_event(e), send_result(false) { } |
| 100 int id; |
| 101 MessageReplyDeserializer* deserializer; |
| 102 base::WaitableEvent* done_event; |
| 103 bool send_result; |
| 104 }; |
| 105 |
| 95 } // namespace IPC | 106 } // namespace IPC |
| 96 | 107 |
| 97 #endif // IPC_IPC_SYNC_MESSAGE_H_ | 108 #endif // IPC_IPC_SYNC_MESSAGE_H_ |
| OLD | NEW |