mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 545733: |const|-ify some *Channel methods. r=bent
This commit is contained in:
parent
5d668bd37a
commit
a2d53e0f5e
@ -268,14 +268,14 @@ AsyncChannel::OnSpecialMessage(uint16 id, const Message& msg)
|
||||
}
|
||||
|
||||
void
|
||||
AsyncChannel::SendSpecialMessage(Message* msg)
|
||||
AsyncChannel::SendSpecialMessage(Message* msg) const
|
||||
{
|
||||
AssertWorkerThread();
|
||||
SendThroughTransport(msg);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncChannel::SendThroughTransport(Message* msg)
|
||||
AsyncChannel::SendThroughTransport(Message* msg) const
|
||||
{
|
||||
AssertWorkerThread();
|
||||
|
||||
@ -401,7 +401,7 @@ AsyncChannel::MaybeHandleError(Result code, const char* channelName)
|
||||
}
|
||||
|
||||
void
|
||||
AsyncChannel::ReportConnectionError(const char* channelName)
|
||||
AsyncChannel::ReportConnectionError(const char* channelName) const
|
||||
{
|
||||
const char* errorMsg;
|
||||
switch (mChannelState) {
|
||||
|
@ -125,19 +125,19 @@ public:
|
||||
|
||||
protected:
|
||||
// Can be run on either thread
|
||||
void AssertWorkerThread()
|
||||
void AssertWorkerThread() const
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mWorkerLoop == MessageLoop::current(),
|
||||
"not on worker thread!");
|
||||
}
|
||||
|
||||
void AssertIOThread()
|
||||
void AssertIOThread() const
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mIOLoop == MessageLoop::current(),
|
||||
"not on IO thread!");
|
||||
}
|
||||
|
||||
bool Connected() {
|
||||
bool Connected() const {
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
return ChannelConnected == mChannelState;
|
||||
}
|
||||
@ -145,15 +145,15 @@ protected:
|
||||
// Run on the worker thread
|
||||
void OnDispatchMessage(const Message& aMsg);
|
||||
virtual bool OnSpecialMessage(uint16 id, const Message& msg);
|
||||
void SendSpecialMessage(Message* msg);
|
||||
void SendSpecialMessage(Message* msg) const;
|
||||
|
||||
// Tell the IO thread to close the channel and wait for it to ACK.
|
||||
void SynchronouslyClose();
|
||||
|
||||
bool MaybeHandleError(Result code, const char* channelName);
|
||||
void ReportConnectionError(const char* channelName);
|
||||
void ReportConnectionError(const char* channelName) const;
|
||||
|
||||
void PrintErrorMessage(const char* channelName, const char* msg)
|
||||
void PrintErrorMessage(const char* channelName, const char* msg) const
|
||||
{
|
||||
fprintf(stderr, "\n###!!! [%s][%s] Error: %s\n\n",
|
||||
mChild ? "Child" : "Parent", channelName, msg);
|
||||
@ -161,10 +161,10 @@ protected:
|
||||
|
||||
// Run on the worker thread
|
||||
|
||||
void SendThroughTransport(Message* msg);
|
||||
void SendThroughTransport(Message* msg) const;
|
||||
|
||||
void OnNotifyMaybeChannelError();
|
||||
virtual bool ShouldDeferNotifyMaybeError() {
|
||||
virtual bool ShouldDeferNotifyMaybeError() const {
|
||||
return false;
|
||||
}
|
||||
void NotifyChannelClosed();
|
||||
|
@ -127,7 +127,7 @@ int RPCChannel::sModalEventCount = 0;
|
||||
#endif
|
||||
|
||||
bool
|
||||
RPCChannel::EventOccurred()
|
||||
RPCChannel::EventOccurred() const
|
||||
{
|
||||
AssertWorkerThread();
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
@ -618,7 +618,7 @@ RPCChannel::ExitedCxxStack()
|
||||
void
|
||||
RPCChannel::DebugAbort(const char* file, int line, const char* cond,
|
||||
const char* why,
|
||||
const char* type, bool reply)
|
||||
const char* type, bool reply) const
|
||||
{
|
||||
fprintf(stderr,
|
||||
"###!!! [RPCChannel][%s][%s:%d] "
|
||||
@ -637,19 +637,21 @@ RPCChannel::DebugAbort(const char* file, int line, const char* cond,
|
||||
mOutOfTurnReplies.size());
|
||||
fprintf(stderr, " Pending queue size: %lu, front to back:\n",
|
||||
mPending.size());
|
||||
while (!mPending.empty()) {
|
||||
|
||||
MessageQueue pending = mPending;
|
||||
while (!pending.empty()) {
|
||||
fprintf(stderr, " [ %s%s ]\n",
|
||||
mPending.front().is_rpc() ? "rpc" :
|
||||
(mPending.front().is_sync() ? "sync" : "async"),
|
||||
mPending.front().is_reply() ? "reply" : "");
|
||||
mPending.pop();
|
||||
pending.front().is_rpc() ? "rpc" :
|
||||
(pending.front().is_sync() ? "sync" : "async"),
|
||||
pending.front().is_reply() ? "reply" : "");
|
||||
pending.pop();
|
||||
}
|
||||
|
||||
NS_RUNTIMEABORT(why);
|
||||
}
|
||||
|
||||
void
|
||||
RPCChannel::DumpRPCStack(FILE* outfile, const char* const pfx)
|
||||
RPCChannel::DumpRPCStack(FILE* outfile, const char* const pfx) const
|
||||
{
|
||||
NS_WARN_IF_FALSE(MessageLoop::current() != mWorkerLoop,
|
||||
"The worker thread had better be paused in a debugger!");
|
||||
|
@ -196,11 +196,11 @@ protected:
|
||||
}
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool ShouldDeferNotifyMaybeError() {
|
||||
virtual bool ShouldDeferNotifyMaybeError() const {
|
||||
return IsOnCxxStack();
|
||||
}
|
||||
|
||||
bool EventOccurred();
|
||||
bool EventOccurred() const;
|
||||
|
||||
void MaybeProcessDeferredIncall();
|
||||
void EnqueuePendingMessages();
|
||||
@ -230,8 +230,7 @@ protected:
|
||||
{ }
|
||||
|
||||
void Describe(int32* id, const char** dir, const char** sems,
|
||||
const char** name)
|
||||
const
|
||||
const char** name) const
|
||||
{
|
||||
*id = mMsg->routing_id();
|
||||
*dir = (IN_MESSAGE == mDirection) ? "in" : "out";
|
||||
@ -282,18 +281,18 @@ protected:
|
||||
};
|
||||
|
||||
// Called from both threads
|
||||
size_t StackDepth() {
|
||||
size_t StackDepth() const {
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
return mStack.size();
|
||||
}
|
||||
|
||||
void DebugAbort(const char* file, int line, const char* cond,
|
||||
const char* why,
|
||||
const char* type="rpc", bool reply=false);
|
||||
const char* type="rpc", bool reply=false) const;
|
||||
|
||||
// This method is only safe to call on the worker thread, or in a
|
||||
// debugger with all threads paused. |outfile| defaults to stdout.
|
||||
void DumpRPCStack(FILE* outfile=NULL, const char* const pfx="");
|
||||
void DumpRPCStack(FILE* outfile=NULL, const char* const pfx="") const;
|
||||
|
||||
//
|
||||
// Queue of all incoming messages, except for replies to sync
|
||||
@ -334,8 +333,9 @@ protected:
|
||||
// one RPC call on our stack, the other side *better* not have
|
||||
// sent us another blocking message, because it's blocked on a
|
||||
// reply from us.
|
||||
//
|
||||
std::queue<Message> mPending;
|
||||
//
|
||||
typedef std::queue<Message> MessageQueue;
|
||||
MessageQueue mPending;
|
||||
|
||||
//
|
||||
// Stack of all the RPC out-calls on which this RPCChannel is
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
|
||||
protected:
|
||||
// Executed on the worker thread
|
||||
bool ProcessingSyncMessage() {
|
||||
bool ProcessingSyncMessage() const {
|
||||
return mProcessingSyncMessage;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ protected:
|
||||
void NotifyWorkerThread();
|
||||
|
||||
// On both
|
||||
bool AwaitingSyncReply() {
|
||||
bool AwaitingSyncReply() const {
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
return mPendingReply != 0;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
* AssertCurrentThreadOwns
|
||||
* @see prlock.h
|
||||
**/
|
||||
void AssertCurrentThreadOwns ()
|
||||
void AssertCurrentThreadOwns () const
|
||||
{
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public:
|
||||
* AssertNotCurrentThreadOwns
|
||||
* @see prlock.h
|
||||
**/
|
||||
void AssertNotCurrentThreadOwns ()
|
||||
void AssertNotCurrentThreadOwns () const
|
||||
{
|
||||
}
|
||||
|
||||
@ -133,12 +133,12 @@ public:
|
||||
void Lock();
|
||||
void Unlock();
|
||||
|
||||
void AssertCurrentThreadOwns ()
|
||||
void AssertCurrentThreadOwns () const
|
||||
{
|
||||
PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(mLock);
|
||||
}
|
||||
|
||||
void AssertNotCurrentThreadOwns ()
|
||||
void AssertNotCurrentThreadOwns () const
|
||||
{
|
||||
// FIXME bug 476536
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user