Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: mojo/edk/system/transport_data.h

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ 5 #ifndef MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_
6 #define MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ 6 #define MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/aligned_memory.h" 12 #include "base/memory/aligned_memory.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "mojo/edk/embedder/platform_handle.h" 15 #include "mojo/edk/embedder/platform_handle.h"
16 #include "mojo/edk/embedder/platform_handle_vector.h" 16 #include "mojo/edk/embedder/platform_handle_vector.h"
17 #include "mojo/edk/system/dispatcher.h" 17 #include "mojo/edk/system/dispatcher.h"
18 #include "mojo/edk/system/system_impl_export.h" 18 #include "mojo/edk/system/system_impl_export.h"
19 #include "mojo/public/cpp/system/macros.h" 19 #include "mojo/public/cpp/system/macros.h"
20 20
21 namespace mojo { 21 namespace mojo {
22 namespace system { 22 namespace system {
23 23
24 class Channel;
25
26 // This class is used by |MessageInTransit| to represent handles (|Dispatcher|s) 24 // This class is used by |MessageInTransit| to represent handles (|Dispatcher|s)
27 // in various stages of serialization. 25 // in various stages of serialization.
28 // 26 //
29 // The stages are: 27 // The stages are:
30 // - Before reaching |TransportData|: Turn |DispatcherTransport|s into 28 // - Before reaching |TransportData|: Turn |DispatcherTransport|s into
31 // |Dispatcher|s that are "owned" by (and attached to) a |MessageInTransit|. 29 // |Dispatcher|s that are "owned" by (and attached to) a |MessageInTransit|.
32 // This invalidates the handles in the space of the sending application 30 // This invalidates the handles in the space of the sending application
33 // (and, e.g., if another thread is waiting on such a handle, it'll be 31 // (and, e.g., if another thread is waiting on such a handle, it'll be
34 // notified of this invalidation). 32 // notified of this invalidation).
35 // - Serialize these dispatchers into the |TransportData|: First, for each 33 // - Serialize these dispatchers into the |TransportData|: First, for each
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // The maximum number of platform handles to attach for a single serialized 80 // The maximum number of platform handles to attach for a single serialized
83 // dispatcher. 81 // dispatcher.
84 static const size_t kMaxSerializedDispatcherPlatformHandles = 2; 82 static const size_t kMaxSerializedDispatcherPlatformHandles = 2;
85 83
86 // The maximum possible size of a valid transport data buffer. 84 // The maximum possible size of a valid transport data buffer.
87 static size_t GetMaxBufferSize(); 85 static size_t GetMaxBufferSize();
88 86
89 // The maximum total number of platform handles that may be attached. 87 // The maximum total number of platform handles that may be attached.
90 static size_t GetMaxPlatformHandles(); 88 static size_t GetMaxPlatformHandles();
91 89
92 TransportData(scoped_ptr<DispatcherVector> dispatchers, Channel* channel); 90 explicit TransportData(scoped_ptr<DispatcherVector> dispatchers);
93 91
94 // This is used for users of |MessageInTransit|/|TransportData|/|RawChannel| 92 // This is used for users of |MessageInTransit|/|TransportData|/|RawChannel|
95 // that want to simply transport data and platform handles, and not 93 // that want to simply transport data and platform handles, and not
96 // |Dispatcher|s. (|Header| will be present, and zero except for 94 // |Dispatcher|s. (|Header| will be present, and zero except for
97 // |num_platform_handles|, and |platform_handle_table_offset| if necessary.) 95 // |num_platform_handles|, and |platform_handle_table_offset| if necessary.)
98 explicit TransportData( 96 explicit TransportData(
99 embedder::ScopedPlatformHandleVectorPtr platform_handles, 97 embedder::ScopedPlatformHandleVectorPtr platform_handles,
100 size_t serialized_platform_handle_size); 98 size_t serialized_platform_handle_size);
101 99
102 ~TransportData(); 100 ~TransportData();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 static void GetPlatformHandleTable(const void* transport_data_buffer, 134 static void GetPlatformHandleTable(const void* transport_data_buffer,
137 size_t* num_platform_handles, 135 size_t* num_platform_handles,
138 const void** platform_handle_table); 136 const void** platform_handle_table);
139 137
140 // Deserializes dispatchers from the given (serialized) transport data buffer 138 // Deserializes dispatchers from the given (serialized) transport data buffer
141 // (typically from a |MessageInTransit::View|) and vector of platform handles. 139 // (typically from a |MessageInTransit::View|) and vector of platform handles.
142 // |buffer| should be non-null and |buffer_size| should be nonzero. 140 // |buffer| should be non-null and |buffer_size| should be nonzero.
143 static scoped_ptr<DispatcherVector> DeserializeDispatchers( 141 static scoped_ptr<DispatcherVector> DeserializeDispatchers(
144 const void* buffer, 142 const void* buffer,
145 size_t buffer_size, 143 size_t buffer_size,
146 embedder::ScopedPlatformHandleVectorPtr platform_handles, 144 embedder::ScopedPlatformHandleVectorPtr platform_handles);
147 Channel* channel);
148 145
149 private: 146 private:
150 // To allow us to make compile-assertions about |Header|, etc. in the .cc 147 // To allow us to make compile-assertions about |Header|, etc. in the .cc
151 // file. 148 // file.
152 struct PrivateStructForCompileAsserts; 149 struct PrivateStructForCompileAsserts;
153 150
154 // Header for the "secondary buffer"/"transport data". Must be a multiple of 151 // Header for the "secondary buffer"/"transport data". Must be a multiple of
155 // |MessageInTransit::kMessageAlignment| in size. Must be POD. 152 // |MessageInTransit::kMessageAlignment| in size. Must be POD.
156 struct Header { 153 struct Header {
157 uint32_t num_handles; 154 uint32_t num_handles;
(...skipping 24 matching lines...) Expand all
182 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandle|s. 179 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandle|s.
183 embedder::ScopedPlatformHandleVectorPtr platform_handles_; 180 embedder::ScopedPlatformHandleVectorPtr platform_handles_;
184 181
185 MOJO_DISALLOW_COPY_AND_ASSIGN(TransportData); 182 MOJO_DISALLOW_COPY_AND_ASSIGN(TransportData);
186 }; 183 };
187 184
188 } // namespace system 185 } // namespace system
189 } // namespace mojo 186 } // namespace mojo
190 187
191 #endif // MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ 188 #endif // MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698