diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-08 18:10:14 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-08 18:10:14 +0000 |
commit | fa95fc9a2f01e76d455b88f54d95455cf9797dae (patch) | |
tree | 10de50e7ec33b7cba4a8e5a6d54dac0d1bd61abf /chrome/common/ipc_channel.h | |
parent | 0290ab07274feb2b44fca1006875509f1cceed70 (diff) | |
download | chromium_src-fa95fc9a2f01e76d455b88f54d95455cf9797dae.zip chromium_src-fa95fc9a2f01e76d455b88f54d95455cf9797dae.tar.gz chromium_src-fa95fc9a2f01e76d455b88f54d95455cf9797dae.tar.bz2 |
First cut at POSIX Implementation of IPC Channel using FIFOs.
The following work still remains:
* Provide better encapsulation of libevent.
* Use socketpair and use named FIFO code only when debugging.
Review URL: http://codereview.chromium.org/12927
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_channel.h')
-rw-r--r-- | chrome/common/ipc_channel.h | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/chrome/common/ipc_channel.h b/chrome/common/ipc_channel.h index 4709166..ac234b8 100644 --- a/chrome/common/ipc_channel.h +++ b/chrome/common/ipc_channel.h @@ -14,9 +14,11 @@ namespace IPC { //------------------------------------------------------------------------------ -class Channel : public Message::Sender +class Channel : public Message::Sender, #if defined(OS_WIN) - , public MessageLoopForIO::IOHandler + public MessageLoopForIO::IOHandler +#elif defined(OS_POSIX) + public MessageLoopForIO::FileWatcher #endif { // Security tests need access to the pipe handle. @@ -90,9 +92,9 @@ class Channel : public Message::Sender virtual bool Send(Message* message); private: -#if defined(OS_WIN) const std::wstring PipeName(const std::wstring& channel_id) const; bool CreatePipe(const std::wstring& channel_id, Mode mode); +#if defined(OS_WIN) bool ProcessConnection(); bool ProcessIncomingMessages(MessageLoopForIO::IOContext* context, DWORD bytes_read); @@ -102,14 +104,11 @@ class Channel : public Message::Sender // MessageLoop::IOHandler implementation. virtual void OnIOCompleted(MessageLoopForIO::IOContext* context, DWORD bytes_transfered, DWORD error); -#endif - private: enum { BUF_SIZE = 4096 }; -#if defined(OS_WIN) struct State { explicit State(Channel* channel); ~State(); @@ -121,7 +120,36 @@ class Channel : public Message::Sender State output_state_; HANDLE pipe_; -#endif +#elif defined(OS_POSIX) + bool ProcessIncomingMessages(); + bool ProcessOutgoingMessages(); + + void OnFileReadReady(int fd); + void OnFileWriteReady(int fd); + + + Mode mode_; + + // TODO(playmobil): do we need to change BUF_SIZE ? + private: + enum { + BUF_SIZE = 4096 + }; + + // PIMPL to encapsulate libevent structures. + struct EventHolder; + EventHolder *server_listen_connection_event_; + EventHolder *read_event_; + EventHolder *write_event_; + + // If sending a message blocks then we use this variable + // to keep track of where we are. + size_t message_send_bytes_written_; + + int server_listen_pipe_; + int pipe_; + std::string pipe_name_; +#endif // defined(OS_POSIX) Listener* listener_; // Messages to be sent are queued here. |