| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 using CreateMessagingPipeCallback = | 54 using CreateMessagingPipeCallback = |
| 55 base::Callback<void(mojo::ScopedMessagePipeHandle)>; | 55 base::Callback<void(mojo::ScopedMessagePipeHandle)>; |
| 56 using CreateMessagingPipeOnIOThreadCallback = | 56 using CreateMessagingPipeOnIOThreadCallback = |
| 57 base::Callback<void(mojo::ScopedMessagePipeHandle, | 57 base::Callback<void(mojo::ScopedMessagePipeHandle, |
| 58 mojo::embedder::ChannelInfo*)>; | 58 mojo::embedder::ChannelInfo*)>; |
| 59 | 59 |
| 60 // True if ChannelMojo should be used regardless of the flag. | 60 // True if ChannelMojo should be used regardless of the flag. |
| 61 static bool ShouldBeUsed(); | 61 static bool ShouldBeUsed(); |
| 62 | 62 |
| 63 // Create ChannelMojo. A bootstrap channel is created as well. | 63 // Create ChannelMojo. A bootstrap channel is created as well. |
| 64 // |broker| must outlive the newly created channel. | |
| 65 static scoped_ptr<ChannelMojo> Create( | 64 static scoped_ptr<ChannelMojo> Create( |
| 66 scoped_refptr<base::TaskRunner> io_runner, | 65 scoped_refptr<base::TaskRunner> io_runner, |
| 67 const ChannelHandle& channel_handle, | 66 const ChannelHandle& channel_handle, |
| 68 Mode mode, | 67 Mode mode, |
| 69 Listener* listener, | 68 Listener* listener); |
| 70 AttachmentBroker* broker); | |
| 71 | 69 |
| 72 // Create a factory object for ChannelMojo. | 70 // Create a factory object for ChannelMojo. |
| 73 // The factory is used to create Mojo-based ChannelProxy family. | 71 // The factory is used to create Mojo-based ChannelProxy family. |
| 74 // |host| must not be null. | 72 // |host| must not be null. |
| 75 // TODO(erikchen): Remove default parameter for |broker|. It exists only to | |
| 76 // make the upcoming refactor decomposable into smaller CLs. | |
| 77 // http://crbug.com/493414. | |
| 78 // |broker| must outlive the factory and all channels it creates. | |
| 79 static scoped_ptr<ChannelFactory> CreateServerFactory( | 73 static scoped_ptr<ChannelFactory> CreateServerFactory( |
| 80 scoped_refptr<base::TaskRunner> io_runner, | 74 scoped_refptr<base::TaskRunner> io_runner, |
| 81 const ChannelHandle& channel_handle, | 75 const ChannelHandle& channel_handle); |
| 82 AttachmentBroker* broker = nullptr); | |
| 83 | 76 |
| 84 // TODO(erikchen): Remove default parameter for |broker|. It exists only to | |
| 85 // make the upcoming refactor decomposable into smaller CLs. | |
| 86 // http://crbug.com/493414. | |
| 87 // |broker| must outlive the factory and all channels it creates. | |
| 88 static scoped_ptr<ChannelFactory> CreateClientFactory( | 77 static scoped_ptr<ChannelFactory> CreateClientFactory( |
| 89 scoped_refptr<base::TaskRunner> io_runner, | 78 scoped_refptr<base::TaskRunner> io_runner, |
| 90 const ChannelHandle& channel_handle, | 79 const ChannelHandle& channel_handle); |
| 91 AttachmentBroker* broker = nullptr); | |
| 92 | 80 |
| 93 ~ChannelMojo() override; | 81 ~ChannelMojo() override; |
| 94 | 82 |
| 95 // Channel implementation | 83 // Channel implementation |
| 96 bool Connect() override; | 84 bool Connect() override; |
| 97 void Close() override; | 85 void Close() override; |
| 98 bool Send(Message* message) override; | 86 bool Send(Message* message) override; |
| 99 bool IsSendThreadSafe() const override; | 87 bool IsSendThreadSafe() const override; |
| 100 base::ProcessId GetPeerPID() const override; | 88 base::ProcessId GetPeerPID() const override; |
| 101 base::ProcessId GetSelfPID() const override; | 89 base::ProcessId GetSelfPID() const override; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 119 | 107 |
| 120 // MessagePipeReader::Delegate | 108 // MessagePipeReader::Delegate |
| 121 void OnMessageReceived(Message& message) override; | 109 void OnMessageReceived(Message& message) override; |
| 122 void OnPipeClosed(internal::MessagePipeReader* reader) override; | 110 void OnPipeClosed(internal::MessagePipeReader* reader) override; |
| 123 void OnPipeError(internal::MessagePipeReader* reader) override; | 111 void OnPipeError(internal::MessagePipeReader* reader) override; |
| 124 | 112 |
| 125 protected: | 113 protected: |
| 126 ChannelMojo(scoped_refptr<base::TaskRunner> io_runner, | 114 ChannelMojo(scoped_refptr<base::TaskRunner> io_runner, |
| 127 const ChannelHandle& channel_handle, | 115 const ChannelHandle& channel_handle, |
| 128 Mode mode, | 116 Mode mode, |
| 129 Listener* listener, | 117 Listener* listener); |
| 130 AttachmentBroker* broker); | |
| 131 | 118 |
| 132 void CreateMessagingPipe(mojo::embedder::ScopedPlatformHandle handle, | 119 void CreateMessagingPipe(mojo::embedder::ScopedPlatformHandle handle, |
| 133 const CreateMessagingPipeCallback& callback); | 120 const CreateMessagingPipeCallback& callback); |
| 134 void InitMessageReader(mojo::ScopedMessagePipeHandle pipe, int32_t peer_pid); | 121 void InitMessageReader(mojo::ScopedMessagePipeHandle pipe, int32_t peer_pid); |
| 135 | 122 |
| 136 Listener* listener() const { return listener_; } | 123 Listener* listener() const { return listener_; } |
| 137 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } | 124 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; } |
| 138 | 125 |
| 139 private: | 126 private: |
| 140 struct ChannelInfoDeleter { | 127 struct ChannelInfoDeleter { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 scoped_ptr<ScopedIPCSupport> ipc_support_; | 168 scoped_ptr<ScopedIPCSupport> ipc_support_; |
| 182 | 169 |
| 183 base::WeakPtrFactory<ChannelMojo> weak_factory_; | 170 base::WeakPtrFactory<ChannelMojo> weak_factory_; |
| 184 | 171 |
| 185 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); | 172 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); |
| 186 }; | 173 }; |
| 187 | 174 |
| 188 } // namespace IPC | 175 } // namespace IPC |
| 189 | 176 |
| 190 #endif // IPC_IPC_CHANNEL_MOJO_H_ | 177 #endif // IPC_IPC_CHANNEL_MOJO_H_ |
| OLD | NEW |