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

Side by Side Diff: mojo/edk/system/handle_table.cc

Issue 782693004: Update mojo sdk to rev f6c8ec07c01deebc13178d516225fd12695c3dc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hack mojo_system_impl gypi for android :| Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/edk/system/handle_table.h" 5 #include "mojo/edk/system/handle_table.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "mojo/edk/system/configuration.h" 10 #include "mojo/edk/system/configuration.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 DCHECK(handles); 84 DCHECK(handles);
85 DCHECK_LT( 85 DCHECK_LT(
86 static_cast<uint64_t>(max_handle_table_size) + max_message_num_handles, 86 static_cast<uint64_t>(max_handle_table_size) + max_message_num_handles,
87 std::numeric_limits<size_t>::max()) 87 std::numeric_limits<size_t>::max())
88 << "Addition may overflow"; 88 << "Addition may overflow";
89 89
90 if (handle_to_entry_map_.size() + dispatchers.size() > max_handle_table_size) 90 if (handle_to_entry_map_.size() + dispatchers.size() > max_handle_table_size)
91 return false; 91 return false;
92 92
93 for (size_t i = 0; i < dispatchers.size(); i++) { 93 for (size_t i = 0; i < dispatchers.size(); i++) {
94 if (dispatchers[i].get()) { 94 if (dispatchers[i]) {
95 handles[i] = AddDispatcherNoSizeCheck(dispatchers[i]); 95 handles[i] = AddDispatcherNoSizeCheck(dispatchers[i]);
96 } else { 96 } else {
97 LOG(WARNING) << "Invalid dispatcher at index " << i; 97 LOG(WARNING) << "Invalid dispatcher at index " << i;
98 handles[i] = MOJO_HANDLE_INVALID; 98 handles[i] = MOJO_HANDLE_INVALID;
99 } 99 }
100 } 100 }
101 return true; 101 return true;
102 } 102 }
103 103
104 MojoResult HandleTable::MarkBusyAndStartTransport( 104 MojoResult HandleTable::MarkBusyAndStartTransport(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 (*transports)[j].End(); 181 (*transports)[j].End();
182 } 182 }
183 return error_result; 183 return error_result;
184 } 184 }
185 185
186 return MOJO_RESULT_OK; 186 return MOJO_RESULT_OK;
187 } 187 }
188 188
189 MojoHandle HandleTable::AddDispatcherNoSizeCheck( 189 MojoHandle HandleTable::AddDispatcherNoSizeCheck(
190 const scoped_refptr<Dispatcher>& dispatcher) { 190 const scoped_refptr<Dispatcher>& dispatcher) {
191 DCHECK(dispatcher.get()); 191 DCHECK(dispatcher);
192 DCHECK_LT(handle_to_entry_map_.size(), 192 DCHECK_LT(handle_to_entry_map_.size(),
193 GetConfiguration().max_handle_table_size); 193 GetConfiguration().max_handle_table_size);
194 DCHECK_NE(next_handle_, MOJO_HANDLE_INVALID); 194 DCHECK_NE(next_handle_, MOJO_HANDLE_INVALID);
195 195
196 // TODO(vtl): Maybe we want to do something different/smarter. (Or maybe try 196 // TODO(vtl): Maybe we want to do something different/smarter. (Or maybe try
197 // assigning randomly?) 197 // assigning randomly?)
198 while (handle_to_entry_map_.find(next_handle_) != 198 while (handle_to_entry_map_.find(next_handle_) !=
199 handle_to_entry_map_.end()) { 199 handle_to_entry_map_.end()) {
200 next_handle_++; 200 next_handle_++;
201 if (next_handle_ == MOJO_HANDLE_INVALID) 201 if (next_handle_ == MOJO_HANDLE_INVALID)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 for (uint32_t i = 0; i < num_handles; i++) { 234 for (uint32_t i = 0; i < num_handles; i++) {
235 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handles[i]); 235 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handles[i]);
236 DCHECK(it != handle_to_entry_map_.end()); 236 DCHECK(it != handle_to_entry_map_.end());
237 DCHECK(it->second.busy); 237 DCHECK(it->second.busy);
238 it->second.busy = false; 238 it->second.busy = false;
239 } 239 }
240 } 240 }
241 241
242 } // namespace system 242 } // namespace system
243 } // namespace mojo 243 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698