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

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

Issue 14068: Reverting 6911. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « base/message_pump_libevent.cc ('k') | chrome/common/ipc_channel_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
14 15
15 namespace IPC { 16 namespace IPC {
16 17
17 class Channel::ChannelImpl : public MessageLoopForIO::Watcher { 18 class Channel::ChannelImpl : public MessageLoopForIO::FileWatcher {
18 public: 19 public:
19 // Mirror methods of Channel, see ipc_channel.h for description. 20 // Mirror methods of Channel, see ipc_channel.h for description.
20 ChannelImpl(const std::wstring& channel_id, Mode mode, Listener* listener); 21 ChannelImpl(const std::wstring& channel_id, Mode mode, Listener* listener);
21 ~ChannelImpl() { Close(); } 22 ~ChannelImpl() { Close(); }
22 bool Connect(); 23 bool Connect();
23 void Close(); 24 void Close();
24 void set_listener(Listener* listener) { listener_ = listener; } 25 void set_listener(Listener* listener) { listener_ = listener; }
25 bool Send(Message* message); 26 bool Send(Message* message);
26 private: 27 private:
27 const std::wstring PipeName(const std::wstring& channel_id) const; 28 const std::wstring PipeName(const std::wstring& channel_id) const;
28 bool CreatePipe(const std::wstring& channel_id, Mode mode); 29 bool CreatePipe(const std::wstring& channel_id, Mode mode);
29 30
30 bool ProcessIncomingMessages(); 31 bool ProcessIncomingMessages();
31 bool ProcessOutgoingMessages(); 32 bool ProcessOutgoingMessages();
32 33
33 void OnFileCanReadWithoutBlocking(int fd); 34 void OnFileReadReady(int fd);
34 void OnFileCanWriteWithoutBlocking(int fd); 35 void OnFileWriteReady(int fd);
35 36
36 Mode mode_; 37 Mode mode_;
37 38
38 // After accepting one client connection on our server socket we want to 39 // Wrapper for Libevent event.
39 // stop listening. 40 // TODO(playmobil): MessageLoopForIO needs to better encapsulate libevent.
40 MessageLoopForIO::FileDescriptorWatcher server_listen_connection_watcher_; 41 struct EventHolder {
41 MessageLoopForIO::FileDescriptorWatcher read_watcher_; 42 EventHolder() : is_active(false) {}
42 MessageLoopForIO::FileDescriptorWatcher write_watcher_; 43 ~EventHolder() {}
43 44
44 // Are we currently blocked waiting for a write to complete. 45 bool is_active;
45 bool is_blocked_on_write_; 46
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_;
46 55
47 // If sending a message blocks then we use this variable 56 // If sending a message blocks then we use this variable
48 // to keep track of where we are. 57 // to keep track of where we are.
49 size_t message_send_bytes_written_; 58 size_t message_send_bytes_written_;
50 59
51 int server_listen_pipe_; 60 int server_listen_pipe_;
52 int pipe_; 61 int pipe_;
53 std::string pipe_name_; 62 std::string pipe_name_;
54 63
55 Listener* listener_; 64 Listener* listener_;
(...skipping 19 matching lines...) Expand all
75 bool processing_incoming_; 84 bool processing_incoming_;
76 85
77 ScopedRunnableMethodFactory<ChannelImpl> factory_; 86 ScopedRunnableMethodFactory<ChannelImpl> factory_;
78 87
79 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); 88 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
80 }; 89 };
81 90
82 } // namespace IPC 91 } // namespace IPC
83 92
84 #endif // CHROME_COMMON_IPC_CHANNEL_POSIX_H_ 93 #endif // CHROME_COMMON_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « base/message_pump_libevent.cc ('k') | chrome/common/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698