| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 #include <stack> | 10 #include <stack> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 set_pump_messages_event(dummy_event.Pointer()); | 67 set_pump_messages_event(dummy_event.Pointer()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool SyncMessage::IsMessageReplyTo(const Message& msg, int request_id) { | 70 bool SyncMessage::IsMessageReplyTo(const Message& msg, int request_id) { |
| 71 if (!msg.is_reply()) | 71 if (!msg.is_reply()) |
| 72 return false; | 72 return false; |
| 73 | 73 |
| 74 return GetMessageId(msg) == request_id; | 74 return GetMessageId(msg) == request_id; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void* SyncMessage::GetDataIterator(const Message* msg) { | 77 PickleIterator SyncMessage::GetDataIterator(const Message* msg) { |
| 78 void* iter = const_cast<char*>(msg->payload()); | 78 PickleIterator iter(*msg); |
| 79 UpdateIter(&iter, kSyncMessageHeaderSize); | 79 if (!iter.SkipBytes(kSyncMessageHeaderSize)) |
| 80 return iter; | 80 return PickleIterator(); |
| 81 else |
| 82 return iter; |
| 81 } | 83 } |
| 82 | 84 |
| 83 int SyncMessage::GetMessageId(const Message& msg) { | 85 int SyncMessage::GetMessageId(const Message& msg) { |
| 84 if (!msg.is_sync() && !msg.is_reply()) | 86 if (!msg.is_sync() && !msg.is_reply()) |
| 85 return 0; | 87 return 0; |
| 86 | 88 |
| 87 SyncHeader header; | 89 SyncHeader header; |
| 88 if (!ReadSyncHeader(msg, &header)) | 90 if (!ReadSyncHeader(msg, &header)) |
| 89 return 0; | 91 return 0; |
| 90 | 92 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 // use the same message id, but this time reply bit is set | 105 // use the same message id, but this time reply bit is set |
| 104 header.message_id = GetMessageId(*msg); | 106 header.message_id = GetMessageId(*msg); |
| 105 WriteSyncHeader(reply, header); | 107 WriteSyncHeader(reply, header); |
| 106 | 108 |
| 107 return reply; | 109 return reply; |
| 108 } | 110 } |
| 109 | 111 |
| 110 bool SyncMessage::ReadSyncHeader(const Message& msg, SyncHeader* header) { | 112 bool SyncMessage::ReadSyncHeader(const Message& msg, SyncHeader* header) { |
| 111 DCHECK(msg.is_sync() || msg.is_reply()); | 113 DCHECK(msg.is_sync() || msg.is_reply()); |
| 112 | 114 |
| 113 void* iter = NULL; | 115 PickleIterator iter(msg); |
| 114 bool result = msg.ReadInt(&iter, &header->message_id); | 116 bool result = msg.ReadInt(&iter, &header->message_id); |
| 115 if (!result) { | 117 if (!result) { |
| 116 NOTREACHED(); | 118 NOTREACHED(); |
| 117 return false; | 119 return false; |
| 118 } | 120 } |
| 119 | 121 |
| 120 return true; | 122 return true; |
| 121 } | 123 } |
| 122 | 124 |
| 123 bool SyncMessage::WriteSyncHeader(Message* msg, const SyncHeader& header) { | 125 bool SyncMessage::WriteSyncHeader(Message* msg, const SyncHeader& header) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 134 | 136 |
| 135 return true; | 137 return true; |
| 136 } | 138 } |
| 137 | 139 |
| 138 | 140 |
| 139 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { | 141 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { |
| 140 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); | 142 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); |
| 141 } | 143 } |
| 142 | 144 |
| 143 } // namespace IPC | 145 } // namespace IPC |
| OLD | NEW |