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

Side by Side Diff: mojo/system/handle_table.h

Issue 262093003: Mojo: Add/use |typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/dispatcher.cc ('k') | mojo/system/handle_table.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 #ifndef MOJO_SYSTEM_HANDLE_TABLE_H_ 5 #ifndef MOJO_SYSTEM_HANDLE_TABLE_H_
6 #define MOJO_SYSTEM_HANDLE_TABLE_H_ 6 #define MOJO_SYSTEM_HANDLE_TABLE_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "mojo/public/c/system/core.h" 14 #include "mojo/public/c/system/core.h"
15 #include "mojo/system/system_impl_export.h" 15 #include "mojo/system/system_impl_export.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 namespace system { 18 namespace system {
19 19
20 class Core; 20 class Core;
21 class Dispatcher; 21 class Dispatcher;
22 class DispatcherTransport; 22 class DispatcherTransport;
23 23
24 typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector;
25
24 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here 26 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here
25 // so it can be friended. 27 // so it can be friended.
26 namespace internal { 28 namespace internal {
27 bool ShutdownCheckNoLeaks(Core*); 29 bool ShutdownCheckNoLeaks(Core*);
28 } 30 }
29 31
30 // This class provides the (global) handle table (owned by |Core|), which maps 32 // This class provides the (global) handle table (owned by |Core|), which maps
31 // (valid) |MojoHandle|s to |Dispatcher|s. This is abstracted so that, e.g., 33 // (valid) |MojoHandle|s to |Dispatcher|s. This is abstracted so that, e.g.,
32 // caching may be added. 34 // caching may be added.
33 // 35 //
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 std::pair<MojoHandle, MojoHandle> AddDispatcherPair( 69 std::pair<MojoHandle, MojoHandle> AddDispatcherPair(
68 const scoped_refptr<Dispatcher>& dispatcher0, 70 const scoped_refptr<Dispatcher>& dispatcher0,
69 const scoped_refptr<Dispatcher>& dispatcher1); 71 const scoped_refptr<Dispatcher>& dispatcher1);
70 72
71 // Adds the given vector of dispatchers (of size at most 73 // Adds the given vector of dispatchers (of size at most
72 // |kMaxMessageNumHandles|). |handles| must point to an array of size at least 74 // |kMaxMessageNumHandles|). |handles| must point to an array of size at least
73 // |dispatchers.size()|. Unlike the other |AddDispatcher...()| functions, some 75 // |dispatchers.size()|. Unlike the other |AddDispatcher...()| functions, some
74 // of the dispatchers may be invalid (null). Returns true on success and false 76 // of the dispatchers may be invalid (null). Returns true on success and false
75 // on failure (if the handle table is full), in which case it leaves 77 // on failure (if the handle table is full), in which case it leaves
76 // |handles[...]| untouched (and all dispatchers unadded). 78 // |handles[...]| untouched (and all dispatchers unadded).
77 bool AddDispatcherVector( 79 bool AddDispatcherVector(const DispatcherVector& dispatchers,
78 const std::vector<scoped_refptr<Dispatcher> >& dispatchers, 80 MojoHandle* handles);
79 MojoHandle* handles);
80 81
81 // Tries to mark the given handles as busy and start transport on them (i.e., 82 // Tries to mark the given handles as busy and start transport on them (i.e.,
82 // take their dispatcher locks); |transports| must be sized to contain 83 // take their dispatcher locks); |transports| must be sized to contain
83 // |num_handles| elements. On failure, returns them to their original 84 // |num_handles| elements. On failure, returns them to their original
84 // (non-busy, unlocked state). 85 // (non-busy, unlocked state).
85 MojoResult MarkBusyAndStartTransport( 86 MojoResult MarkBusyAndStartTransport(
86 MojoHandle disallowed_handle, 87 MojoHandle disallowed_handle,
87 const MojoHandle* handles, 88 const MojoHandle* handles,
88 uint32_t num_handles, 89 uint32_t num_handles,
89 std::vector<DispatcherTransport>* transports); 90 std::vector<DispatcherTransport>* transports);
(...skipping 27 matching lines...) Expand all
117 HandleToEntryMap handle_to_entry_map_; 118 HandleToEntryMap handle_to_entry_map_;
118 MojoHandle next_handle_; // Invariant: never |MOJO_HANDLE_INVALID|. 119 MojoHandle next_handle_; // Invariant: never |MOJO_HANDLE_INVALID|.
119 120
120 DISALLOW_COPY_AND_ASSIGN(HandleTable); 121 DISALLOW_COPY_AND_ASSIGN(HandleTable);
121 }; 122 };
122 123
123 } // namespace system 124 } // namespace system
124 } // namespace mojo 125 } // namespace mojo
125 126
126 #endif // MOJO_SYSTEM_HANDLE_TABLE_H_ 127 #endif // MOJO_SYSTEM_HANDLE_TABLE_H_
OLDNEW
« no previous file with comments | « mojo/system/dispatcher.cc ('k') | mojo/system/handle_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698