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

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

Issue 1949283002: EDK: Replace HandleTable::GetAndRemoveDispatcher() with GetAndRemoveHandle(). (Closed) Base URL: https://github.com/domokit/mojo.git@work789_edk_handle_13.3-x-work788_edk_handle_13.2
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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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
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
OLDNEW
« 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