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

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

Issue 1949153002: EDK: Add HandleTable::AddHandleVector(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 months 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/handle_table.h ('k') | mojo/edk/system/handle_table_unittest.cc » ('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 90da427fed3afc9b588c04fd62b84a271b2f42ac..7bff6f3ce4ae27765253ee6ba5ba3004f9526ddd 100644
--- a/mojo/edk/system/handle_table.cc
+++ b/mojo/edk/system/handle_table.cc
@@ -83,6 +83,33 @@ std::pair<MojoHandle, MojoHandle> HandleTable::AddHandlePair(Handle&& handle0,
: std::make_pair(MOJO_HANDLE_INVALID, MOJO_HANDLE_INVALID);
}
+bool HandleTable::AddHandleVector(HandleVector* handles,
+ MojoHandle* handle_values) {
+ size_t max_message_num_handles = GetConfiguration().max_message_num_handles;
+
+ DCHECK(handles);
+ DCHECK_LE(handles->size(), max_message_num_handles);
+ DCHECK(handle_values);
+ 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() + handles->size() > max_handle_table_size_)
+ return false;
+
+ for (size_t i = 0; i < handles->size(); i++) {
+ if (handles->at(i)) {
+ handle_values[i] = AddHandleNoSizeCheck(std::move(handles->at(i)));
+ } else {
+ LOG(WARNING) << "Invalid dispatcher at index " << i;
+ handle_values[i] = MOJO_HANDLE_INVALID;
+ }
+ }
+ return true;
+}
+
+// TODO(vtl): Delete this.
bool HandleTable::AddDispatcherVector(const DispatcherVector& dispatchers,
MojoHandle* handles) {
size_t max_message_num_handles = GetConfiguration().max_message_num_handles;
« no previous file with comments | « mojo/edk/system/handle_table.h ('k') | mojo/edk/system/handle_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698