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

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

Issue 136343004: Mojo: Add a "GetType()" to Dispatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/data_pipe_producer_dispatcher.cc ('k') | mojo/system/dispatcher_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 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_DISPATCHER_H_ 5 #ifndef MOJO_SYSTEM_DISPATCHER_H_
6 #define MOJO_SYSTEM_DISPATCHER_H_ 6 #define MOJO_SYSTEM_DISPATCHER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "mojo/public/system/core.h" 13 #include "mojo/public/system/core.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; 19 class CoreImpl;
20 class Waiter; 20 class Waiter;
21 21
22 // A |Dispatcher| implements Mojo primitives that are "attached" to a particular 22 // A |Dispatcher| implements Mojo primitives that are "attached" to a particular
23 // handle. This includes most (all?) primitives except for |MojoWait...()|. This 23 // handle. This includes most (all?) primitives except for |MojoWait...()|. This
24 // object is thread-safe, with its state being protected by a single lock 24 // object is thread-safe, with its state being protected by a single lock
25 // |lock_|, which is also made available to implementation subclasses (via the 25 // |lock_|, which is also made available to implementation subclasses (via the
26 // |lock()| method). 26 // |lock()| method).
27 class MOJO_SYSTEM_IMPL_EXPORT Dispatcher : 27 class MOJO_SYSTEM_IMPL_EXPORT Dispatcher :
28 public base::RefCountedThreadSafe<Dispatcher> { 28 public base::RefCountedThreadSafe<Dispatcher> {
29 public: 29 public:
30 enum Type {
31 kTypeUnknown = 0,
32 kTypeMessagePipe,
33 kTypeDataPipeProducer,
34 kTypeDataPipeConsumer
35 };
36 virtual Type GetType() = 0;
37
30 // These methods implement the various primitives named |Mojo...()|. These 38 // These methods implement the various primitives named |Mojo...()|. These
31 // take |lock_| and handle races with |Close()|. Then they call out to 39 // take |lock_| and handle races with |Close()|. Then they call out to
32 // subclasses' |...ImplNoLock()| methods (still under |lock_|), which actually 40 // subclasses' |...ImplNoLock()| methods (still under |lock_|), which actually
33 // implement the primitives. 41 // implement the primitives.
34 // NOTE(vtl): This puts a big lock around each dispatcher (i.e., handle), and 42 // NOTE(vtl): This puts a big lock around each dispatcher (i.e., handle), and
35 // prevents the various |...ImplNoLock()|s from releasing the lock as soon as 43 // prevents the various |...ImplNoLock()|s from releasing the lock as soon as
36 // possible. If this becomes an issue, we can rethink this. 44 // possible. If this becomes an issue, we can rethink this.
37 MojoResult Close(); 45 MojoResult Close();
38 // |dispatchers| may be non-null if and only if there are handles to be 46 // |dispatchers| may be non-null if and only if there are handles to be
39 // written, in which case this will be called with all the dispatchers' locks 47 // written, in which case this will be called with all the dispatchers' locks
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 mutable base::Lock lock_; 172 mutable base::Lock lock_;
165 bool is_closed_; 173 bool is_closed_;
166 174
167 DISALLOW_COPY_AND_ASSIGN(Dispatcher); 175 DISALLOW_COPY_AND_ASSIGN(Dispatcher);
168 }; 176 };
169 177
170 } // namespace system 178 } // namespace system
171 } // namespace mojo 179 } // namespace mojo
172 180
173 #endif // MOJO_SYSTEM_DISPATCHER_H_ 181 #endif // MOJO_SYSTEM_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/system/data_pipe_producer_dispatcher.cc ('k') | mojo/system/dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698