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

Side by Side Diff: ipc/ipc_message.cc

Issue 1330563002: 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: Rebase and add missing ampersand. 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
49 #if defined(OS_POSIX) 52 #if defined(OS_POSIX)
50 header()->num_fds = 0; 53 header()->num_fds = 0;
51 header()->pad = 0; 54 header()->pad = 0;
52 #endif 55 #endif
53 Init(); 56 Init();
54 } 57 }
55 58
56 Message::Message(int32 routing_id, uint32 type, PriorityValue priority) 59 Message::Message(int32 routing_id, uint32 type, PriorityValue priority)
57 : base::Pickle(sizeof(Header)) { 60 : base::Pickle(sizeof(Header)) {
58 header()->routing = routing_id; 61 header()->routing = routing_id;
59 header()->type = type; 62 header()->type = type;
60 DCHECK((priority & 0xffffff00) == 0); 63 DCHECK((priority & 0xffffff00) == 0);
61 header()->flags = priority | GetRefNumUpper24(); 64 header()->flags = priority | GetRefNumUpper24();
65 #if USE_ATTACHMENT_BROKER
66 header()->num_brokered_attachments = 0;
67 #endif
62 #if defined(OS_POSIX) 68 #if defined(OS_POSIX)
63 header()->num_fds = 0; 69 header()->num_fds = 0;
64 header()->pad = 0; 70 header()->pad = 0;
65 #endif 71 #endif
66 Init(); 72 Init();
67 } 73 }
68 74
69 Message::Message(const char* data, int data_len) 75 Message::Message(const char* data, int data_len)
70 : base::Pickle(data, data_len) { 76 : base::Pickle(data, data_len) {
71 Init(); 77 Init();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 130
125 void Message::set_received_time(int64 time) const { 131 void Message::set_received_time(int64 time) const {
126 received_time_ = time; 132 received_time_ = time;
127 } 133 }
128 #endif 134 #endif
129 135
130 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { 136 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) {
131 // We write the index of the descriptor so that we don't have to 137 // We write the index of the descriptor so that we don't have to
132 // keep the current descriptor as extra decoding state when deserialising. 138 // keep the current descriptor as extra decoding state when deserialising.
133 WriteInt(attachment_set()->size()); 139 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
134 return attachment_set()->AddAttachment(attachment); 146 return attachment_set()->AddAttachment(attachment);
135 } 147 }
136 148
137 bool Message::ReadAttachment( 149 bool Message::ReadAttachment(
138 base::PickleIterator* iter, 150 base::PickleIterator* iter,
139 scoped_refptr<MessageAttachment>* attachment) const { 151 scoped_refptr<MessageAttachment>* attachment) const {
140 int descriptor_index; 152 int descriptor_index;
141 if (!iter->ReadInt(&descriptor_index)) 153 if (!iter->ReadInt(&descriptor_index))
142 return false; 154 return false;
143 155
(...skipping 12 matching lines...) Expand all
156 bool Message::HasMojoHandles() const { 168 bool Message::HasMojoHandles() const {
157 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; 169 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0;
158 } 170 }
159 171
160 bool Message::HasBrokerableAttachments() const { 172 bool Message::HasBrokerableAttachments() const {
161 return attachment_set_.get() && 173 return attachment_set_.get() &&
162 attachment_set_->num_brokerable_attachments() > 0; 174 attachment_set_->num_brokerable_attachments() > 0;
163 } 175 }
164 176
165 } // namespace IPC 177 } // 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