OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ | 5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ |
6 #define MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ | 6 #define MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "mojo/system/dispatcher.h" | 13 #include "mojo/system/dispatcher.h" |
| 14 #include "mojo/system/memory.h" |
14 #include "mojo/system/system_impl_export.h" | 15 #include "mojo/system/system_impl_export.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 namespace system { | 18 namespace system { |
18 | 19 |
19 class MessagePipe; | 20 class MessagePipe; |
20 class MessagePipeDispatcherTransport; | 21 class MessagePipeDispatcherTransport; |
21 | 22 |
22 // This is the |Dispatcher| implementation for message pipes (created by the | 23 // This is the |Dispatcher| implementation for message pipes (created by the |
23 // Mojo primitive |MojoCreateMessagePipe()|). This class is thread-safe. | 24 // Mojo primitive |MojoCreateMessagePipe()|). This class is thread-safe. |
24 class MOJO_SYSTEM_IMPL_EXPORT MessagePipeDispatcher : public Dispatcher { | 25 class MOJO_SYSTEM_IMPL_EXPORT MessagePipeDispatcher : public Dispatcher { |
25 public: | 26 public: |
26 // The default options to use for |MojoCreateMessagePipe()|. (Real uses | 27 // The default options to use for |MojoCreateMessagePipe()|. (Real uses |
27 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; | 28 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; |
28 // this is exposed directly for testing convenience.) | 29 // this is exposed directly for testing convenience.) |
29 static const MojoCreateMessagePipeOptions kDefaultCreateOptions; | 30 static const MojoCreateMessagePipeOptions kDefaultCreateOptions; |
30 | 31 |
31 MessagePipeDispatcher( | 32 MessagePipeDispatcher( |
32 const MojoCreateMessagePipeOptions& /*validated_options*/); | 33 const MojoCreateMessagePipeOptions& /*validated_options*/); |
33 | 34 |
34 // Validates and/or sets default options for |MojoCreateMessagePipeOptions|. | 35 // Validates and/or sets default options for |MojoCreateMessagePipeOptions|. |
35 // If non-null, |in_options| must point to a struct of at least | 36 // If non-null, |in_options| must point to a struct of at least |
36 // |in_options->struct_size| bytes. |out_options| must point to a (current) | 37 // |in_options->struct_size| bytes. |out_options| must point to a (current) |
37 // |MojoCreateMessagePipeOptions| and will be entirely overwritten on success | 38 // |MojoCreateMessagePipeOptions| and will be entirely overwritten on success |
38 // (it may be partly overwritten on failure). | 39 // (it may be partly overwritten on failure). |
39 static MojoResult ValidateCreateOptions( | 40 static MojoResult ValidateCreateOptions( |
40 const MojoCreateMessagePipeOptions* in_options, | 41 UserPointer<const MojoCreateMessagePipeOptions> in_options, |
41 MojoCreateMessagePipeOptions* out_options); | 42 MojoCreateMessagePipeOptions* out_options); |
42 | 43 |
43 // Must be called before any other methods. (This method is not thread-safe.) | 44 // Must be called before any other methods. (This method is not thread-safe.) |
44 void Init(scoped_refptr<MessagePipe> message_pipe, unsigned port); | 45 void Init(scoped_refptr<MessagePipe> message_pipe, unsigned port); |
45 | 46 |
46 // |Dispatcher| public methods: | 47 // |Dispatcher| public methods: |
47 virtual Type GetType() const OVERRIDE; | 48 virtual Type GetType() const OVERRIDE; |
48 | 49 |
49 // Creates a |MessagePipe| with a local endpoint (at port 0) and a proxy | 50 // Creates a |MessagePipe| with a local endpoint (at port 0) and a proxy |
50 // endpoint, and creates/initializes a |MessagePipeDispatcher| (attached to | 51 // endpoint, and creates/initializes a |MessagePipeDispatcher| (attached to |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return static_cast<MessagePipeDispatcher*>(dispatcher()); | 123 return static_cast<MessagePipeDispatcher*>(dispatcher()); |
123 } | 124 } |
124 | 125 |
125 // Copy and assign allowed. | 126 // Copy and assign allowed. |
126 }; | 127 }; |
127 | 128 |
128 } // namespace system | 129 } // namespace system |
129 } // namespace mojo | 130 } // namespace mojo |
130 | 131 |
131 #endif // MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ | 132 #endif // MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ |
OLD | NEW |