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

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

Issue 27060003: Mojo: Abstract out the endpoints of MessagePipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 2 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
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_MESSAGE_PIPE_H_ 5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_H_
6 #define MOJO_SYSTEM_MESSAGE_PIPE_H_ 6 #define MOJO_SYSTEM_MESSAGE_PIPE_H_
7 7
8 #include <deque>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
14 #include "mojo/public/system/core.h" 12 #include "mojo/public/system/core.h"
15 #include "mojo/public/system/system_export.h" 13 #include "mojo/public/system/system_export.h"
16 #include "mojo/system/waiter_list.h"
17 14
18 namespace mojo { 15 namespace mojo {
19 namespace system { 16 namespace system {
20 17
21 class MessageInTransit; 18 class MessagePipeEndpoint;
22 class Waiter; 19 class Waiter;
23 20
24 // |MessagePipe| is the secondary object implementing a message pipe (see the 21 // |MessagePipe| is the secondary object implementing a message pipe (see the
25 // explanatory comment in core_impl.cc), and is jointly owned by the two 22 // explanatory comment in core_impl.cc), and is jointly owned by the two
26 // dispatchers passed in to the constructor. This class is thread-safe. 23 // dispatchers passed in to the constructor. This class is thread-safe.
27 class MOJO_SYSTEM_EXPORT MessagePipe : 24 class MOJO_SYSTEM_EXPORT MessagePipe :
28 public base::RefCountedThreadSafe<MessagePipe> { 25 public base::RefCountedThreadSafe<MessagePipe> {
29 public: 26 public:
30 MessagePipe(); 27 MessagePipe();
31 28
(...skipping 16 matching lines...) Expand all
48 MojoResult AddWaiter(unsigned port, 45 MojoResult AddWaiter(unsigned port,
49 Waiter* waiter, 46 Waiter* waiter,
50 MojoWaitFlags flags, 47 MojoWaitFlags flags,
51 MojoResult wake_result); 48 MojoResult wake_result);
52 void RemoveWaiter(unsigned port, Waiter* waiter); 49 void RemoveWaiter(unsigned port, Waiter* waiter);
53 50
54 private: 51 private:
55 friend class base::RefCountedThreadSafe<MessagePipe>; 52 friend class base::RefCountedThreadSafe<MessagePipe>;
56 virtual ~MessagePipe(); 53 virtual ~MessagePipe();
57 54
58 MojoWaitFlags SatisfiedFlagsNoLock(unsigned port);
59 MojoWaitFlags SatisfiableFlagsNoLock(unsigned port);
60
61 base::Lock lock_; // Protects the following members. 55 base::Lock lock_; // Protects the following members.
62 bool is_open_[2]; 56 scoped_ptr<MessagePipeEndpoint> endpoints_[2];
63 // These are *incoming* queues for their corresponding ports. It owns its
64 // contents.
65 // TODO(vtl): When possible (with C++11), convert the plain pointers to
66 // scoped_ptr/unique_ptr.
67 std::deque<MessageInTransit*> message_queues_[2];
68 WaiterList waiter_lists_[2];
69 57
70 DISALLOW_COPY_AND_ASSIGN(MessagePipe); 58 DISALLOW_COPY_AND_ASSIGN(MessagePipe);
71 }; 59 };
72 60
73 } // namespace system 61 } // namespace system
74 } // namespace mojo 62 } // namespace mojo
75 63
76 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ 64 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698