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

Unified Diff: ipc/ipc_channel_reader.cc

Issue 1286253002: IPC: Add attachment brokering support to the message header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error. Created 5 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_channel_reader.h ('k') | ipc/ipc_channel_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_reader.cc
diff --git a/ipc/ipc_channel_reader.cc b/ipc/ipc_channel_reader.cc
index 30f03a1f2decbb2fd74b690baf5cc22eeb392ef5..b805f753a1a88857b6bfb9b7db578b5454b4729a 100644
--- a/ipc/ipc_channel_reader.cc
+++ b/ipc/ipc_channel_reader.cc
@@ -20,8 +20,7 @@ ChannelReader::ChannelReader(Listener* listener) : listener_(listener) {
}
ChannelReader::~ChannelReader() {
- if (!blocked_ids_.empty())
- StopObservingAttachmentBroker();
+ DCHECK(blocked_ids_.empty());
}
ChannelReader::DispatchState ChannelReader::ProcessIncomingMessages() {
@@ -85,11 +84,14 @@ bool ChannelReader::TranslateInputData(const char* input_data,
// Dispatch all complete messages in the data buffer.
while (p < end) {
- const char* message_tail = Message::FindNext(p, end);
- if (message_tail) {
- int len = static_cast<int>(message_tail - p);
+ 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);
- Message translated_message(p, len);
if (!GetNonBrokeredAttachments(&translated_message))
return false;
@@ -103,7 +105,7 @@ bool ChannelReader::TranslateInputData(const char* input_data,
if (blocked_ids.empty()) {
// Dispatch the message and continue the loop.
DispatchMessage(&translated_message);
- p = message_tail;
+ p = info.message_end;
continue;
}
@@ -114,7 +116,7 @@ bool ChannelReader::TranslateInputData(const char* input_data,
// 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 = message_tail;
+ p = info.message_end;
} else {
// Last message is partial.
break;
@@ -149,6 +151,13 @@ ChannelReader::DispatchState ChannelReader::DispatchMessages() {
return DISPATCH_FINISHED;
}
+void ChannelReader::CleanUp() {
+ if (!blocked_ids_.empty()) {
+ StopObservingAttachmentBroker();
+ blocked_ids_.clear();
+ }
+}
+
void ChannelReader::DispatchMessage(Message* m) {
m->set_sender_pid(GetSenderPID());
@@ -186,8 +195,9 @@ ChannelReader::AttachmentIdSet ChannelReader::GetBrokeredAttachments(
#if USE_ATTACHMENT_BROKER
MessageAttachmentSet* set = msg->attachment_set();
- for (const scoped_refptr<BrokerableAttachment>& attachment :
- set->GetBrokerableAttachmentsForUpdating()) {
+ std::vector<const BrokerableAttachment*> brokerable_attachments_copy =
+ set->PeekBrokerableAttachments();
+ for (const BrokerableAttachment* attachment : brokerable_attachments_copy) {
if (attachment->NeedsBrokering()) {
AttachmentBroker* broker = GetAttachmentBroker();
scoped_refptr<BrokerableAttachment> brokered_attachment;
@@ -198,7 +208,7 @@ ChannelReader::AttachmentIdSet ChannelReader::GetBrokeredAttachments(
continue;
}
- attachment->PopulateWithAttachment(brokered_attachment.get());
+ set->ReplacePlaceholderWithAttachment(brokered_attachment);
}
}
#endif // USE_ATTACHMENT_BROKER
« no previous file with comments | « ipc/ipc_channel_reader.h ('k') | ipc/ipc_channel_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698