Chromium Code Reviews| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 // We don't need to worry about complicated set up and READWRITE mode for | 30 // We don't need to worry about complicated set up and READWRITE mode for |
| 31 // sharing handles. We also currently do not support passing file descriptors or | 31 // sharing handles. We also currently do not support passing file descriptors or |
| 32 // named pipes, and we use background threads to emulate signaling when we can | 32 // named pipes, and we use background threads to emulate signaling when we can |
| 33 // read or write without blocking. | 33 // read or write without blocking. |
| 34 class ChannelNacl : public Channel, | 34 class ChannelNacl : public Channel, |
| 35 public internal::ChannelReader { | 35 public internal::ChannelReader { |
| 36 public: | 36 public: |
| 37 // Mirror methods of Channel, see ipc_channel.h for description. | 37 // Mirror methods of Channel, see ipc_channel.h for description. |
| 38 ChannelNacl(const IPC::ChannelHandle& channel_handle, | 38 ChannelNacl(const IPC::ChannelHandle& channel_handle, |
| 39 Mode mode, | 39 Mode mode, |
| 40 Listener* listener); | 40 Listener* listener, |
| 41 AttachmentBroker* broker); | |
| 41 ~ChannelNacl() override; | 42 ~ChannelNacl() override; |
| 42 | 43 |
| 43 // Channel implementation. | 44 // Channel implementation. |
| 44 base::ProcessId GetPeerPID() const override; | 45 base::ProcessId GetPeerPID() const override; |
| 45 base::ProcessId GetSelfPID() const override; | 46 base::ProcessId GetSelfPID() const override; |
| 46 bool Connect() override; | 47 bool Connect() override; |
| 47 void Close() override; | 48 void Close() override; |
| 48 bool Send(Message* message) override; | 49 bool Send(Message* message) override; |
| 50 AttachmentBroker* GetAttachmentBroker() override; | |
| 49 | 51 |
| 50 // Posted to the main thread by ReaderThreadRunner. | 52 // Posted to the main thread by ReaderThreadRunner. |
| 51 void DidRecvMsg(scoped_ptr<MessageContents> contents); | 53 void DidRecvMsg(scoped_ptr<MessageContents> contents); |
| 52 void ReadDidFail(); | 54 void ReadDidFail(); |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 class ReaderThreadRunner; | 57 class ReaderThreadRunner; |
| 56 | 58 |
| 57 bool CreatePipe(const IPC::ChannelHandle& channel_handle); | 59 bool CreatePipe(const IPC::ChannelHandle& channel_handle); |
| 58 bool ProcessOutgoingMessages(); | 60 bool ProcessOutgoingMessages(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 // don't change to something like std::deque<> without changing the | 109 // don't change to something like std::deque<> without changing the |
| 108 // implementation! | 110 // implementation! |
| 109 std::vector<int> input_fds_; | 111 std::vector<int> input_fds_; |
| 110 | 112 |
| 111 // This queue is used when a message is sent prior to Connect having been | 113 // This queue is used when a message is sent prior to Connect having been |
| 112 // called. Normally after we're connected, the queue is empty. | 114 // called. Normally after we're connected, the queue is empty. |
| 113 std::deque<linked_ptr<Message> > output_queue_; | 115 std::deque<linked_ptr<Message> > output_queue_; |
| 114 | 116 |
| 115 base::WeakPtrFactory<ChannelNacl> weak_ptr_factory_; | 117 base::WeakPtrFactory<ChannelNacl> weak_ptr_factory_; |
| 116 | 118 |
| 119 // |broker_| must outlive this instance. | |
|
Tom Sepez
2015/06/16 16:36:44
nit: maybe move this comment to the ctor, where th
erikchen
2015/06/16 17:36:47
I kept the comment here, and added a similar comme
| |
| 120 AttachmentBroker* broker_; | |
|
Will Harris
2015/06/16 13:06:04
where will this object be created and how will the
erikchen
2015/06/16 17:36:47
The short answer is: Each process is responsible f
| |
| 121 | |
| 117 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelNacl); | 122 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelNacl); |
| 118 }; | 123 }; |
| 119 | 124 |
| 120 } // namespace IPC | 125 } // namespace IPC |
| 121 | 126 |
| 122 #endif // IPC_IPC_CHANNEL_NACL_H_ | 127 #endif // IPC_IPC_CHANNEL_NACL_H_ |
| OLD | NEW |