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

Side by Side Diff: ipc/ipc_message_attachment_set.cc

Issue 866223005: IPC: Add MojoHandleAttachment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing windows buld error Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_attachment_set.h" 5 #include "ipc/ipc_message_attachment_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/posix/eintr_wrapper.h" 9 #include "base/posix/eintr_wrapper.h"
10 #include "ipc/ipc_message_attachment.h" 10 #include "ipc/ipc_message_attachment.h"
(...skipping 27 matching lines...) Expand all
38 << consumed_descriptor_highwater_ << "/" << size(); 38 << consumed_descriptor_highwater_ << "/" << size();
39 } 39 }
40 40
41 unsigned MessageAttachmentSet::num_descriptors() const { 41 unsigned MessageAttachmentSet::num_descriptors() const {
42 return std::count_if(attachments_.begin(), attachments_.end(), 42 return std::count_if(attachments_.begin(), attachments_.end(),
43 [](scoped_refptr<MessageAttachment> i) { 43 [](scoped_refptr<MessageAttachment> i) {
44 return i->GetType() == MessageAttachment::TYPE_PLATFORM_FILE; 44 return i->GetType() == MessageAttachment::TYPE_PLATFORM_FILE;
45 }); 45 });
46 } 46 }
47 47
48 unsigned MessageAttachmentSet::num_mojo_handles() const {
49 return std::count_if(attachments_.begin(), attachments_.end(),
50 [](scoped_refptr<MessageAttachment> i) {
51 return i->GetType() == MessageAttachment::TYPE_MOJO_HANDLE;
52 });
53 }
54
48 unsigned MessageAttachmentSet::size() const { 55 unsigned MessageAttachmentSet::size() const {
49 return static_cast<unsigned>(attachments_.size()); 56 return static_cast<unsigned>(attachments_.size());
50 } 57 }
51 58
52 bool MessageAttachmentSet::AddAttachment( 59 bool MessageAttachmentSet::AddAttachment(
53 scoped_refptr<MessageAttachment> attachment) { 60 scoped_refptr<MessageAttachment> attachment) {
54 #if defined(OS_POSIX) 61 #if defined(OS_POSIX)
55 if (attachment->GetType() != MessageAttachment::TYPE_PLATFORM_FILE || 62 if (attachment->GetType() == MessageAttachment::TYPE_PLATFORM_FILE &&
56 num_descriptors() == kMaxDescriptorsPerMessage) { 63 num_descriptors() == kMaxDescriptorsPerMessage) {
57 DLOG(WARNING) << "Cannot add file descriptor. MessageAttachmentSet full."; 64 DLOG(WARNING) << "Cannot add file descriptor. MessageAttachmentSet full.";
58 return false; 65 return false;
59 } 66 }
60 #endif 67 #endif
61 68
62 attachments_.push_back(attachment); 69 attachments_.push_back(attachment);
63 return true; 70 return true;
64 } 71 }
65 72
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 for (unsigned i = 0; i < count; ++i) 154 for (unsigned i = 0; i < count; ++i)
148 AddAttachment( 155 AddAttachment(
149 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i]))); 156 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i])));
150 } 157 }
151 158
152 #endif // OS_POSIX 159 #endif // OS_POSIX
153 160
154 } // namespace IPC 161 } // namespace IPC
155 162
156 163
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698