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

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

Issue 20027: Capability: passing fds over IPC (Closed)
Patch Set: ... Created 11 years, 10 months 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
« no previous file with comments | « chrome/common/file_descriptor_posix.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 <sys/socket.h> // for CMSG macros
11
10 #include <queue> 12 #include <queue>
11 #include <string> 13 #include <string>
14 #include <vector>
12 15
13 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "chrome/common/file_descriptor_posix.h"
14 18
15 namespace IPC { 19 namespace IPC {
16 20
17 class Channel::ChannelImpl : public MessageLoopForIO::Watcher { 21 class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
18 public: 22 public:
19 // Mirror methods of Channel, see ipc_channel.h for description. 23 // Mirror methods of Channel, see ipc_channel.h for description.
20 ChannelImpl(const std::wstring& channel_id, Mode mode, Listener* listener); 24 ChannelImpl(const std::wstring& channel_id, Mode mode, Listener* listener);
21 ~ChannelImpl() { Close(); } 25 ~ChannelImpl() { Close(); }
22 bool Connect(); 26 bool Connect();
23 void Close(); 27 void Close();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 std::string pipe_name_; 65 std::string pipe_name_;
62 66
63 Listener* listener_; 67 Listener* listener_;
64 68
65 // Messages to be sent are queued here. 69 // Messages to be sent are queued here.
66 std::queue<Message*> output_queue_; 70 std::queue<Message*> output_queue_;
67 71
68 // We read from the pipe into this buffer 72 // We read from the pipe into this buffer
69 char input_buf_[Channel::kReadBufferSize]; 73 char input_buf_[Channel::kReadBufferSize];
70 74
75 enum {
76 // We assume a worst case: kReadBufferSize bytes of messages, where each
77 // message has no payload and a full complement of descriptors.
78 MAX_READ_FDS = (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) *
79 DescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE,
80 };
81
82 // This is a control message buffer large enough to hold kMaxReadFDs
83 char input_cmsg_buf_[CMSG_SPACE(sizeof(int) * MAX_READ_FDS)];
84
71 // Large messages that span multiple pipe buffers, get built-up using 85 // Large messages that span multiple pipe buffers, get built-up using
72 // this buffer. 86 // this buffer.
73 std::string input_overflow_buf_; 87 std::string input_overflow_buf_;
88 std::vector<int> input_overflow_fds_;
74 89
75 // In server-mode, we have to wait for the client to connect before we 90 // In server-mode, we have to wait for the client to connect before we
76 // can begin reading. We make use of the input_state_ when performing 91 // can begin reading. We make use of the input_state_ when performing
77 // the connect operation in overlapped mode. 92 // the connect operation in overlapped mode.
78 bool waiting_connect_; 93 bool waiting_connect_;
79 94
80 // This flag is set when processing incoming messages. It is used to 95 // This flag is set when processing incoming messages. It is used to
81 // avoid recursing through ProcessIncomingMessages, which could cause 96 // avoid recursing through ProcessIncomingMessages, which could cause
82 // problems. TODO(darin): make this unnecessary 97 // problems. TODO(darin): make this unnecessary
83 bool processing_incoming_; 98 bool processing_incoming_;
84 99
85 ScopedRunnableMethodFactory<ChannelImpl> factory_; 100 ScopedRunnableMethodFactory<ChannelImpl> factory_;
86 101
87 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); 102 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
88 }; 103 };
89 104
90 } // namespace IPC 105 } // namespace IPC
91 106
92 #endif // CHROME_COMMON_IPC_CHANNEL_POSIX_H_ 107 #endif // CHROME_COMMON_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « chrome/common/file_descriptor_posix.cc ('k') | chrome/common/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698