OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_H_ | |
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "mojo/edk/embedder/platform_handle_vector.h" | |
12 #include "mojo/edk/embedder/scoped_platform_handle.h" | |
13 #include "mojo/edk/system/system_impl_export.h" | |
14 #include "mojo/public/c/system/data_pipe.h" | |
15 #include "mojo/public/c/system/types.h" | |
16 | |
17 namespace mojo { | |
18 namespace edk { | |
19 class RawChannel; | |
20 | |
21 // Shared code between DataPipeConsumerDispatcher and | |
22 // DataPipeProducerDispatcher. | |
23 class MOJO_SYSTEM_IMPL_EXPORT DataPipe { | |
24 public: | |
25 // The default options for |MojoCreateDataPipe()|. (Real uses should obtain | |
26 // this via |ValidateCreateOptions()| with a null |in_options|; this is | |
27 // exposed directly for testing convenience.) | |
28 static MojoCreateDataPipeOptions GetDefaultCreateOptions(); | |
29 | |
30 // Validates and/or sets default options for |MojoCreateDataPipeOptions|. If | |
31 // non-null, |in_options| must point to a struct of at least | |
32 // |in_options->struct_size| bytes. |out_options| must point to a (current) | |
33 // |MojoCreateDataPipeOptions| and will be entirely overwritten on success (it | |
34 // may be partly overwritten on failure). | |
35 static MojoResult ValidateCreateOptions( | |
36 const MojoCreateDataPipeOptions* in_options, | |
37 MojoCreateDataPipeOptions* out_options); | |
38 | |
39 // Helper methods used by DataPipeConsumerDispatcher and | |
40 // DataPipeProducerDispatcher for serialization and deserialization. | |
41 static void StartSerialize(bool have_channel_handle, | |
42 bool have_shared_memory, | |
43 size_t* max_size, | |
44 size_t* max_platform_handles); | |
45 static void EndSerialize(const MojoCreateDataPipeOptions& options, | |
46 ScopedPlatformHandle channel_handle, | |
47 ScopedPlatformHandle shared_memory_handle, | |
48 size_t shared_memory_size, | |
49 void* destination, | |
50 size_t* actual_size, | |
51 PlatformHandleVector* platform_handles); | |
52 static ScopedPlatformHandle Deserialize( | |
53 const void* source, | |
54 size_t size, | |
55 PlatformHandleVector* platform_handles, | |
56 MojoCreateDataPipeOptions* options, | |
57 ScopedPlatformHandle* shared_memory_handle, | |
58 size_t* shared_memory_size); | |
59 }; | |
60 | |
61 } // namespace edk | |
62 } // namespace mojo | |
63 | |
64 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_H_ | |
OLD | NEW |