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

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

Issue 68303007: Mojo: More plumbing required to transfer handles over MessagePipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « no previous file | mojo/system/local_message_pipe_endpoint.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_LOCAL_MESSAGE_PIPE_ENDPOINT_H_ 5 #ifndef MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_
6 #define MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_ 6 #define MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "mojo/public/system/core.h" 13 #include "mojo/public/system/core.h"
13 #include "mojo/public/system/system_export.h" 14 #include "mojo/public/system/system_export.h"
14 #include "mojo/system/message_pipe_endpoint.h" 15 #include "mojo/system/message_pipe_endpoint.h"
15 #include "mojo/system/waiter_list.h" 16 #include "mojo/system/waiter_list.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace system { 19 namespace system {
19 20
20 class MOJO_SYSTEM_EXPORT LocalMessagePipeEndpoint : public MessagePipeEndpoint { 21 class MOJO_SYSTEM_EXPORT LocalMessagePipeEndpoint : public MessagePipeEndpoint {
21 public: 22 public:
22 LocalMessagePipeEndpoint(); 23 LocalMessagePipeEndpoint();
23 virtual ~LocalMessagePipeEndpoint(); 24 virtual ~LocalMessagePipeEndpoint();
24 25
25 // |MessagePipeEndpoint| implementation: 26 // |MessagePipeEndpoint| implementation:
26 virtual void Close() OVERRIDE; 27 virtual void Close() OVERRIDE;
27 virtual bool OnPeerClose() OVERRIDE; 28 virtual bool OnPeerClose() OVERRIDE;
28 virtual MojoResult EnqueueMessage( 29 virtual MojoResult CanEnqueueMessage(
30 const MessageInTransit* message,
31 const std::vector<Dispatcher*>* dispatchers) OVERRIDE;
32 virtual void EnqueueMessage(
29 MessageInTransit* message, 33 MessageInTransit* message,
30 const std::vector<Dispatcher*>* dispatchers) OVERRIDE; 34 std::vector<scoped_refptr<Dispatcher> >* dispatchers) OVERRIDE;
31 35
32 // There's a dispatcher for |LocalMessagePipeEndpoint|s, so we have to 36 // There's a dispatcher for |LocalMessagePipeEndpoint|s, so we have to
33 // implement/override these: 37 // implement/override these:
34 virtual void CancelAllWaiters() OVERRIDE; 38 virtual void CancelAllWaiters() OVERRIDE;
35 virtual MojoResult ReadMessage( 39 virtual MojoResult ReadMessage(
36 void* bytes, uint32_t* num_bytes, 40 void* bytes, uint32_t* num_bytes,
37 uint32_t max_num_dispatchers, 41 uint32_t max_num_dispatchers,
38 std::vector<scoped_refptr<Dispatcher> >* dispatchers, 42 std::vector<scoped_refptr<Dispatcher> >* dispatchers,
39 MojoReadMessageFlags flags) OVERRIDE; 43 MojoReadMessageFlags flags) OVERRIDE;
40 virtual MojoResult AddWaiter(Waiter* waiter, 44 virtual MojoResult AddWaiter(Waiter* waiter,
41 MojoWaitFlags flags, 45 MojoWaitFlags flags,
42 MojoResult wake_result) OVERRIDE; 46 MojoResult wake_result) OVERRIDE;
43 virtual void RemoveWaiter(Waiter* waiter) OVERRIDE; 47 virtual void RemoveWaiter(Waiter* waiter) OVERRIDE;
44 48
45 private: 49 private:
50 struct MessageQueueEntry {
51 MessageQueueEntry();
52 // Provide an explicit copy constructor, so that we can use this directly in
53 // a (C++03) STL container. However, we only allow the case where |other| is
54 // empty. (We don't provide a nontrivial constructor, because it wouldn't be
55 // useful with these constraints. This will change with C++11.)
56 MessageQueueEntry(const MessageQueueEntry& other);
57 ~MessageQueueEntry();
58
59 MessageInTransit* message;
60 std::vector<scoped_refptr<Dispatcher> > dispatchers;
61
62 private:
63 // We don't need assignment, however.
64 DISALLOW_ASSIGN(MessageQueueEntry);
65 };
66
46 MojoWaitFlags SatisfiedFlags(); 67 MojoWaitFlags SatisfiedFlags();
47 MojoWaitFlags SatisfiableFlags(); 68 MojoWaitFlags SatisfiableFlags();
48 69
49 bool is_open_; 70 bool is_open_;
50 bool is_peer_open_; 71 bool is_peer_open_;
51 72
52 std::deque<MessageInTransit*> message_queue_; 73 std::deque<MessageQueueEntry> message_queue_;
53 WaiterList waiter_list_; 74 WaiterList waiter_list_;
54 75
55 DISALLOW_COPY_AND_ASSIGN(LocalMessagePipeEndpoint); 76 DISALLOW_COPY_AND_ASSIGN(LocalMessagePipeEndpoint);
56 }; 77 };
57 78
58 } // namespace system 79 } // namespace system
59 } // namespace mojo 80 } // namespace mojo
60 81
61 #endif // MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_ 82 #endif // MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/system/local_message_pipe_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698