Revert of IPC: Add attachment brokering support to the message header. (patchset #3 id:40001 of https://codereview.chromium.org/1303103002/ )

Reason for revert:
Reverting on suspicion of causing crashes in Canary.

https://code.google.com/p/chromium/issues/detail?id=524032

Original issue's description:
> Reland #1: IPC: Add attachment brokering support to the message header.
>
> This reland fixes a race condition in the unit test SendHandleTwice that caused
> the test to flakily fail, mostly on XP machines. This reland also updates switch
> statements to contain a block for the newly added enum
> BrokerableAttachment::PLACEHOLDER, which was causing problems with the clang
> Windows build.
>
> > Message dispatch happens before message translation, and message dispatch
> > requires that all brokered attachments have been received. This means that
> > attachment brokering needs to function without message translation. This is
> > accomplished by modifying the message header to include a new field
> > num_brokered_attachments, and writing the attachment ids into the IPC Channel
> > immediately following the pickled message itself.
> >
> > AttachmentBrokerPrivilegedWinUnittest was expanded to test ChannelReader in the
> > receiving process. It is now a fully functional end-to-end test of attachment
> > brokering.
> >
> > BUG=493414
>
> [email protected]
> BUG=493414
>
> Committed: https://crrev.com/37a2e0b682555bf35852d707dbd74b68f345841f
> Cr-Commit-Position: refs/heads/master@{#344933}

TBR=
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=493414

Review URL: https://codereview.chromium.org/1312433009

Cr-Commit-Position: refs/heads/master@{#345960}
diff --git a/ipc/brokerable_attachment.cc b/ipc/brokerable_attachment.cc
index 4a1becc..f1cc9b2 100644
--- a/ipc/brokerable_attachment.cc
+++ b/ipc/brokerable_attachment.cc
@@ -4,65 +4,47 @@
 
 #include "ipc/brokerable_attachment.h"
 
-#include "ipc/attachment_broker.h"
-
-#if USE_ATTACHMENT_BROKER
 #include "crypto/random.h"
-#endif
 
 namespace IPC {
 
-#if USE_ATTACHMENT_BROKER
-BrokerableAttachment::AttachmentId::AttachmentId() {
-  // In order to prevent mutually untrusted processes from stealing resources
-  // from one another, the nonce must be secret. This generates a 128-bit,
-  // cryptographicaly-strong random number.
-  crypto::RandBytes(nonce, BrokerableAttachment::kNonceSize);
-}
-#else
-BrokerableAttachment::AttachmentId::AttachmentId() {
-  CHECK(false) << "Not allowed to construct an attachment id if the platform "
-                  "does not support attachment brokering.";
-}
-#endif
+namespace {
 
-BrokerableAttachment::AttachmentId::AttachmentId(const char* start_address,
-                                                 size_t size) {
-  DCHECK(size == BrokerableAttachment::kNonceSize);
-  for (size_t i = 0; i < BrokerableAttachment::kNonceSize; ++i)
-    nonce[i] = start_address[i];
+// In order to prevent mutually untrusted processes from stealing resources from
+// one another, the nonce must be secret. This generates a 128-bit,
+// cryptographicaly-strong random number.
+BrokerableAttachment::AttachmentId GetRandomId() {
+  BrokerableAttachment::AttachmentId id;
+  crypto::RandBytes(id.nonce, BrokerableAttachment::kNonceSize);
+  return id;
 }
 
-void BrokerableAttachment::AttachmentId::SerializeToBuffer(char* start_address,
-                                                           size_t size) {
-  DCHECK(size == BrokerableAttachment::kNonceSize);
-  for (size_t i = 0; i < BrokerableAttachment::kNonceSize; ++i)
-    start_address[i] = nonce[i];
+}  // namespace
+
+BrokerableAttachment::BrokerableAttachment()
+    : id_(GetRandomId()), needs_brokering_(false) {}
+
+BrokerableAttachment::BrokerableAttachment(const AttachmentId& id,
+                                           bool needs_brokering)
+    : id_(id), needs_brokering_(needs_brokering) {}
+
+BrokerableAttachment::~BrokerableAttachment() {
 }
 
-BrokerableAttachment::BrokerableAttachment() {}
-
-BrokerableAttachment::BrokerableAttachment(const AttachmentId& id) : id_(id) {}
-
-BrokerableAttachment::~BrokerableAttachment() {}
-
 BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const {
   return id_;
 }
 
 bool BrokerableAttachment::NeedsBrokering() const {
-  return GetBrokerableType() == PLACEHOLDER;
+  return needs_brokering_;
+}
+
+void BrokerableAttachment::SetNeedsBrokering(bool needs_brokering) {
+  needs_brokering_ = needs_brokering;
 }
 
 BrokerableAttachment::Type BrokerableAttachment::GetType() const {
   return TYPE_BROKERABLE_ATTACHMENT;
 }
 
-#if defined(OS_POSIX)
-base::PlatformFile BrokerableAttachment::TakePlatformFile() {
-  NOTREACHED();
-  return base::PlatformFile();
-}
-#endif  // OS_POSIX
-
 }  // namespace IPC