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

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

Issue 216893005: Mojo: Move the handle table details out of CoreImpl into its own class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile assert Created 6 years, 8 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/mojo.gyp ('k') | mojo/system/core_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CORE_IMPL_H_ 5 #ifndef MOJO_SYSTEM_CORE_IMPL_H_
6 #define MOJO_SYSTEM_CORE_IMPL_H_ 6 #define MOJO_SYSTEM_CORE_IMPL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
13 #include "mojo/public/system/core_private.h" 12 #include "mojo/public/system/core_private.h"
13 #include "mojo/system/handle_table.h"
14 #include "mojo/system/system_impl_export.h" 14 #include "mojo/system/system_impl_export.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace system { 17 namespace system {
18 18
19 class CoreImpl;
20 class Dispatcher; 19 class Dispatcher;
21 20
22 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here
23 // so it can be friended.
24 namespace internal {
25 bool ShutdownCheckNoLeaks(CoreImpl*);
26 }
27
28 // |CoreImpl| is a singleton object that implements the Mojo system calls. All 21 // |CoreImpl| is a singleton object that implements the Mojo system calls. All
29 // public methods are thread-safe. 22 // public methods are thread-safe.
30 class MOJO_SYSTEM_IMPL_EXPORT CoreImpl : public Core { 23 class MOJO_SYSTEM_IMPL_EXPORT CoreImpl : public Core {
31 public: 24 public:
32 // These methods are only to be used by via the embedder API. 25 // These methods are only to be used by via the embedder API.
33 CoreImpl(); 26 CoreImpl();
34 virtual ~CoreImpl(); 27 virtual ~CoreImpl();
35 MojoHandle AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher); 28 MojoHandle AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher);
36 29
37 // |CorePrivate| implementation: 30 // |CorePrivate| implementation:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 117
125 scoped_refptr<Dispatcher> dispatcher; 118 scoped_refptr<Dispatcher> dispatcher;
126 bool busy; 119 bool busy;
127 }; 120 };
128 typedef base::hash_map<MojoHandle, HandleTableEntry> HandleTableMap; 121 typedef base::hash_map<MojoHandle, HandleTableEntry> HandleTableMap;
129 122
130 // Looks up the dispatcher for the given handle. Returns null if the handle is 123 // Looks up the dispatcher for the given handle. Returns null if the handle is
131 // invalid. 124 // invalid.
132 scoped_refptr<Dispatcher> GetDispatcher(MojoHandle handle); 125 scoped_refptr<Dispatcher> GetDispatcher(MojoHandle handle);
133 126
134 // Assigns a new handle for the given dispatcher; returns
135 // |MOJO_HANDLE_INVALID| on failure (due to hitting resource limits) or if
136 // |dispatcher| is null. Must be called under |handle_table_lock_|.
137 MojoHandle AddDispatcherNoLock(const scoped_refptr<Dispatcher>& dispatcher);
138
139 // Internal implementation of |Wait()| and |WaitMany()|; doesn't do basic 127 // Internal implementation of |Wait()| and |WaitMany()|; doesn't do basic
140 // validation of arguments. 128 // validation of arguments.
141 MojoResult WaitManyInternal(const MojoHandle* handles, 129 MojoResult WaitManyInternal(const MojoHandle* handles,
142 const MojoWaitFlags* flags, 130 const MojoWaitFlags* flags,
143 uint32_t num_handles, 131 uint32_t num_handles,
144 MojoDeadline deadline); 132 MojoDeadline deadline);
145 133
146 // --------------------------------------------------------------------------- 134 // ---------------------------------------------------------------------------
147 135
148 // TODO(vtl): |handle_table_lock_| should be a reader-writer lock (if only we 136 // TODO(vtl): |handle_table_lock_| should be a reader-writer lock (if only we
149 // had them). 137 // had them).
150 base::Lock handle_table_lock_; // Protects the immediately-following members. 138 base::Lock handle_table_lock_; // Protects |handle_table_|.
151 HandleTableMap handle_table_; 139 HandleTable handle_table_;
152 MojoHandle next_handle_; // Invariant: never |MOJO_HANDLE_INVALID|.
153 140
154 // --------------------------------------------------------------------------- 141 // ---------------------------------------------------------------------------
155 142
156 DISALLOW_COPY_AND_ASSIGN(CoreImpl); 143 DISALLOW_COPY_AND_ASSIGN(CoreImpl);
157 }; 144 };
158 145
159 } // namespace system 146 } // namespace system
160 } // namespace mojo 147 } // namespace mojo
161 148
162 #endif // MOJO_SYSTEM_CORE_IMPL_H_ 149 #endif // MOJO_SYSTEM_CORE_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/mojo.gyp ('k') | mojo/system/core_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698