Chromium Code Reviews| 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_MOJO_IPC_CHANNEL_MOJO_READERS_H_ | 5 #ifndef IPC_MOJO_IPC_CHANNEL_MOJO_READERS_H_ |
| 6 #define IPC_MOJO_IPC_CHANNEL_MOJO_READERS_H_ | 6 #define IPC_MOJO_IPC_CHANNEL_MOJO_READERS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ipc/mojo/ipc_message_pipe_reader.h" | 12 #include "ipc/mojo/ipc_message_pipe_reader.h" |
| 13 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace embedder { | 16 namespace embedder { |
| 17 struct ChannelInfo; | 17 struct ChannelInfo; |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace IPC { | 21 namespace IPC { |
| 22 | 22 |
| 23 class ChannelMojo; | 23 class ChannelMojo; |
| 24 class Message; | 24 class Message; |
| 25 | 25 |
| 26 namespace internal { | 26 namespace internal { |
| 27 | 27 |
| 28 // A MessagePipeReader implementation for IPC::Message communication. | 28 // A MessagePipeReader implementation for IPC::Message communication. |
| 29 class MessageReader : public MessagePipeReader { | 29 class IPC_MOJO_EXPORT MessageReader : public MessagePipeReader { |
| 30 public: | 30 public: |
| 31 MessageReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner); | 31 MessageReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner); |
| 32 | 32 |
| 33 bool Send(scoped_ptr<Message> message); | 33 bool Send(scoped_ptr<Message> message); |
| 34 | 34 |
| 35 // MessagePipeReader implementation | 35 // MessagePipeReader implementation |
| 36 virtual void OnMessageReceived() OVERRIDE; | 36 virtual void OnMessageReceived() OVERRIDE; |
| 37 virtual void OnPipeClosed() OVERRIDE; | 37 virtual void OnPipeClosed() OVERRIDE; |
| 38 virtual void OnPipeError(MojoResult error) OVERRIDE; | 38 virtual void OnPipeError(MojoResult error) OVERRIDE; |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 // Be virtual for testing. | |
| 42 virtual MojoResult WriteMessageToPipe( | |
|
yzshen1
2014/09/15 17:26:07
Is it possible to do it in a different way? For ex
Hajime Morrita
2014/09/15 18:16:53
Sounds good. I made change and things got much sim
| |
| 43 const void* bytes, | |
| 44 uint32_t num_bytes, | |
| 45 const MojoHandle* handles, | |
| 46 uint32_t num_handles, | |
| 47 MojoWriteMessageFlags flags); | |
| 48 | |
| 41 ChannelMojo* owner_; | 49 ChannelMojo* owner_; |
| 42 | 50 |
| 43 DISALLOW_COPY_AND_ASSIGN(MessageReader); | 51 DISALLOW_COPY_AND_ASSIGN(MessageReader); |
| 44 }; | 52 }; |
| 45 | 53 |
| 46 // MessagePipeReader implementation for control messages. | 54 // MessagePipeReader implementation for control messages. |
| 47 // Actual message handling is implemented by sublcasses. | 55 // Actual message handling is implemented by sublcasses. |
| 48 class ControlReader : public MessagePipeReader { | 56 class ControlReader : public MessagePipeReader { |
| 49 public: | 57 public: |
| 50 ControlReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner); | 58 ControlReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 private: | 101 private: |
| 94 MojoResult RespondHelloRequest(MojoHandle message_channel); | 102 MojoResult RespondHelloRequest(MojoHandle message_channel); |
| 95 | 103 |
| 96 DISALLOW_COPY_AND_ASSIGN(ClientControlReader); | 104 DISALLOW_COPY_AND_ASSIGN(ClientControlReader); |
| 97 }; | 105 }; |
| 98 | 106 |
| 99 } // namespace internal | 107 } // namespace internal |
| 100 } // namespace IPC | 108 } // namespace IPC |
| 101 | 109 |
| 102 #endif // IPC_MOJO_IPC_CHANNEL_MOJO_READERS_H_ | 110 #endif // IPC_MOJO_IPC_CHANNEL_MOJO_READERS_H_ |
| OLD | NEW |