| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MOJO_H_ | 5 #ifndef IPC_IPC_CHANNEL_MOJO_H_ |
| 6 #define IPC_IPC_CHANNEL_MOJO_H_ | 6 #define IPC_IPC_CHANNEL_MOJO_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Create a factory object for ChannelMojo. | 80 // Create a factory object for ChannelMojo. |
| 81 // The factory is used to create Mojo-based ChannelProxy family. | 81 // The factory is used to create Mojo-based ChannelProxy family. |
| 82 // |host| must not be null. | 82 // |host| must not be null. |
| 83 static scoped_ptr<ChannelFactory> CreateServerFactory( | 83 static scoped_ptr<ChannelFactory> CreateServerFactory( |
| 84 Delegate* delegate, | 84 Delegate* delegate, |
| 85 const ChannelHandle& channel_handle); | 85 const ChannelHandle& channel_handle); |
| 86 | 86 |
| 87 static scoped_ptr<ChannelFactory> CreateClientFactory( | 87 static scoped_ptr<ChannelFactory> CreateClientFactory( |
| 88 const ChannelHandle& channel_handle); | 88 const ChannelHandle& channel_handle); |
| 89 | 89 |
| 90 virtual ~ChannelMojo(); | 90 ~ChannelMojo() override; |
| 91 | 91 |
| 92 // ChannelMojoHost tells the client handle using this API. | 92 // ChannelMojoHost tells the client handle using this API. |
| 93 void OnClientLaunched(base::ProcessHandle handle); | 93 void OnClientLaunched(base::ProcessHandle handle); |
| 94 | 94 |
| 95 // Channel implementation | 95 // Channel implementation |
| 96 virtual bool Connect() override; | 96 bool Connect() override; |
| 97 virtual void Close() override; | 97 void Close() override; |
| 98 virtual bool Send(Message* message) override; | 98 bool Send(Message* message) override; |
| 99 virtual base::ProcessId GetPeerPID() const override; | 99 base::ProcessId GetPeerPID() const override; |
| 100 virtual base::ProcessId GetSelfPID() const override; | 100 base::ProcessId GetSelfPID() const override; |
| 101 | 101 |
| 102 #if defined(OS_POSIX) && !defined(OS_NACL) | 102 #if defined(OS_POSIX) && !defined(OS_NACL) |
| 103 virtual int GetClientFileDescriptor() const override; | 103 int GetClientFileDescriptor() const override; |
| 104 virtual base::ScopedFD TakeClientFileDescriptor() override; | 104 base::ScopedFD TakeClientFileDescriptor() override; |
| 105 | 105 |
| 106 // These access protected API of IPC::Message, which has ChannelMojo | 106 // These access protected API of IPC::Message, which has ChannelMojo |
| 107 // as a friend class. | 107 // as a friend class. |
| 108 static MojoResult WriteToFileDescriptorSet( | 108 static MojoResult WriteToFileDescriptorSet( |
| 109 const std::vector<MojoHandle>& handle_buffer, | 109 const std::vector<MojoHandle>& handle_buffer, |
| 110 Message* message); | 110 Message* message); |
| 111 static MojoResult ReadFromFileDescriptorSet(Message* message, | 111 static MojoResult ReadFromFileDescriptorSet(Message* message, |
| 112 std::vector<MojoHandle>* handles); | 112 std::vector<MojoHandle>* handles); |
| 113 | 113 |
| 114 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 114 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 115 | 115 |
| 116 // MojoBootstrapDelegate implementation | 116 // MojoBootstrapDelegate implementation |
| 117 virtual void OnPipeAvailable( | 117 void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle) override; |
| 118 mojo::embedder::ScopedPlatformHandle handle) override; | 118 void OnBootstrapError() override; |
| 119 virtual void OnBootstrapError() override; | |
| 120 | 119 |
| 121 // Called from MessagePipeReader implementations | 120 // Called from MessagePipeReader implementations |
| 122 void OnMessageReceived(Message& message); | 121 void OnMessageReceived(Message& message); |
| 123 void OnConnected(mojo::ScopedMessagePipeHandle pipe); | 122 void OnConnected(mojo::ScopedMessagePipeHandle pipe); |
| 124 void OnPipeClosed(internal::MessagePipeReader* reader); | 123 void OnPipeClosed(internal::MessagePipeReader* reader); |
| 125 void OnPipeError(internal::MessagePipeReader* reader); | 124 void OnPipeError(internal::MessagePipeReader* reader); |
| 126 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } | 125 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } |
| 127 | 126 |
| 128 protected: | 127 protected: |
| 129 ChannelMojo(Delegate* delegate, | 128 ChannelMojo(Delegate* delegate, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 157 ScopedVector<Message> pending_messages_; | 156 ScopedVector<Message> pending_messages_; |
| 158 | 157 |
| 159 base::WeakPtrFactory<ChannelMojo> weak_factory_; | 158 base::WeakPtrFactory<ChannelMojo> weak_factory_; |
| 160 | 159 |
| 161 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); | 160 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); |
| 162 }; | 161 }; |
| 163 | 162 |
| 164 } // namespace IPC | 163 } // namespace IPC |
| 165 | 164 |
| 166 #endif // IPC_IPC_CHANNEL_MOJO_H_ | 165 #endif // IPC_IPC_CHANNEL_MOJO_H_ |
| OLD | NEW |