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

Side by Side Diff: ipc/ipc_message.cc

Issue 1314803005: Revert of Reland #1 "ipc: Add a new field num_brokered_attachments to the message header." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « ipc/ipc_message.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ipc/ipc_message.h" 5 #include "ipc/ipc_message.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ipc/ipc_message_attachment.h" 10 #include "ipc/ipc_message_attachment.h"
(...skipping 28 matching lines...) Expand all
39 namespace IPC { 39 namespace IPC {
40 40
41 //------------------------------------------------------------------------------ 41 //------------------------------------------------------------------------------
42 42
43 Message::~Message() { 43 Message::~Message() {
44 } 44 }
45 45
46 Message::Message() : base::Pickle(sizeof(Header)) { 46 Message::Message() : base::Pickle(sizeof(Header)) {
47 header()->routing = header()->type = 0; 47 header()->routing = header()->type = 0;
48 header()->flags = GetRefNumUpper24(); 48 header()->flags = GetRefNumUpper24();
49 #if USE_ATTACHMENT_BROKER
50 header()->num_brokered_attachments = 0;
51 #endif
52 #if defined(OS_POSIX) 49 #if defined(OS_POSIX)
53 header()->num_fds = 0; 50 header()->num_fds = 0;
54 header()->pad = 0; 51 header()->pad = 0;
55 #endif 52 #endif
56 Init(); 53 Init();
57 } 54 }
58 55
59 Message::Message(int32 routing_id, uint32 type, PriorityValue priority) 56 Message::Message(int32 routing_id, uint32 type, PriorityValue priority)
60 : base::Pickle(sizeof(Header)) { 57 : base::Pickle(sizeof(Header)) {
61 header()->routing = routing_id; 58 header()->routing = routing_id;
62 header()->type = type; 59 header()->type = type;
63 DCHECK((priority & 0xffffff00) == 0); 60 DCHECK((priority & 0xffffff00) == 0);
64 header()->flags = priority | GetRefNumUpper24(); 61 header()->flags = priority | GetRefNumUpper24();
65 #if USE_ATTACHMENT_BROKER
66 header()->num_brokered_attachments = 0;
67 #endif
68 #if defined(OS_POSIX) 62 #if defined(OS_POSIX)
69 header()->num_fds = 0; 63 header()->num_fds = 0;
70 header()->pad = 0; 64 header()->pad = 0;
71 #endif 65 #endif
72 Init(); 66 Init();
73 } 67 }
74 68
75 Message::Message(const char* data, int data_len) 69 Message::Message(const char* data, int data_len)
76 : base::Pickle(data, data_len) { 70 : base::Pickle(data, data_len) {
77 Init(); 71 Init();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 124
131 void Message::set_received_time(int64 time) const { 125 void Message::set_received_time(int64 time) const {
132 received_time_ = time; 126 received_time_ = time;
133 } 127 }
134 #endif 128 #endif
135 129
136 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { 130 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) {
137 // We write the index of the descriptor so that we don't have to 131 // We write the index of the descriptor so that we don't have to
138 // keep the current descriptor as extra decoding state when deserialising. 132 // keep the current descriptor as extra decoding state when deserialising.
139 WriteInt(attachment_set()->size()); 133 WriteInt(attachment_set()->size());
140
141 #if USE_ATTACHMENT_BROKER
142 if (attachment->GetType() == MessageAttachment::TYPE_BROKERABLE_ATTACHMENT)
143 header()->num_brokered_attachments += 1;
144 #endif
145
146 return attachment_set()->AddAttachment(attachment); 134 return attachment_set()->AddAttachment(attachment);
147 } 135 }
148 136
149 bool Message::ReadAttachment( 137 bool Message::ReadAttachment(
150 base::PickleIterator* iter, 138 base::PickleIterator* iter,
151 scoped_refptr<MessageAttachment>* attachment) const { 139 scoped_refptr<MessageAttachment>* attachment) const {
152 int descriptor_index; 140 int descriptor_index;
153 if (!iter->ReadInt(&descriptor_index)) 141 if (!iter->ReadInt(&descriptor_index))
154 return false; 142 return false;
155 143
(...skipping 12 matching lines...) Expand all
168 bool Message::HasMojoHandles() const { 156 bool Message::HasMojoHandles() const {
169 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; 157 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0;
170 } 158 }
171 159
172 bool Message::HasBrokerableAttachments() const { 160 bool Message::HasBrokerableAttachments() const {
173 return attachment_set_.get() && 161 return attachment_set_.get() &&
174 attachment_set_->num_brokerable_attachments() > 0; 162 attachment_set_->num_brokerable_attachments() > 0;
175 } 163 }
176 164
177 } // namespace IPC 165 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_message.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698