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 #include "mojo/edk/system/transport_data.h" | 5 #include "mojo/edk/system/transport_data.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 // (|{Channel,RawChannel}::GetSerializedPlatformHandleSize()| should always | 23 // (|{Channel,RawChannel}::GetSerializedPlatformHandleSize()| should always |
24 // return a value which is at most this. This is only used to calculate | 24 // return a value which is at most this. This is only used to calculate |
25 // |TransportData::kMaxBufferSize|. This value should be a multiple of the | 25 // |TransportData::kMaxBufferSize|. This value should be a multiple of the |
26 // alignment in order to simplify calculations, even though the actual amount of | 26 // alignment in order to simplify calculations, even though the actual amount of |
27 // space needed need not be a multiple of the alignment. | 27 // space needed need not be a multiple of the alignment. |
28 const size_t kMaxSizePerPlatformHandle = 8; | 28 const size_t kMaxSizePerPlatformHandle = 8; |
29 static_assert(kMaxSizePerPlatformHandle % MessageInTransit::kMessageAlignment == | 29 static_assert(kMaxSizePerPlatformHandle % MessageInTransit::kMessageAlignment == |
30 0, | 30 0, |
31 "kMaxSizePerPlatformHandle not a multiple of alignment"); | 31 "kMaxSizePerPlatformHandle not a multiple of alignment"); |
32 | 32 |
33 MOJO_STATIC_CONST_MEMBER_DEFINITION const size_t | 33 const size_t TransportData::kMaxSerializedDispatcherSize; |
34 TransportData::kMaxSerializedDispatcherSize; | 34 const size_t TransportData::kMaxSerializedDispatcherPlatformHandles; |
35 MOJO_STATIC_CONST_MEMBER_DEFINITION const size_t | |
36 TransportData::kMaxSerializedDispatcherPlatformHandles; | |
37 | 35 |
38 // static | 36 // static |
39 size_t TransportData::GetMaxBufferSize() { | 37 size_t TransportData::GetMaxBufferSize() { |
40 // In additional to the header, for each attached (Mojo) handle there'll be a | 38 // In additional to the header, for each attached (Mojo) handle there'll be a |
41 // handle table entry and serialized dispatcher data. | 39 // handle table entry and serialized dispatcher data. |
42 return sizeof(Header) + | 40 return sizeof(Header) + |
43 GetConfiguration().max_message_num_handles * | 41 GetConfiguration().max_message_num_handles * |
44 (sizeof(HandleTableEntry) + kMaxSerializedDispatcherSize) + | 42 (sizeof(HandleTableEntry) + kMaxSerializedDispatcherSize) + |
45 GetMaxPlatformHandles() * kMaxSizePerPlatformHandle; | 43 GetMaxPlatformHandles() * kMaxSizePerPlatformHandle; |
46 } | 44 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 const void* source = static_cast<const char*>(buffer) + offset; | 337 const void* source = static_cast<const char*>(buffer) + offset; |
340 (*dispatchers)[i] = Dispatcher::TransportDataAccess::Deserialize( | 338 (*dispatchers)[i] = Dispatcher::TransportDataAccess::Deserialize( |
341 channel, handle_table[i].type, source, size, platform_handles.get()); | 339 channel, handle_table[i].type, source, size, platform_handles.get()); |
342 } | 340 } |
343 | 341 |
344 return dispatchers; | 342 return dispatchers; |
345 } | 343 } |
346 | 344 |
347 } // namespace system | 345 } // namespace system |
348 } // namespace mojo | 346 } // namespace mojo |
OLD | NEW |