diff --git a/ipc/chromium/src/base/message_loop.h b/ipc/chromium/src/base/message_loop.h index 33016a3d1952..41c86ac54063 100644 --- a/ipc/chromium/src/base/message_loop.h +++ b/ipc/chromium/src/base/message_loop.h @@ -531,7 +531,6 @@ class MessageLoopForIO : public MessageLoop { typedef base::MessagePumpLibevent::Watcher Watcher; typedef base::MessagePumpLibevent::FileDescriptorWatcher FileDescriptorWatcher; - typedef base::LineWatcher LineWatcher; enum Mode { WATCH_READ = base::MessagePumpLibevent::WATCH_READ, diff --git a/ipc/chromium/src/base/message_pump_libevent.cc b/ipc/chromium/src/base/message_pump_libevent.cc index f7500fdfd9a3..c1f945bd4d48 100644 --- a/ipc/chromium/src/base/message_pump_libevent.cc +++ b/ipc/chromium/src/base/message_pump_libevent.cc @@ -16,7 +16,6 @@ #include "base/logging.h" #include "base/scoped_nsautorelease_pool.h" #include "base/time.h" -#include "nsDependentSubstring.h" #include "event.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/ProfilerThreadSleep.h" @@ -408,46 +407,4 @@ void MessagePumpLibevent::ScheduleDelayedWork( delayed_work_time_ = delayed_work_time; } -void LineWatcher::OnFileCanReadWithoutBlocking(int aFd) { - ssize_t length = 0; - - while (true) { - length = read(aFd, mReceiveBuffer.get(), mBufferSize - mReceivedIndex); - DCHECK(length <= ssize_t(mBufferSize - mReceivedIndex)); - if (length <= 0) { - if (length < 0) { - if (errno == EINTR) { - continue; // retry system call when interrupted - } - if (errno == EAGAIN || errno == EWOULDBLOCK) { - return; // no data available: return and re-poll - } - DLOG(ERROR) << "Can't read from fd, error " << errno; - } else { - DLOG(ERROR) << "End of file"; - } - // At this point, assume that we can't actually access - // the socket anymore, and indicate an error. - OnError(); - mReceivedIndex = 0; - return; - } - - while (length-- > 0) { - DCHECK(mReceivedIndex < mBufferSize); - if (mReceiveBuffer[mReceivedIndex] == mTerminator) { - nsDependentCSubstring message(mReceiveBuffer.get(), mReceivedIndex); - OnLineRead(aFd, message); - if (length > 0) { - DCHECK(mReceivedIndex < (mBufferSize - 1)); - memmove(&mReceiveBuffer[0], &mReceiveBuffer[mReceivedIndex + 1], - length); - } - mReceivedIndex = 0; - } else { - mReceivedIndex++; - } - } - } -} } // namespace base diff --git a/ipc/chromium/src/base/message_pump_libevent.h b/ipc/chromium/src/base/message_pump_libevent.h index ac2646806945..b1a7d474b3c8 100644 --- a/ipc/chromium/src/base/message_pump_libevent.h +++ b/ipc/chromium/src/base/message_pump_libevent.h @@ -9,8 +9,6 @@ #include "base/message_pump.h" #include "base/time.h" -#include "mozilla/UniquePtr.h" -#include "nsStringFwd.h" // Declare structs we need from libevent.h rather than including it struct event_base; @@ -178,36 +176,6 @@ class MessagePumpLibevent : public MessagePump { DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent); }; -/** - * LineWatcher overrides OnFileCanReadWithoutBlocking. It separates the read - * data by mTerminator and passes each line to OnLineRead. - */ -class LineWatcher : public MessagePumpLibevent::Watcher { - public: - LineWatcher(char aTerminator, int aBufferSize) - : mReceivedIndex(0), mBufferSize(aBufferSize), mTerminator(aTerminator) { - mReceiveBuffer = mozilla::MakeUnique(mBufferSize); - } - - ~LineWatcher() {} - - protected: - /** - * OnError will be called when |read| returns error. Derived class should - * implement this function to handle error cases when needed. - */ - virtual void OnError() {} - virtual void OnLineRead(int aFd, nsDependentCSubstring& aMessage) = 0; - virtual void OnFileCanWriteWithoutBlocking(int /* aFd */) override {} - - private: - void OnFileCanReadWithoutBlocking(int aFd) final; - - mozilla::UniquePtr mReceiveBuffer; - int mReceivedIndex; - int mBufferSize; - char mTerminator; -}; } // namespace base #endif // BASE_MESSAGE_PUMP_LIBEVENT_H_