mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
mac: Add NotifyServer::DefaultInterface, a default no-op implementation
Each routine in this implementation returns MIG_BAD_ID. These routines may be overridden. Most things that implement NotifyServer::Interface will only need to implement one of the interface routines. Since another user of NotifyServer will be added soon, it makes sense to provide a default no-op implementation rather than forcing everyone to write the same no-op boilerplate repeatedly. R=rsesek@chromium.org Review URL: https://codereview.chromium.org/1414413006 .
This commit is contained in:
parent
7858145558
commit
c1b841442f
@ -27,13 +27,13 @@ namespace crashpad {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class ExceptionHandlerServerRun : public UniversalMachExcServer::Interface,
|
class ExceptionHandlerServerRun : public UniversalMachExcServer::Interface,
|
||||||
public NotifyServer::Interface {
|
public NotifyServer::DefaultInterface {
|
||||||
public:
|
public:
|
||||||
ExceptionHandlerServerRun(
|
ExceptionHandlerServerRun(
|
||||||
mach_port_t exception_port,
|
mach_port_t exception_port,
|
||||||
UniversalMachExcServer::Interface* exception_interface)
|
UniversalMachExcServer::Interface* exception_interface)
|
||||||
: UniversalMachExcServer::Interface(),
|
: UniversalMachExcServer::Interface(),
|
||||||
NotifyServer::Interface(),
|
NotifyServer::DefaultInterface(),
|
||||||
mach_exc_server_(this),
|
mach_exc_server_(this),
|
||||||
notify_server_(this),
|
notify_server_(this),
|
||||||
composite_mach_message_server_(),
|
composite_mach_message_server_(),
|
||||||
@ -144,22 +144,7 @@ class ExceptionHandlerServerRun : public UniversalMachExcServer::Interface,
|
|||||||
destroy_complex_request);
|
destroy_complex_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyServer::Interface:
|
// NotifyServer::DefaultInterface:
|
||||||
|
|
||||||
kern_return_t DoMachNotifyPortDeleted(
|
|
||||||
notify_port_t notify,
|
|
||||||
mach_port_name_t name,
|
|
||||||
const mach_msg_trailer_t* trailer) override {
|
|
||||||
return UnimplementedNotifyRoutine(notify);
|
|
||||||
}
|
|
||||||
|
|
||||||
kern_return_t DoMachNotifyPortDestroyed(notify_port_t notify,
|
|
||||||
mach_port_t rights,
|
|
||||||
const mach_msg_trailer_t* trailer,
|
|
||||||
bool* destroy_request) override {
|
|
||||||
*destroy_request = true;
|
|
||||||
return UnimplementedNotifyRoutine(notify);
|
|
||||||
}
|
|
||||||
|
|
||||||
kern_return_t DoMachNotifyNoSenders(
|
kern_return_t DoMachNotifyNoSenders(
|
||||||
notify_port_t notify,
|
notify_port_t notify,
|
||||||
@ -180,32 +165,7 @@ class ExceptionHandlerServerRun : public UniversalMachExcServer::Interface,
|
|||||||
return KERN_SUCCESS;
|
return KERN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
kern_return_t DoMachNotifySendOnce(
|
|
||||||
notify_port_t notify,
|
|
||||||
const mach_msg_trailer_t* trailer) override {
|
|
||||||
return UnimplementedNotifyRoutine(notify);
|
|
||||||
}
|
|
||||||
|
|
||||||
kern_return_t DoMachNotifyDeadName(
|
|
||||||
notify_port_t notify,
|
|
||||||
mach_port_name_t name,
|
|
||||||
const mach_msg_trailer_t* trailer) override {
|
|
||||||
return UnimplementedNotifyRoutine(notify);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
kern_return_t UnimplementedNotifyRoutine(notify_port_t notify) {
|
|
||||||
// Most of the routines in the notify subsystem are not expected to be
|
|
||||||
// called.
|
|
||||||
if (notify != notify_port_) {
|
|
||||||
LOG(WARNING) << "notify port mismatch";
|
|
||||||
return KERN_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NOTREACHED();
|
|
||||||
return MIG_BAD_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
UniversalMachExcServer mach_exc_server_;
|
UniversalMachExcServer mach_exc_server_;
|
||||||
NotifyServer notify_server_;
|
NotifyServer notify_server_;
|
||||||
CompositeMachMessageServer composite_mach_message_server_;
|
CompositeMachMessageServer composite_mach_message_server_;
|
||||||
|
@ -105,6 +105,42 @@ kern_return_t MIGCheckRequestMachNotifyDeadName(
|
|||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
|
kern_return_t NotifyServer::DefaultInterface::DoMachNotifyPortDeleted(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_name_t name,
|
||||||
|
const mach_msg_trailer_t* trailer) {
|
||||||
|
return MIG_BAD_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_return_t NotifyServer::DefaultInterface::DoMachNotifyPortDestroyed(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_t rights,
|
||||||
|
const mach_msg_trailer_t* trailer,
|
||||||
|
bool* destroy_request) {
|
||||||
|
*destroy_request = true;
|
||||||
|
return MIG_BAD_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_return_t NotifyServer::DefaultInterface::DoMachNotifyNoSenders(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_mscount_t mscount,
|
||||||
|
const mach_msg_trailer_t* trailer) {
|
||||||
|
return MIG_BAD_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_return_t NotifyServer::DefaultInterface::DoMachNotifySendOnce(
|
||||||
|
notify_port_t notify,
|
||||||
|
const mach_msg_trailer_t* trailer) {
|
||||||
|
return MIG_BAD_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_return_t NotifyServer::DefaultInterface::DoMachNotifyDeadName(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_name_t name,
|
||||||
|
const mach_msg_trailer_t* trailer) {
|
||||||
|
return MIG_BAD_ID;
|
||||||
|
}
|
||||||
|
|
||||||
NotifyServer::NotifyServer(NotifyServer::Interface* interface)
|
NotifyServer::NotifyServer(NotifyServer::Interface* interface)
|
||||||
: MachMessageServer::Interface(),
|
: MachMessageServer::Interface(),
|
||||||
interface_(interface) {
|
interface_(interface) {
|
||||||
|
@ -37,6 +37,9 @@ class NotifyServer : public MachMessageServer::Interface {
|
|||||||
public:
|
public:
|
||||||
//! \brief An interface that the different request messages that are a part of
|
//! \brief An interface that the different request messages that are a part of
|
||||||
//! the `notify` Mach subsystem can be dispatched to.
|
//! the `notify` Mach subsystem can be dispatched to.
|
||||||
|
//!
|
||||||
|
//! Default implementations of all methods are available in the
|
||||||
|
//! DefaultInterface class.
|
||||||
class Interface {
|
class Interface {
|
||||||
public:
|
public:
|
||||||
//! \brief Handles port-deleted notifications sent by
|
//! \brief Handles port-deleted notifications sent by
|
||||||
@ -166,6 +169,52 @@ class NotifyServer : public MachMessageServer::Interface {
|
|||||||
~Interface() {}
|
~Interface() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! \brief A concrete implementation of Interface that provides a default
|
||||||
|
//! behavior for all `notify` routines.
|
||||||
|
//!
|
||||||
|
//! The Mach `notify` subsystem contains a collection of unrelated routines,
|
||||||
|
//! and a single server would rarely need to implement all of them. To make it
|
||||||
|
//! easier to use NotifyServer, a server can inherit from DefaultInterface
|
||||||
|
//! instead of Interface. Unless overridden, each routine in DefaultInterface
|
||||||
|
//! returns `MIG_BAD_ID` to indicate to the caller that the `notify` message
|
||||||
|
//! was unexpected and not processed.
|
||||||
|
class DefaultInterface : public Interface {
|
||||||
|
public:
|
||||||
|
// Interface:
|
||||||
|
|
||||||
|
kern_return_t DoMachNotifyPortDeleted(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_name_t name,
|
||||||
|
const mach_msg_trailer_t* trailer) override;
|
||||||
|
|
||||||
|
kern_return_t DoMachNotifyPortDestroyed(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_t rights,
|
||||||
|
const mach_msg_trailer_t* trailer,
|
||||||
|
bool* destroy_request) override;
|
||||||
|
|
||||||
|
kern_return_t DoMachNotifyNoSenders(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_mscount_t mscount,
|
||||||
|
const mach_msg_trailer_t* trailer) override;
|
||||||
|
|
||||||
|
kern_return_t DoMachNotifySendOnce(
|
||||||
|
notify_port_t notify,
|
||||||
|
const mach_msg_trailer_t* trailer) override;
|
||||||
|
|
||||||
|
kern_return_t DoMachNotifyDeadName(
|
||||||
|
notify_port_t notify,
|
||||||
|
mach_port_name_t name,
|
||||||
|
const mach_msg_trailer_t* trailer) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DefaultInterface() : Interface() {}
|
||||||
|
~DefaultInterface() {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(DefaultInterface);
|
||||||
|
};
|
||||||
|
|
||||||
//! \brief Constructs an object of this class.
|
//! \brief Constructs an object of this class.
|
||||||
//!
|
//!
|
||||||
//! \param[in] interface The interface to dispatch requests to. Weak.
|
//! \param[in] interface The interface to dispatch requests to. Weak.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user