Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome/common/ipc_channel_posix.h

Issue 13757: message_pump_libevent refactor: (Closed)
Patch Set: Another small fix. Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_COMMON_IPC_CHANNEL_POSIX_H_ 5 #ifndef CHROME_COMMON_IPC_CHANNEL_POSIX_H_
6 #define CHROME_COMMON_IPC_CHANNEL_POSIX_H_ 6 #define CHROME_COMMON_IPC_CHANNEL_POSIX_H_
7 7
8 #include "chrome/common/ipc_channel.h" 8 #include "chrome/common/ipc_channel.h"
9 9
10 #include <queue> 10 #include <queue>
11 #include <string> 11 #include <string>
12 12
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "third_party/libevent/event.h"
15 14
16 namespace IPC { 15 namespace IPC {
17 16
18 class Channel::ChannelImpl : public MessageLoopForIO::FileWatcher { 17 class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
19 public: 18 public:
20 // Mirror methods of Channel, see ipc_channel.h for description. 19 // Mirror methods of Channel, see ipc_channel.h for description.
21 ChannelImpl(const std::wstring& channel_id, Mode mode, Listener* listener); 20 ChannelImpl(const std::wstring& channel_id, Mode mode, Listener* listener);
22 ~ChannelImpl() { Close(); } 21 ~ChannelImpl() { Close(); }
23 bool Connect(); 22 bool Connect();
24 void Close(); 23 void Close();
25 void set_listener(Listener* listener) { listener_ = listener; } 24 void set_listener(Listener* listener) { listener_ = listener; }
26 bool Send(Message* message); 25 bool Send(Message* message);
27 private: 26 private:
28 const std::wstring PipeName(const std::wstring& channel_id) const; 27 const std::wstring PipeName(const std::wstring& channel_id) const;
29 bool CreatePipe(const std::wstring& channel_id, Mode mode); 28 bool CreatePipe(const std::wstring& channel_id, Mode mode);
30 29
31 bool ProcessIncomingMessages(); 30 bool ProcessIncomingMessages();
32 bool ProcessOutgoingMessages(); 31 bool ProcessOutgoingMessages();
33 32
34 void OnFileReadReady(int fd); 33 void OnFileCanReadWithoutBlocking(int fd);
35 void OnFileWriteReady(int fd); 34 void OnFileCanWriteWithoutBlocking(int fd);
36 35
37 Mode mode_; 36 Mode mode_;
38 37
39 // Wrapper for Libevent event. 38 // After accepting one client connection on our server socket we want to
40 // TODO(playmobil): MessageLoopForIO needs to better encapsulate libevent. 39 // stop listening.
41 struct EventHolder { 40 MessageLoopForIO::FileDescriptorWatcher server_listen_connection_watcher_;
42 EventHolder() : is_active(false) {} 41 MessageLoopForIO::FileDescriptorWatcher read_watcher_;
43 ~EventHolder() {} 42 MessageLoopForIO::FileDescriptorWatcher write_watcher_;
44 43
45 bool is_active; 44 // Indicates whether we're currently blocked waiting for a write to complete.
46 45 bool is_blocked_on_write_;
47 // libevent's set functions set all the needed members of this struct, so no
48 // need to initialize before use.
49 struct event event;
50 };
51
52 EventHolder *server_listen_connection_event_;
53 EventHolder *read_event_;
54 EventHolder *write_event_;
55 46
56 // If sending a message blocks then we use this variable 47 // If sending a message blocks then we use this variable
57 // to keep track of where we are. 48 // to keep track of where we are.
58 size_t message_send_bytes_written_; 49 size_t message_send_bytes_written_;
59 50
60 int server_listen_pipe_; 51 int server_listen_pipe_;
61 int pipe_; 52 int pipe_;
62 std::string pipe_name_; 53 std::string pipe_name_;
63 54
64 Listener* listener_; 55 Listener* listener_;
(...skipping 19 matching lines...) Expand all
84 bool processing_incoming_; 75 bool processing_incoming_;
85 76
86 ScopedRunnableMethodFactory<ChannelImpl> factory_; 77 ScopedRunnableMethodFactory<ChannelImpl> factory_;
87 78
88 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); 79 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
89 }; 80 };
90 81
91 } // namespace IPC 82 } // namespace IPC
92 83
93 #endif // CHROME_COMMON_IPC_CHANNEL_POSIX_H_ 84 #endif // CHROME_COMMON_IPC_CHANNEL_POSIX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698