| OLD | NEW |
| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 HandleTable::HandleTable(size_t max_handle_table_size) | 29 HandleTable::HandleTable(size_t max_handle_table_size) |
| 30 : max_handle_table_size_(max_handle_table_size), | 30 : max_handle_table_size_(max_handle_table_size), |
| 31 next_handle_value_(MOJO_HANDLE_INVALID + 1) {} | 31 next_handle_value_(MOJO_HANDLE_INVALID + 1) {} |
| 32 | 32 |
| 33 HandleTable::~HandleTable() { | 33 HandleTable::~HandleTable() { |
| 34 // This should usually not be reached (the only instance should be owned by | 34 // This should usually not be reached (the only instance should be owned by |
| 35 // the singleton |Core|, which lives forever), except in tests. | 35 // the singleton |Core|, which lives forever), except in tests. |
| 36 } | 36 } |
| 37 | 37 |
| 38 MojoResult HandleTable::GetDispatcher(MojoHandle handle_value, | 38 MojoResult HandleTable::GetHandle(MojoHandle handle_value, Handle* handle) { |
| 39 RefPtr<Dispatcher>* dispatcher) { | |
| 40 DCHECK_NE(handle_value, MOJO_HANDLE_INVALID); | 39 DCHECK_NE(handle_value, MOJO_HANDLE_INVALID); |
| 41 DCHECK(dispatcher); | 40 DCHECK(handle); |
| 42 | 41 |
| 43 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); | 42 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); |
| 44 if (it == handle_to_entry_map_.end()) | 43 if (it == handle_to_entry_map_.end()) |
| 45 return MOJO_RESULT_INVALID_ARGUMENT; | 44 return MOJO_RESULT_INVALID_ARGUMENT; |
| 46 if (it->second.busy) | 45 if (it->second.busy) |
| 47 return MOJO_RESULT_BUSY; | 46 return MOJO_RESULT_BUSY; |
| 48 *dispatcher = it->second.handle.dispatcher; | 47 *handle = it->second.handle; |
| 49 | 48 |
| 50 return MOJO_RESULT_OK; | 49 return MOJO_RESULT_OK; |
| 51 } | 50 } |
| 52 | 51 |
| 53 MojoResult HandleTable::GetAndRemoveDispatcher(MojoHandle handle_value, | 52 MojoResult HandleTable::GetAndRemoveDispatcher(MojoHandle handle_value, |
| 54 RefPtr<Dispatcher>* dispatcher) { | 53 RefPtr<Dispatcher>* dispatcher) { |
| 55 DCHECK_NE(handle_value, MOJO_HANDLE_INVALID); | 54 DCHECK_NE(handle_value, MOJO_HANDLE_INVALID); |
| 56 DCHECK(dispatcher); | 55 DCHECK(dispatcher); |
| 57 | 56 |
| 58 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); | 57 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 for (uint32_t i = 0; i < num_handles; i++) { | 266 for (uint32_t i = 0; i < num_handles; i++) { |
| 268 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); | 267 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); |
| 269 DCHECK(it != handle_to_entry_map_.end()); | 268 DCHECK(it != handle_to_entry_map_.end()); |
| 270 DCHECK(it->second.busy); | 269 DCHECK(it->second.busy); |
| 271 it->second.busy = false; | 270 it->second.busy = false; |
| 272 } | 271 } |
| 273 } | 272 } |
| 274 | 273 |
| 275 } // namespace system | 274 } // namespace system |
| 276 } // namespace mojo | 275 } // namespace mojo |
| OLD | NEW |