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

Unified Diff: ipc/ipc_message.cc

Issue 1286883003: Revert of IPC: Add attachment brokering support to the message header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_message.h ('k') | ipc/ipc_message_attachment_set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message.cc
diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc
index 6b55d277a8441a7c528cf021514faab40bc119d8..07d5d254759a23d208829d86d924c5e207a56ce3 100644
--- a/ipc/ipc_message.cc
+++ b/ipc/ipc_message.cc
@@ -9,7 +9,6 @@
#include "build/build_config.h"
#include "ipc/ipc_message_attachment.h"
#include "ipc/ipc_message_attachment_set.h"
-#include "ipc/placeholder_brokerable_attachment.h"
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
@@ -47,9 +46,6 @@
Message::Message() : base::Pickle(sizeof(Header)) {
header()->routing = header()->type = 0;
header()->flags = GetRefNumUpper24();
-#if USE_ATTACHMENT_BROKER
- header()->num_brokered_attachments = 0;
-#endif
#if defined(OS_POSIX)
header()->num_fds = 0;
header()->pad = 0;
@@ -63,9 +59,6 @@
header()->type = type;
DCHECK((priority & 0xffffff00) == 0);
header()->flags = priority | GetRefNumUpper24();
-#if USE_ATTACHMENT_BROKER
- header()->num_brokered_attachments = 0;
-#endif
#if defined(OS_POSIX)
header()->num_fds = 0;
header()->pad = 0;
@@ -134,91 +127,10 @@
}
#endif
-Message::NextMessageInfo::NextMessageInfo()
- : message_found(false), pickle_end(nullptr), message_end(nullptr) {}
-Message::NextMessageInfo::~NextMessageInfo() {}
-
-// static
-Message::NextMessageInfo Message::FindNext(const char* range_start,
- const char* range_end) {
- NextMessageInfo info;
- const char* pickle_end =
- base::Pickle::FindNext(sizeof(Header), range_start, range_end);
- if (pickle_end == nullptr)
- return info;
- info.pickle_end = pickle_end;
-
-#if USE_ATTACHMENT_BROKER
- // The data is not copied.
- size_t pickle_len = static_cast<size_t>(pickle_end - range_start);
- Message message(range_start, static_cast<int>(pickle_len));
- int num_attachments = message.header()->num_brokered_attachments;
-
- // Each brokered attachment adds kNonceSize bytes of data to the message. We
- // want to avoid overflows in our computations, so we limit the number of
- // brokerable attachments to 100.
- if (num_attachments > 100)
- return info;
-
- // Check whether the range includes the attachments.
- size_t attachment_length = num_attachments * BrokerableAttachment::kNonceSize;
- size_t buffer_length = static_cast<size_t>(range_end - range_start);
- if (buffer_length < attachment_length + pickle_len)
- return info;
-
- for (int i = 0; i < num_attachments; ++i) {
- const char* attachment_start =
- pickle_end + i * (BrokerableAttachment::kNonceSize);
- BrokerableAttachment::AttachmentId id(attachment_start,
- BrokerableAttachment::kNonceSize);
- info.attachment_ids.push_back(id);
- }
- info.message_end =
- pickle_end + num_attachments * BrokerableAttachment::kNonceSize;
-#else
- info.message_end = pickle_end;
-#endif // USE_ATTACHMENT_BROKER
-
- info.message_found = true;
- return info;
-}
-
-Message::SerializedAttachmentIds
-Message::SerializedIdsOfBrokerableAttachments() {
- DCHECK(HasBrokerableAttachments());
- std::vector<const BrokerableAttachment*> attachments =
- attachment_set_->PeekBrokerableAttachments();
- size_t size = attachments.size() * BrokerableAttachment::kNonceSize;
- char* buffer = static_cast<char*>(malloc(size));
- for (size_t i = 0; i < attachments.size(); ++i) {
- const BrokerableAttachment* attachment = attachments[i];
- char* start_range = buffer + i * BrokerableAttachment::kNonceSize;
- BrokerableAttachment::AttachmentId id = attachment->GetIdentifier();
- id.SerializeToBuffer(start_range, BrokerableAttachment::kNonceSize);
- }
- SerializedAttachmentIds ids;
- ids.buffer = buffer;
- ids.size = size;
- return ids;
-}
-
-bool Message::AddPlaceholderBrokerableAttachmentWithId(
- BrokerableAttachment::AttachmentId id) {
- scoped_refptr<PlaceholderBrokerableAttachment> attachment(
- new PlaceholderBrokerableAttachment(id));
- return attachment_set()->AddAttachment(attachment);
-}
-
bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) {
// We write the index of the descriptor so that we don't have to
// keep the current descriptor as extra decoding state when deserialising.
WriteInt(attachment_set()->size());
-
-#if USE_ATTACHMENT_BROKER
- if (attachment->GetType() == MessageAttachment::TYPE_BROKERABLE_ATTACHMENT)
- header()->num_brokered_attachments += 1;
-#endif
-
return attachment_set()->AddAttachment(attachment);
}
« no previous file with comments | « ipc/ipc_message.h ('k') | ipc/ipc_message_attachment_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698