/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
// The hard limit of handles or file descriptors allowed in a single message. static constexpr size_t MAX_DESCRIPTORS_PER_MESSAGE = 32767;
class HeaderFlags { friendclass Message; #ifdef FUZZING_SNAPSHOT // IPCFuzzController calls various private API functions on the header. friendclass mozilla::fuzzing::IPCFuzzController; #endif
// Helper method for the common case (default segmentCapacity, recording // the write latency of messages) of IPDL message creation. This helps // move the malloc and some of the parameter setting out of autogenerated // code. static mozilla::UniquePtr<Message> IPDLMessage(int32_t routing_id,
msgid_t type,
uint32_t segmentCapacity,
HeaderFlags flags);
// One-off constructors for special error-handling messages. static mozilla::UniquePtr<Message> ForSyncDispatchError(NestedLevel level);
// Write the given footer bytes to the end of the current message. The // footer's `data_len` will be padded to a multiple of 4 bytes. void WriteFooter(constvoid* data, uint32_t data_len); // Read a footer written with `WriteFooter` from the end of the message, given // a buffer and the length of the footer. If `truncate` is true, the message // will be truncated, removing the footer.
[[nodiscard]] bool ReadFooter(void* buffer, uint32_t buffer_len, bool truncate);
// Figure out how big the message starting at range_start is. Returns 0 if // there's no enough data to determine (i.e., if [range_start, range_end) does // not contain enough of the message header to know the size). static uint32_t MessageSize(constchar* range_start, constchar* range_end) { return Pickle::MessageSize(HeaderSize(), range_start, range_end);
}
// WARNING: This method is marked as `const` so it can be called when // deserializing the message, but will mutate it, consuming the handle. bool ConsumeFileHandle(PickleIterator* iter,
mozilla::UniqueFileHandle* handle) const;
// Called when receiving an IPC message to attach file handles which were // received from IPC. Must only be called when there are no handles on this // IPC::Message. void SetAttachedFileHandles(nsTArray<mozilla::UniqueFileHandle> handles);
// This method consumes the port from the message, preventing the message's // destructor from destroying the port and meaning that future attempts to // read this port will instead produce an invalid port. // // WARNING: This method is marked as `const` so it can be called when // deserializing the message, but will mutate the message. bool ConsumePort(PickleIterator* iter, mozilla::ipc::ScopedPort* port) const;
// Called when loading an IPC message to attach ports which were recieved form // IPC. Must only be called when there are no ports on this IPC::Message. void SetAttachedPorts(nsTArray<mozilla::ipc::ScopedPort> ports);
// WARNING: This method is marked as `const` so it can be called when // deserializing the message, but will mutate it, consuming the send rights. bool ConsumeMachSendRight(PickleIterator* iter,
mozilla::UniqueMachSendRight* port) const;
struct Header : Pickle::Header {
int32_t routing; // ID of the view that this message is destined for
msgid_t type; // specifies the user-defined message type
HeaderFlags flags; // specifies control flags for the message
uint32_t num_handles; // the number of handles included with this message #ifdefined(XP_DARWIN)
uint32_t cookie; // cookie to ACK that the descriptors have been read.
uint32_t num_send_rights; // the number of mach send rights included with // this message #endif // For sync messages, a transaction ID for message ordering.
int32_t txid; // Sequence number
int32_t seqno; // Size of the message's event footer
uint32_t event_footer_size;
};
// The set of file handles which are attached to this message. // // Mutable, as this array can be mutated during `ReadHandle` when // deserializing a message. mutable nsTArray<mozilla::UniqueFileHandle> attached_handles_;
// The set of mojo ports which are attached to this message. // // Mutable, as this array can be mutated during `ConsumePort` when // deserializing a message. mutable nsTArray<mozilla::ipc::ScopedPort> attached_ports_;
#ifdefined(XP_DARWIN) // The set of mach send rights which are attached to this message. // // Mutable, as this array can be mutated during `ConsumeMachSendRight` when // deserializing a message. mutable nsTArray<mozilla::UniqueMachSendRight> attached_send_rights_; #endif
// Total size of buffers which should have been sent in shared memory, but had // to fall back to being sent inline due to shmem allocation or mapping // failures.
uint32_t large_buffer_shmem_failure_size_ = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.