| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| 11 #include "ipc/file_descriptor_set_posix.h" | 11 #include "ipc/file_descriptor_set_posix.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // We write the index of the descriptor so that we don't have to | 93 // We write the index of the descriptor so that we don't have to |
| 94 // keep the current descriptor as extra decoding state when deserialising. | 94 // keep the current descriptor as extra decoding state when deserialising. |
| 95 WriteInt(file_descriptor_set()->size()); | 95 WriteInt(file_descriptor_set()->size()); |
| 96 if (descriptor.auto_close) { | 96 if (descriptor.auto_close) { |
| 97 return file_descriptor_set()->AddAndAutoClose(descriptor.fd); | 97 return file_descriptor_set()->AddAndAutoClose(descriptor.fd); |
| 98 } else { | 98 } else { |
| 99 return file_descriptor_set()->Add(descriptor.fd); | 99 return file_descriptor_set()->Add(descriptor.fd); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool Message::ReadFileDescriptor(void** iter, | 103 bool Message::ReadFileDescriptor(PickleIterator* iter, |
| 104 base::FileDescriptor* descriptor) const { | 104 base::FileDescriptor* descriptor) const { |
| 105 int descriptor_index; | 105 int descriptor_index; |
| 106 if (!ReadInt(iter, &descriptor_index)) | 106 if (!ReadInt(iter, &descriptor_index)) |
| 107 return false; | 107 return false; |
| 108 | 108 |
| 109 FileDescriptorSet* file_descriptor_set = file_descriptor_set_.get(); | 109 FileDescriptorSet* file_descriptor_set = file_descriptor_set_.get(); |
| 110 if (!file_descriptor_set) | 110 if (!file_descriptor_set) |
| 111 return false; | 111 return false; |
| 112 | 112 |
| 113 descriptor->fd = file_descriptor_set->GetDescriptorAt(descriptor_index); | 113 descriptor->fd = file_descriptor_set->GetDescriptorAt(descriptor_index); |
| 114 descriptor->auto_close = true; | 114 descriptor->auto_close = true; |
| 115 | 115 |
| 116 return descriptor->fd >= 0; | 116 return descriptor->fd >= 0; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void Message::EnsureFileDescriptorSet() { | 119 void Message::EnsureFileDescriptorSet() { |
| 120 if (file_descriptor_set_.get() == NULL) | 120 if (file_descriptor_set_.get() == NULL) |
| 121 file_descriptor_set_ = new FileDescriptorSet; | 121 file_descriptor_set_ = new FileDescriptorSet; |
| 122 } | 122 } |
| 123 | 123 |
| 124 #endif | 124 #endif |
| 125 | 125 |
| 126 } // namespace IPC | 126 } // namespace IPC |
| OLD | NEW |