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

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

Issue 728043002: Revert of Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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))
« 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