OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 IPC_IPC_CHANNEL_NACL_H_ | 5 #ifndef IPC_IPC_CHANNEL_NACL_H_ |
6 #define IPC_IPC_CHANNEL_NACL_H_ | 6 #define IPC_IPC_CHANNEL_NACL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 bool CreatePipe(const IPC::ChannelHandle& channel_handle); | 56 bool CreatePipe(const IPC::ChannelHandle& channel_handle); |
57 bool ProcessOutgoingMessages(); | 57 bool ProcessOutgoingMessages(); |
58 void CallOnChannelConnected(); | 58 void CallOnChannelConnected(); |
59 | 59 |
60 // ChannelReader implementation. | 60 // ChannelReader implementation. |
61 ReadState ReadData(char* buffer, | 61 ReadState ReadData(char* buffer, |
62 int buffer_len, | 62 int buffer_len, |
63 int* bytes_read) override; | 63 int* bytes_read) override; |
64 bool ShouldDispatchInputMessage(Message* msg) override; | 64 bool ShouldDispatchInputMessage(Message* msg) override; |
65 bool GetNonBrokeredAttachments(Message* msg) override; | 65 bool GetAttachments(Message* msg) override; |
66 bool DidEmptyInputBuffers() override; | 66 bool DidEmptyInputBuffers() override; |
67 void HandleInternalMessage(const Message& msg) override; | 67 void HandleInternalMessage(const Message& msg) override; |
68 | 68 |
69 Mode mode_; | 69 Mode mode_; |
70 bool waiting_connect_; | 70 bool waiting_connect_; |
71 | 71 |
72 // The pipe used for communication. | 72 // The pipe used for communication. |
73 int pipe_; | 73 int pipe_; |
74 | 74 |
75 // We use a thread for reading, so that we can simply block on reading and | 75 // We use a thread for reading, so that we can simply block on reading and |
(...skipping 13 matching lines...) Expand all Loading... |
89 // MessageContents object is the result of one call to "imc_recvmsg". | 89 // MessageContents object is the result of one call to "imc_recvmsg". |
90 // DidRecvMsg breaks the MessageContents out in to the data and the file | 90 // DidRecvMsg breaks the MessageContents out in to the data and the file |
91 // descriptors, and puts them on these two queues. | 91 // descriptors, and puts them on these two queues. |
92 // TODO(dmichael): There's probably a more efficient way to emulate this with | 92 // TODO(dmichael): There's probably a more efficient way to emulate this with |
93 // a circular buffer or something, so we don't have to do so | 93 // a circular buffer or something, so we don't have to do so |
94 // many heap allocations. But it maybe isn't worth | 94 // many heap allocations. But it maybe isn't worth |
95 // the trouble given that we probably want to implement 1 and | 95 // the trouble given that we probably want to implement 1 and |
96 // 2 above in NaCl eventually. | 96 // 2 above in NaCl eventually. |
97 // When ReadData is called, it pulls the bytes out of this queue in order. | 97 // When ReadData is called, it pulls the bytes out of this queue in order. |
98 std::deque<linked_ptr<std::vector<char> > > read_queue_; | 98 std::deque<linked_ptr<std::vector<char> > > read_queue_; |
99 // Queue of file descriptors extracted from imc_recvmsg messages. | 99 // Queue of file descriptor attachments extracted from imc_recvmsg messages. |
100 // NOTE: The implementation assumes underlying storage here is contiguous, so | 100 std::vector<scoped_refptr<MessageAttachment>> input_attachments_; |
101 // don't change to something like std::deque<> without changing the | |
102 // implementation! | |
103 std::vector<int> input_fds_; | |
104 | 101 |
105 // This queue is used when a message is sent prior to Connect having been | 102 // This queue is used when a message is sent prior to Connect having been |
106 // called. Normally after we're connected, the queue is empty. | 103 // called. Normally after we're connected, the queue is empty. |
107 std::deque<linked_ptr<Message> > output_queue_; | 104 std::deque<linked_ptr<Message> > output_queue_; |
108 | 105 |
109 base::WeakPtrFactory<ChannelNacl> weak_ptr_factory_; | 106 base::WeakPtrFactory<ChannelNacl> weak_ptr_factory_; |
110 | 107 |
111 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelNacl); | 108 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelNacl); |
112 }; | 109 }; |
113 | 110 |
114 } // namespace IPC | 111 } // namespace IPC |
115 | 112 |
116 #endif // IPC_IPC_CHANNEL_NACL_H_ | 113 #endif // IPC_IPC_CHANNEL_NACL_H_ |
OLD | NEW |