| Index: mojo/edk/system/transport_data.cc
|
| diff --git a/mojo/edk/system/transport_data.cc b/mojo/edk/system/transport_data.cc
|
| index 300b7313ffed881042f6f1e29471f556a40da3cc..774b74413a5cfbf6bf54cf689a772bfd11f4ab77 100644
|
| --- a/mojo/edk/system/transport_data.cc
|
| +++ b/mojo/edk/system/transport_data.cc
|
| @@ -9,7 +9,7 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/logging.h"
|
| #include "mojo/edk/system/channel.h"
|
| -#include "mojo/edk/system/configuration.h"
|
| +#include "mojo/edk/system/constants.h"
|
| #include "mojo/edk/system/message_in_transit.h"
|
|
|
| namespace mojo {
|
| @@ -32,20 +32,19 @@
|
| TransportData::kMaxSerializedDispatcherPlatformHandles;
|
|
|
| // static
|
| -size_t TransportData::GetMaxBufferSize() {
|
| - // In additional to the header, for each attached (Mojo) handle there'll be a
|
| - // handle table entry and serialized dispatcher data.
|
| - return sizeof(Header) +
|
| - GetConfiguration().max_message_num_handles *
|
| - (sizeof(HandleTableEntry) + kMaxSerializedDispatcherSize) +
|
| - GetMaxPlatformHandles() * kMaxSizePerPlatformHandle;
|
| -}
|
| -
|
| -// static
|
| -size_t TransportData::GetMaxPlatformHandles() {
|
| - return GetConfiguration().max_message_num_handles *
|
| - kMaxSerializedDispatcherPlatformHandles;
|
| -}
|
| +const size_t TransportData::kMaxPlatformHandles =
|
| + kMaxMessageNumHandles * kMaxSerializedDispatcherPlatformHandles;
|
| +
|
| +// In additional to the header, for each attached (Mojo) handle there'll be a
|
| +// handle table entry and serialized dispatcher data.
|
| +// Note: This definition must follow the one for |kMaxPlatformHandles|;
|
| +// otherwise, we get a static initializer with gcc (but not clang).
|
| +// static
|
| +const size_t TransportData::kMaxBufferSize =
|
| + sizeof(Header) +
|
| + kMaxMessageNumHandles *
|
| + (sizeof(HandleTableEntry) + kMaxSerializedDispatcherSize) +
|
| + kMaxPlatformHandles * kMaxSizePerPlatformHandle;
|
|
|
| struct TransportData::PrivateStructForCompileAsserts {
|
| static_assert(sizeof(Header) % MessageInTransit::kMessageAlignment == 0,
|
| @@ -91,11 +90,11 @@
|
|
|
| DCHECK_LE(max_size, kMaxSerializedDispatcherSize);
|
| estimated_size += MessageInTransit::RoundUpMessageAlignment(max_size);
|
| - DCHECK_LE(estimated_size, GetMaxBufferSize());
|
| + DCHECK_LE(estimated_size, kMaxBufferSize);
|
|
|
| DCHECK_LE(max_platform_handles, kMaxSerializedDispatcherPlatformHandles);
|
| estimated_num_platform_handles += max_platform_handles;
|
| - DCHECK_LE(estimated_num_platform_handles, GetMaxPlatformHandles());
|
| + DCHECK_LE(estimated_num_platform_handles, kMaxPlatformHandles);
|
|
|
| #if DCHECK_IS_ON
|
| all_max_sizes[i] = max_size;
|
| @@ -110,7 +109,7 @@
|
| DCHECK_LE(size_per_platform_handle, kMaxSizePerPlatformHandle);
|
| estimated_size += estimated_num_platform_handles * size_per_platform_handle;
|
| estimated_size = MessageInTransit::RoundUpMessageAlignment(estimated_size);
|
| - DCHECK_LE(estimated_size, GetMaxBufferSize());
|
| + DCHECK_LE(estimated_size, kMaxBufferSize);
|
| }
|
|
|
| buffer_.reset(static_cast<char*>(
|
| @@ -149,7 +148,10 @@
|
| void* destination = buffer_.get() + current_offset;
|
| size_t actual_size = 0;
|
| if (Dispatcher::TransportDataAccess::EndSerializeAndClose(
|
| - dispatcher, channel, destination, &actual_size,
|
| + dispatcher,
|
| + channel,
|
| + destination,
|
| + &actual_size,
|
| platform_handles_.get())) {
|
| handle_table[i].type = static_cast<int32_t>(dispatcher->GetType());
|
| handle_table[i].offset = static_cast<uint32_t>(current_offset);
|
| @@ -214,7 +216,7 @@
|
|
|
| // Always make sure that the buffer size is sane; if it's not, someone's
|
| // messing with us.
|
| - if (buffer_size < sizeof(Header) || buffer_size > GetMaxBufferSize() ||
|
| + if (buffer_size < sizeof(Header) || buffer_size > kMaxBufferSize ||
|
| buffer_size % MessageInTransit::kMessageAlignment != 0)
|
| return "Invalid message secondary buffer size";
|
|
|
| @@ -231,7 +233,7 @@
|
| #endif
|
|
|
| // Sanity-check |num_handles| (before multiplying it against anything).
|
| - if (num_handles > GetConfiguration().max_message_num_handles)
|
| + if (num_handles > kMaxMessageNumHandles)
|
| return "Message handle payload too large";
|
|
|
| if (buffer_size < sizeof(Header) + num_handles * sizeof(HandleTableEntry))
|
|
|