diff --git a/mozilla/modules/ipc/common/ipcList.h b/mozilla/modules/ipc/common/ipcList.h index afd38ece455..e93838b424d 100644 --- a/mozilla/modules/ipc/common/ipcList.h +++ b/mozilla/modules/ipc/common/ipcList.h @@ -154,9 +154,12 @@ public: DeleteFirst(); } - T *First() { return mHead; } - T *Last() { return mTail; } - PRBool IsEmpty() { return mHead == NULL; } + const T *First() const { return mHead; } + T *First() { return mHead; } + const T *Last() const { return mTail; } + T *Last() { return mTail; } + + PRBool IsEmpty() const { return mHead == NULL; } protected: void AdvanceHead() diff --git a/mozilla/modules/ipc/daemon/ipcClient.h b/mozilla/modules/ipc/daemon/ipcClient.h index d144d019072..b51e42fa7f2 100644 --- a/mozilla/modules/ipc/daemon/ipcClient.h +++ b/mozilla/modules/ipc/daemon/ipcClient.h @@ -68,6 +68,10 @@ public: void DelTarget(const nsID &target); PRBool HasTarget(const nsID &target) const { return mTargets.Find(target) != NULL; } + // list iterators + const ipcStringNode *Names() const { return mNames.First(); } + const ipcIDNode *Targets() const { return mTargets.First(); } + // // returns TRUE if successfully enqueued. will return FALSE if client // does not have a registered message handler for this message's target. diff --git a/mozilla/modules/ipc/daemon/ipcd.cpp b/mozilla/modules/ipc/daemon/ipcd.cpp index 965a8a8e71f..ba04c513dff 100644 --- a/mozilla/modules/ipc/daemon/ipcd.cpp +++ b/mozilla/modules/ipc/daemon/ipcd.cpp @@ -413,6 +413,40 @@ ipcClient *IPC_GetClientByName(const char *name) return NULL; } +PRBool +IPC_ClientHasName(ipcClient *client, const char *name) +{ + return client->HasName(name); +} + +PRBool +IPC_ClientHasTarget(ipcClient *client, const nsID &target) +{ + return client->HasTarget(target); +} + +void +IPC_EnumerateClientNames(ipcClient *client, ipcClientNameEnumFunc func, void *closure) +{ + const ipcStringNode *node = client->Names(); + while (node) { + if (func(closure, client, node->Value()) == PR_FALSE) + break; + node = node->mNext; + } +} + +void +IPC_EnumerateClientTargets(ipcClient *client, ipcClientTargetEnumFunc func, void *closure) +{ + const ipcIDNode *node = client->Targets(); + while (node) { + if (func(closure, client, node->Value()) == PR_FALSE) + break; + node = node->mNext; + } +} + ipcClient *IPC_GetClients(int *count) { *count = poll_fd_count - 1; diff --git a/mozilla/modules/ipc/daemon/ipcd.h b/mozilla/modules/ipc/daemon/ipcd.h index b6008e1ca89..118f52adc8d 100644 --- a/mozilla/modules/ipc/daemon/ipcd.h +++ b/mozilla/modules/ipc/daemon/ipcd.h @@ -93,8 +93,22 @@ IPC_API const char *IPC_GetClientName(ipcClient *client); // // client lookup functions // -IPC_API ipcClient *IPC_GetClientByID(int clientID); -IPC_API ipcClient *IPC_GetClientByName(const char *clientName); +IPC_API ipcClient *IPC_GetClientByID(int id); +IPC_API ipcClient *IPC_GetClientByName(const char *name); + +// +// functions for inspecting the names and targets defined for a particular +// client instance. +// +IPC_API PRBool IPC_ClientHasName(ipcClient *client, const char *name); +IPC_API PRBool IPC_ClientHasTarget(ipcClient *client, const nsID &target); + +// return PR_FALSE to end enumeration +typedef PRBool (* ipcClientNameEnumFunc)(void *closure, ipcClient *client, const char *name); +typedef PRBool (* ipcClientTargetEnumFunc)(void *closure, ipcClient *client, const nsID &target); + +IPC_API void IPC_EnumerateClientNames(ipcClient *client, ipcClientNameEnumFunc func, void *closure); +IPC_API void IPC_EnumerateClientTargets(ipcClient *client, ipcClientTargetEnumFunc func, void *closure); // // return array of all clients, length equal to |count|.