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

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

Issue 1947083003: EDK: Replace HandleTable::GetDispatcher() with GetHandle(). (Closed) Base URL: https://github.com/domokit/mojo.git@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 17 matching lines...) Expand all
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
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
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