Bug 974410: Cleanup UnixSocketImpl, r=kyle

This patch cleans up the implementation of UnixSocketImpl by

 - inlining all calls to SetUpIO,
 - removing the unsued constant SOCKET_RETRY_TIME_MS, and
 - separating logging from Bluetooth.
This commit is contained in:
Thomas Zimmermann 2014-02-26 17:52:18 +01:00
parent 928bfd8605
commit ceb3f29bcc

View File

@ -28,14 +28,12 @@ static const size_t MAX_READ_SIZE = 1 << 16;
#undef CHROMIUM_LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GonkDBus", args);
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "I/O", args);
#else
#define BTDEBUG true
#define CHROMIUM_LOG(args...) if (BTDEBUG) printf(args);
#define IODEBUG true
#define CHROMIUM_LOG(args...) if (IODEBUG) printf(args);
#endif
static const int SOCKET_RETRY_TIME_MS = 1000;
namespace mozilla {
namespace ipc {
@ -94,15 +92,6 @@ public:
mShuttingDownOnIOThread = true;
}
void SetUpIO()
{
MOZ_ASSERT(IsOpen());
AddWatchers(READ_WATCHER, true);
if (!mOutgoingQ.IsEmpty()) {
AddWatchers(WRITE_WATCHER, false);
}
}
void SetDelayedConnectTask(CancelableTask* aTask)
{
MOZ_ASSERT(NS_IsMainThread());
@ -561,7 +550,10 @@ UnixSocketImpl::OnAccepted(int aFd)
new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS);
NS_DispatchToMainThread(t);
SetUpIO();
AddWatchers(READ_WATCHER, true);
if (!mOutgoingQ.IsEmpty()) {
AddWatchers(WRITE_WATCHER, false);
}
}
void
@ -586,7 +578,10 @@ UnixSocketImpl::OnConnected()
new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS);
NS_DispatchToMainThread(t);
SetUpIO();
AddWatchers(READ_WATCHER, true);
if (!mOutgoingQ.IsEmpty()) {
AddWatchers(WRITE_WATCHER, false);
}
}
void
@ -601,7 +596,7 @@ UnixSocketImpl::OnListening()
return;
}
SetUpIO();
AddWatchers(READ_WATCHER, true);
}
void