| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // True if ChannelMojo should be used regardless of the flag. | 67 // True if ChannelMojo should be used regardless of the flag. |
| 68 static bool ShouldBeUsed(); | 68 static bool ShouldBeUsed(); |
| 69 | 69 |
| 70 // Create ChannelMojo. A bootstrap channel is created as well. | 70 // Create ChannelMojo. A bootstrap channel is created as well. |
| 71 // |host| must not be null for server channels. | 71 // |host| must not be null for server channels. |
| 72 static scoped_ptr<ChannelMojo> Create( | 72 static scoped_ptr<ChannelMojo> Create( |
| 73 Delegate* delegate, | 73 Delegate* delegate, |
| 74 scoped_refptr<base::TaskRunner> io_runner, | 74 scoped_refptr<base::TaskRunner> io_runner, |
| 75 const ChannelHandle& channel_handle, | 75 const ChannelHandle& channel_handle, |
| 76 Mode mode, | 76 Mode mode, |
| 77 Listener* listener); | 77 Listener* listener, |
| 78 AttachmentBroker* broker); |
| 78 | 79 |
| 79 // Create a factory object for ChannelMojo. | 80 // Create a factory object for ChannelMojo. |
| 80 // The factory is used to create Mojo-based ChannelProxy family. | 81 // The factory is used to create Mojo-based ChannelProxy family. |
| 81 // |host| must not be null. | 82 // |host| must not be null. |
| 83 // TODO(erikchen): Remove default parameter for |broker|. It exists only to |
| 84 // make the upcoming refactor decomposable into smaller CLs. |
| 85 // http://crbug.com/493414. |
| 82 static scoped_ptr<ChannelFactory> CreateServerFactory( | 86 static scoped_ptr<ChannelFactory> CreateServerFactory( |
| 83 Delegate* delegate, | 87 Delegate* delegate, |
| 84 scoped_refptr<base::TaskRunner> io_runner, | 88 scoped_refptr<base::TaskRunner> io_runner, |
| 85 const ChannelHandle& channel_handle); | 89 const ChannelHandle& channel_handle, |
| 90 AttachmentBroker* broker = nullptr); |
| 86 | 91 |
| 92 // TODO(erikchen): Remove default parameter for |broker|. It exists only to |
| 93 // make the upcoming refactor decomposable into smaller CLs. |
| 94 // http://crbug.com/493414. |
| 87 static scoped_ptr<ChannelFactory> CreateClientFactory( | 95 static scoped_ptr<ChannelFactory> CreateClientFactory( |
| 88 Delegate* delegate, | 96 Delegate* delegate, |
| 89 scoped_refptr<base::TaskRunner> io_runner, | 97 scoped_refptr<base::TaskRunner> io_runner, |
| 90 const ChannelHandle& channel_handle); | 98 const ChannelHandle& channel_handle, |
| 99 AttachmentBroker* broker = nullptr); |
| 91 | 100 |
| 92 ~ChannelMojo() override; | 101 ~ChannelMojo() override; |
| 93 | 102 |
| 94 // ChannelMojoHost tells the client handle using this API. | 103 // ChannelMojoHost tells the client handle using this API. |
| 95 void OnClientLaunched(base::ProcessHandle handle); | 104 void OnClientLaunched(base::ProcessHandle handle); |
| 96 | 105 |
| 97 // Channel implementation | 106 // Channel implementation |
| 98 bool Connect() override; | 107 bool Connect() override; |
| 99 void Close() override; | 108 void Close() override; |
| 100 bool Send(Message* message) override; | 109 bool Send(Message* message) override; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 122 // MessagePipeReader::Delegate | 131 // MessagePipeReader::Delegate |
| 123 void OnMessageReceived(Message& message) override; | 132 void OnMessageReceived(Message& message) override; |
| 124 void OnPipeClosed(internal::MessagePipeReader* reader) override; | 133 void OnPipeClosed(internal::MessagePipeReader* reader) override; |
| 125 void OnPipeError(internal::MessagePipeReader* reader) override; | 134 void OnPipeError(internal::MessagePipeReader* reader) override; |
| 126 | 135 |
| 127 protected: | 136 protected: |
| 128 ChannelMojo(Delegate* delegate, | 137 ChannelMojo(Delegate* delegate, |
| 129 scoped_refptr<base::TaskRunner> io_runner, | 138 scoped_refptr<base::TaskRunner> io_runner, |
| 130 const ChannelHandle& channel_handle, | 139 const ChannelHandle& channel_handle, |
| 131 Mode mode, | 140 Mode mode, |
| 132 Listener* listener); | 141 Listener* listener, |
| 142 AttachmentBroker* broker); |
| 133 | 143 |
| 134 void CreateMessagingPipe(mojo::embedder::ScopedPlatformHandle handle, | 144 void CreateMessagingPipe(mojo::embedder::ScopedPlatformHandle handle, |
| 135 const CreateMessagingPipeCallback& callback); | 145 const CreateMessagingPipeCallback& callback); |
| 136 void InitMessageReader(mojo::ScopedMessagePipeHandle pipe, int32_t peer_pid); | 146 void InitMessageReader(mojo::ScopedMessagePipeHandle pipe, int32_t peer_pid); |
| 137 | 147 |
| 138 Listener* listener() const { return listener_; } | 148 Listener* listener() const { return listener_; } |
| 139 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } | 149 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } |
| 140 | 150 |
| 141 private: | 151 private: |
| 142 struct ChannelInfoDeleter { | 152 struct ChannelInfoDeleter { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 scoped_ptr<ScopedIPCSupport> ipc_support_; | 194 scoped_ptr<ScopedIPCSupport> ipc_support_; |
| 185 | 195 |
| 186 base::WeakPtrFactory<ChannelMojo> weak_factory_; | 196 base::WeakPtrFactory<ChannelMojo> weak_factory_; |
| 187 | 197 |
| 188 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); | 198 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); |
| 189 }; | 199 }; |
| 190 | 200 |
| 191 } // namespace IPC | 201 } // namespace IPC |
| 192 | 202 |
| 193 #endif // IPC_IPC_CHANNEL_MOJO_H_ | 203 #endif // IPC_IPC_CHANNEL_MOJO_H_ |
| OLD | NEW |