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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); | 42 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); |
43 if (it == handle_to_entry_map_.end()) | 43 if (it == handle_to_entry_map_.end()) |
44 return MOJO_RESULT_INVALID_ARGUMENT; | 44 return MOJO_RESULT_INVALID_ARGUMENT; |
45 if (it->second.busy) | 45 if (it->second.busy) |
46 return MOJO_RESULT_BUSY; | 46 return MOJO_RESULT_BUSY; |
47 *handle = it->second.handle; | 47 *handle = it->second.handle; |
48 | 48 |
49 return MOJO_RESULT_OK; | 49 return MOJO_RESULT_OK; |
50 } | 50 } |
51 | 51 |
52 MojoResult HandleTable::GetAndRemoveDispatcher(MojoHandle handle_value, | 52 MojoResult HandleTable::GetAndRemoveHandle(MojoHandle handle_value, |
53 RefPtr<Dispatcher>* dispatcher) { | 53 Handle* handle) { |
54 DCHECK_NE(handle_value, MOJO_HANDLE_INVALID); | 54 DCHECK_NE(handle_value, MOJO_HANDLE_INVALID); |
55 DCHECK(dispatcher); | 55 DCHECK(handle); |
56 | 56 |
57 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); | 57 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_value); |
58 if (it == handle_to_entry_map_.end()) | 58 if (it == handle_to_entry_map_.end()) |
59 return MOJO_RESULT_INVALID_ARGUMENT; | 59 return MOJO_RESULT_INVALID_ARGUMENT; |
60 if (it->second.busy) | 60 if (it->second.busy) |
61 return MOJO_RESULT_BUSY; | 61 return MOJO_RESULT_BUSY; |
62 *dispatcher = std::move(it->second.handle.dispatcher); | 62 *handle = std::move(it->second.handle); |
63 handle_to_entry_map_.erase(it); | 63 handle_to_entry_map_.erase(it); |
64 | 64 |
65 return MOJO_RESULT_OK; | 65 return MOJO_RESULT_OK; |
66 } | 66 } |
67 | 67 |
68 MojoHandle HandleTable::AddHandle(Handle&& handle) { | 68 MojoHandle HandleTable::AddHandle(Handle&& handle) { |
69 DCHECK(handle); | 69 DCHECK(handle); |
70 return (handle_to_entry_map_.size() < max_handle_table_size_) | 70 return (handle_to_entry_map_.size() < max_handle_table_size_) |
71 ? AddHandleNoSizeCheck(std::move(handle)) | 71 ? AddHandleNoSizeCheck(std::move(handle)) |
72 : MOJO_HANDLE_INVALID; | 72 : MOJO_HANDLE_INVALID; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 for (uint32_t i = 0; i < num_handles; i++) { | 266 for (uint32_t i = 0; i < num_handles; i++) { |
267 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); | 267 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); |
268 DCHECK(it != handle_to_entry_map_.end()); | 268 DCHECK(it != handle_to_entry_map_.end()); |
269 DCHECK(it->second.busy); | 269 DCHECK(it->second.busy); |
270 it->second.busy = false; | 270 it->second.busy = false; |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 } // namespace system | 274 } // namespace system |
275 } // namespace mojo | 275 } // namespace mojo |
OLD | NEW |