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 PickleReader SyncMessage::GetDataIterator(const Message* msg) { |
78 void* iter = const_cast<char*>(msg->payload()); | 78 PickleReader iter(*msg); |
79 UpdateIter(&iter, kSyncMessageHeaderSize); | 79 UpdateIter(&iter, kSyncMessageHeaderSize); |
80 return iter; | 80 return iter; |
81 } | 81 } |
82 | 82 |
83 int SyncMessage::GetMessageId(const Message& msg) { | 83 int SyncMessage::GetMessageId(const Message& msg) { |
84 if (!msg.is_sync() && !msg.is_reply()) | 84 if (!msg.is_sync() && !msg.is_reply()) |
85 return 0; | 85 return 0; |
86 | 86 |
87 SyncHeader header; | 87 SyncHeader header; |
88 if (!ReadSyncHeader(msg, &header)) | 88 if (!ReadSyncHeader(msg, &header)) |
(...skipping 14 matching lines...) Expand all Loading... |
103 // use the same message id, but this time reply bit is set | 103 // use the same message id, but this time reply bit is set |
104 header.message_id = GetMessageId(*msg); | 104 header.message_id = GetMessageId(*msg); |
105 WriteSyncHeader(reply, header); | 105 WriteSyncHeader(reply, header); |
106 | 106 |
107 return reply; | 107 return reply; |
108 } | 108 } |
109 | 109 |
110 bool SyncMessage::ReadSyncHeader(const Message& msg, SyncHeader* header) { | 110 bool SyncMessage::ReadSyncHeader(const Message& msg, SyncHeader* header) { |
111 DCHECK(msg.is_sync() || msg.is_reply()); | 111 DCHECK(msg.is_sync() || msg.is_reply()); |
112 | 112 |
113 void* iter = NULL; | 113 PickleReader iter(msg); |
114 bool result = msg.ReadInt(&iter, &header->message_id); | 114 bool result = msg.ReadInt(&iter, &header->message_id); |
115 if (!result) { | 115 if (!result) { |
116 NOTREACHED(); | 116 NOTREACHED(); |
117 return false; | 117 return false; |
118 } | 118 } |
119 | 119 |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
123 bool SyncMessage::WriteSyncHeader(Message* msg, const SyncHeader& header) { | 123 bool SyncMessage::WriteSyncHeader(Message* msg, const SyncHeader& header) { |
(...skipping 10 matching lines...) Expand all Loading... |
134 | 134 |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { | 139 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { |
140 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); | 140 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); |
141 } | 141 } |
142 | 142 |
143 } // namespace IPC | 143 } // namespace IPC |
OLD | NEW |