| OLD | NEW |
| 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/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) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 Message& Message::operator=(const Message& other) { | 62 Message& Message::operator=(const Message& other) { |
| 63 *static_cast<Pickle*>(this) = other; | 63 *static_cast<Pickle*>(this) = other; |
| 64 #if defined(OS_POSIX) | 64 #if defined(OS_POSIX) |
| 65 file_descriptor_set_ = other.file_descriptor_set_; | 65 file_descriptor_set_ = other.file_descriptor_set_; |
| 66 #endif | 66 #endif |
| 67 return *this; | 67 return *this; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void Message::SetHeaderValues(int32 routing, uint32 type, uint32 flags) { |
| 71 // This should only be called when the message is already empty. |
| 72 DCHECK(payload_size() == 0); |
| 73 |
| 74 header()->routing = routing; |
| 75 header()->type = type; |
| 76 header()->flags = flags; |
| 77 } |
| 78 |
| 70 #ifdef IPC_MESSAGE_LOG_ENABLED | 79 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 71 void Message::set_sent_time(int64 time) { | 80 void Message::set_sent_time(int64 time) { |
| 72 DCHECK((header()->flags & HAS_SENT_TIME_BIT) == 0); | 81 DCHECK((header()->flags & HAS_SENT_TIME_BIT) == 0); |
| 73 header()->flags |= HAS_SENT_TIME_BIT; | 82 header()->flags |= HAS_SENT_TIME_BIT; |
| 74 WriteInt64(time); | 83 WriteInt64(time); |
| 75 } | 84 } |
| 76 | 85 |
| 77 int64 Message::sent_time() const { | 86 int64 Message::sent_time() const { |
| 78 if ((header()->flags & HAS_SENT_TIME_BIT) == 0) | 87 if ((header()->flags & HAS_SENT_TIME_BIT) == 0) |
| 79 return 0; | 88 return 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 109 FileDescriptorSet* file_descriptor_set = file_descriptor_set_.get(); | 118 FileDescriptorSet* file_descriptor_set = file_descriptor_set_.get(); |
| 110 if (!file_descriptor_set) | 119 if (!file_descriptor_set) |
| 111 return false; | 120 return false; |
| 112 | 121 |
| 113 descriptor->fd = file_descriptor_set->GetDescriptorAt(descriptor_index); | 122 descriptor->fd = file_descriptor_set->GetDescriptorAt(descriptor_index); |
| 114 descriptor->auto_close = true; | 123 descriptor->auto_close = true; |
| 115 | 124 |
| 116 return descriptor->fd >= 0; | 125 return descriptor->fd >= 0; |
| 117 } | 126 } |
| 118 | 127 |
| 128 bool Message::HasFileDescriptors() const { |
| 129 return file_descriptor_set_.get() && !file_descriptor_set_->empty(); |
| 130 } |
| 131 |
| 119 void Message::EnsureFileDescriptorSet() { | 132 void Message::EnsureFileDescriptorSet() { |
| 120 if (file_descriptor_set_.get() == NULL) | 133 if (file_descriptor_set_.get() == NULL) |
| 121 file_descriptor_set_ = new FileDescriptorSet; | 134 file_descriptor_set_ = new FileDescriptorSet; |
| 122 } | 135 } |
| 123 | 136 |
| 124 #endif | 137 #endif |
| 125 | 138 |
| 126 } // namespace IPC | 139 } // namespace IPC |
| OLD | NEW |