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

Unified Diff: mojo/edk/system/transport_data.cc

Issue 728133002: Update mojo sdk to rev e01f9a49449381a5eb430c1fd88bf2cae73ec35a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + ios gyp fixes Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/transport_data.h ('k') | mojo/edk/system/waiter_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/transport_data.cc
diff --git a/mojo/edk/system/transport_data.cc b/mojo/edk/system/transport_data.cc
index 774b74413a5cfbf6bf54cf689a772bfd11f4ab77..300b7313ffed881042f6f1e29471f556a40da3cc 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/constants.h"
+#include "mojo/edk/system/configuration.h"
#include "mojo/edk/system/message_in_transit.h"
namespace mojo {
@@ -32,19 +32,20 @@ STATIC_CONST_MEMBER_DEFINITION const size_t
TransportData::kMaxSerializedDispatcherPlatformHandles;
// static
-const size_t TransportData::kMaxPlatformHandles =
- kMaxMessageNumHandles * kMaxSerializedDispatcherPlatformHandles;
+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;
+}
-// 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;
+size_t TransportData::GetMaxPlatformHandles() {
+ return GetConfiguration().max_message_num_handles *
+ kMaxSerializedDispatcherPlatformHandles;
+}
struct TransportData::PrivateStructForCompileAsserts {
static_assert(sizeof(Header) % MessageInTransit::kMessageAlignment == 0,
@@ -90,11 +91,11 @@ TransportData::TransportData(scoped_ptr<DispatcherVector> dispatchers,
DCHECK_LE(max_size, kMaxSerializedDispatcherSize);
estimated_size += MessageInTransit::RoundUpMessageAlignment(max_size);
- DCHECK_LE(estimated_size, kMaxBufferSize);
+ DCHECK_LE(estimated_size, GetMaxBufferSize());
DCHECK_LE(max_platform_handles, kMaxSerializedDispatcherPlatformHandles);
estimated_num_platform_handles += max_platform_handles;
- DCHECK_LE(estimated_num_platform_handles, kMaxPlatformHandles);
+ DCHECK_LE(estimated_num_platform_handles, GetMaxPlatformHandles());
#if DCHECK_IS_ON
all_max_sizes[i] = max_size;
@@ -109,7 +110,7 @@ TransportData::TransportData(scoped_ptr<DispatcherVector> dispatchers,
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, kMaxBufferSize);
+ DCHECK_LE(estimated_size, GetMaxBufferSize());
}
buffer_.reset(static_cast<char*>(
@@ -148,10 +149,7 @@ TransportData::TransportData(scoped_ptr<DispatcherVector> dispatchers,
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);
@@ -216,7 +214,7 @@ const char* TransportData::ValidateBuffer(
// 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 > kMaxBufferSize ||
+ if (buffer_size < sizeof(Header) || buffer_size > GetMaxBufferSize() ||
buffer_size % MessageInTransit::kMessageAlignment != 0)
return "Invalid message secondary buffer size";
@@ -233,7 +231,7 @@ const char* TransportData::ValidateBuffer(
#endif
// Sanity-check |num_handles| (before multiplying it against anything).
- if (num_handles > kMaxMessageNumHandles)
+ if (num_handles > GetConfiguration().max_message_num_handles)
return "Message handle payload too large";
if (buffer_size < sizeof(Header) + num_handles * sizeof(HandleTableEntry))
« no previous file with comments | « mojo/edk/system/transport_data.h ('k') | mojo/edk/system/waiter_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698