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

Unified Diff: mojo/edk/system/handle_table.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/entrypoints.cc ('k') | mojo/edk/system/local_data_pipe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/handle_table.cc
diff --git a/mojo/edk/system/handle_table.cc b/mojo/edk/system/handle_table.cc
index 9c0123069410aff01445caa3c933be15c2380071..05d526039696804dcf3dbcaf8585c6a4395d24b7 100644
--- a/mojo/edk/system/handle_table.cc
+++ b/mojo/edk/system/handle_table.cc
@@ -4,9 +4,10 @@
#include "mojo/edk/system/handle_table.h"
+#include <limits>
#include "base/logging.h"
#include "base/macros.h"
-#include "mojo/edk/system/constants.h"
+#include "mojo/edk/system/configuration.h"
#include "mojo/edk/system/dispatcher.h"
namespace mojo {
@@ -59,7 +60,7 @@ MojoResult HandleTable::GetAndRemoveDispatcher(
MojoHandle HandleTable::AddDispatcher(
const scoped_refptr<Dispatcher>& dispatcher) {
- if (handle_to_entry_map_.size() >= kMaxHandleTableSize)
+ if (handle_to_entry_map_.size() >= GetConfiguration().max_handle_table_size)
return MOJO_HANDLE_INVALID;
return AddDispatcherNoSizeCheck(dispatcher);
}
@@ -67,7 +68,8 @@ MojoHandle HandleTable::AddDispatcher(
std::pair<MojoHandle, MojoHandle> HandleTable::AddDispatcherPair(
const scoped_refptr<Dispatcher>& dispatcher0,
const scoped_refptr<Dispatcher>& dispatcher1) {
- if (handle_to_entry_map_.size() + 1 >= kMaxHandleTableSize)
+ if (handle_to_entry_map_.size() + 1 >=
+ GetConfiguration().max_handle_table_size)
return std::make_pair(MOJO_HANDLE_INVALID, MOJO_HANDLE_INVALID);
return std::make_pair(AddDispatcherNoSizeCheck(dispatcher0),
AddDispatcherNoSizeCheck(dispatcher1));
@@ -75,17 +77,17 @@ std::pair<MojoHandle, MojoHandle> HandleTable::AddDispatcherPair(
bool HandleTable::AddDispatcherVector(const DispatcherVector& dispatchers,
MojoHandle* handles) {
- DCHECK_LE(dispatchers.size(), kMaxMessageNumHandles);
+ size_t max_message_num_handles = GetConfiguration().max_message_num_handles;
+ size_t max_handle_table_size = GetConfiguration().max_handle_table_size;
+
+ DCHECK_LE(dispatchers.size(), max_message_num_handles);
DCHECK(handles);
- // TODO(vtl): |std::numeric_limits<size_t>::max()| isn't a compile-time
- // expression in C++03.
- static_assert(
- static_cast<uint64_t>(kMaxHandleTableSize) + kMaxMessageNumHandles <
- (sizeof(size_t) == 8 ? kuint64max
- : static_cast<uint64_t>(kuint32max)),
- "Addition may overflow");
-
- if (handle_to_entry_map_.size() + dispatchers.size() > kMaxHandleTableSize)
+ DCHECK_LT(
+ static_cast<uint64_t>(max_handle_table_size) + max_message_num_handles,
+ std::numeric_limits<size_t>::max())
+ << "Addition may overflow";
+
+ if (handle_to_entry_map_.size() + dispatchers.size() > max_handle_table_size)
return false;
for (size_t i = 0; i < dispatchers.size(); i++) {
@@ -106,7 +108,7 @@ MojoResult HandleTable::MarkBusyAndStartTransport(
std::vector<DispatcherTransport>* transports) {
DCHECK_NE(disallowed_handle, MOJO_HANDLE_INVALID);
DCHECK(handles);
- DCHECK_LE(num_handles, kMaxMessageNumHandles);
+ DCHECK_LE(num_handles, GetConfiguration().max_message_num_handles);
DCHECK(transports);
DCHECK_EQ(transports->size(), num_handles);
@@ -187,7 +189,8 @@ MojoResult HandleTable::MarkBusyAndStartTransport(
MojoHandle HandleTable::AddDispatcherNoSizeCheck(
const scoped_refptr<Dispatcher>& dispatcher) {
DCHECK(dispatcher.get());
- DCHECK_LT(handle_to_entry_map_.size(), kMaxHandleTableSize);
+ DCHECK_LT(handle_to_entry_map_.size(),
+ GetConfiguration().max_handle_table_size);
DCHECK_NE(next_handle_, MOJO_HANDLE_INVALID);
// TODO(vtl): Maybe we want to do something different/smarter. (Or maybe try
@@ -212,7 +215,7 @@ MojoHandle HandleTable::AddDispatcherNoSizeCheck(
void HandleTable::RemoveBusyHandles(const MojoHandle* handles,
uint32_t num_handles) {
DCHECK(handles);
- DCHECK_LE(num_handles, kMaxMessageNumHandles);
+ DCHECK_LE(num_handles, GetConfiguration().max_message_num_handles);
for (uint32_t i = 0; i < num_handles; i++) {
HandleToEntryMap::iterator it = handle_to_entry_map_.find(handles[i]);
@@ -226,7 +229,7 @@ void HandleTable::RemoveBusyHandles(const MojoHandle* handles,
void HandleTable::RestoreBusyHandles(const MojoHandle* handles,
uint32_t num_handles) {
DCHECK(handles);
- DCHECK_LE(num_handles, kMaxMessageNumHandles);
+ DCHECK_LE(num_handles, GetConfiguration().max_message_num_handles);
for (uint32_t i = 0; i < num_handles; i++) {
HandleToEntryMap::iterator it = handle_to_entry_map_.find(handles[i]);
« no previous file with comments | « mojo/edk/system/entrypoints.cc ('k') | mojo/edk/system/local_data_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698