Index: ipc/ipc_channel_reader.cc |
diff --git a/ipc/ipc_channel_reader.cc b/ipc/ipc_channel_reader.cc |
index b805f753a1a88857b6bfb9b7db578b5454b4729a..30f03a1f2decbb2fd74b690baf5cc22eeb392ef5 100644 |
--- a/ipc/ipc_channel_reader.cc |
+++ b/ipc/ipc_channel_reader.cc |
@@ -20,7 +20,8 @@ |
} |
ChannelReader::~ChannelReader() { |
- DCHECK(blocked_ids_.empty()); |
+ if (!blocked_ids_.empty()) |
+ StopObservingAttachmentBroker(); |
} |
ChannelReader::DispatchState ChannelReader::ProcessIncomingMessages() { |
@@ -84,14 +85,11 @@ |
// Dispatch all complete messages in the data buffer. |
while (p < end) { |
- Message::NextMessageInfo info = Message::FindNext(p, end); |
- if (info.message_found) { |
- int pickle_len = static_cast<int>(info.pickle_end - p); |
- Message translated_message(p, pickle_len); |
- |
- for (const auto& id : info.attachment_ids) |
- translated_message.AddPlaceholderBrokerableAttachmentWithId(id); |
- |
+ const char* message_tail = Message::FindNext(p, end); |
+ if (message_tail) { |
+ int len = static_cast<int>(message_tail - p); |
+ |
+ Message translated_message(p, len); |
if (!GetNonBrokeredAttachments(&translated_message)) |
return false; |
@@ -105,7 +103,7 @@ |
if (blocked_ids.empty()) { |
// Dispatch the message and continue the loop. |
DispatchMessage(&translated_message); |
- p = info.message_end; |
+ p = message_tail; |
continue; |
} |
@@ -116,7 +114,7 @@ |
// Make a deep copy of |translated_message| to add to the queue. |
scoped_ptr<Message> m(new Message(translated_message)); |
queued_messages_.push_back(m.release()); |
- p = info.message_end; |
+ p = message_tail; |
} else { |
// Last message is partial. |
break; |
@@ -149,13 +147,6 @@ |
queued_messages_.erase(queued_messages_.begin()); |
} |
return DISPATCH_FINISHED; |
-} |
- |
-void ChannelReader::CleanUp() { |
- if (!blocked_ids_.empty()) { |
- StopObservingAttachmentBroker(); |
- blocked_ids_.clear(); |
- } |
} |
void ChannelReader::DispatchMessage(Message* m) { |
@@ -195,9 +186,8 @@ |
#if USE_ATTACHMENT_BROKER |
MessageAttachmentSet* set = msg->attachment_set(); |
- std::vector<const BrokerableAttachment*> brokerable_attachments_copy = |
- set->PeekBrokerableAttachments(); |
- for (const BrokerableAttachment* attachment : brokerable_attachments_copy) { |
+ for (const scoped_refptr<BrokerableAttachment>& attachment : |
+ set->GetBrokerableAttachmentsForUpdating()) { |
if (attachment->NeedsBrokering()) { |
AttachmentBroker* broker = GetAttachmentBroker(); |
scoped_refptr<BrokerableAttachment> brokered_attachment; |
@@ -208,7 +198,7 @@ |
continue; |
} |
- set->ReplacePlaceholderWithAttachment(brokered_attachment); |
+ attachment->PopulateWithAttachment(brokered_attachment.get()); |
} |
} |
#endif // USE_ATTACHMENT_BROKER |