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

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

Issue 147983009: Mojo: Refactor some message pipe stuff. (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 | « 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 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "mojo/public/system/core.h" 13 #include "mojo/public/system/core.h"
14 #include "mojo/system/message_pipe_endpoint.h" 14 #include "mojo/system/message_pipe_endpoint.h"
15 #include "mojo/system/system_impl_export.h" 15 #include "mojo/system/system_impl_export.h"
16 #include "mojo/system/waiter_list.h" 16 #include "mojo/system/waiter_list.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 namespace system { 19 namespace system {
20 20
21 class MOJO_SYSTEM_IMPL_EXPORT LocalMessagePipeEndpoint 21 class MOJO_SYSTEM_IMPL_EXPORT LocalMessagePipeEndpoint
22 : public MessagePipeEndpoint { 22 : public MessagePipeEndpoint {
23 public: 23 public:
24 LocalMessagePipeEndpoint(); 24 LocalMessagePipeEndpoint();
25 virtual ~LocalMessagePipeEndpoint(); 25 virtual ~LocalMessagePipeEndpoint();
26 26
27 // |MessagePipeEndpoint| implementation: 27 // |MessagePipeEndpoint| implementation:
28 virtual void Close() OVERRIDE; 28 virtual void Close() OVERRIDE;
29 virtual void OnPeerClose() OVERRIDE; 29 virtual void OnPeerClose() OVERRIDE;
30 virtual MojoResult CanEnqueueMessage( 30 virtual MojoResult EnqueueMessage(
31 const MessageInTransit* message, 31 MessageInTransit* message,
32 const std::vector<Dispatcher*>* dispatchers) OVERRIDE; 32 const std::vector<Dispatcher*>* dispatchers) OVERRIDE;
33 virtual void EnqueueMessage(
34 MessageInTransit* message,
35 std::vector<scoped_refptr<Dispatcher> >* dispatchers) OVERRIDE;
36 33
37 // There's a dispatcher for |LocalMessagePipeEndpoint|s, so we have to 34 // There's a dispatcher for |LocalMessagePipeEndpoint|s, so we have to
38 // implement/override these: 35 // implement/override these:
39 virtual void CancelAllWaiters() OVERRIDE; 36 virtual void CancelAllWaiters() OVERRIDE;
40 virtual MojoResult ReadMessage( 37 virtual MojoResult ReadMessage(
41 void* bytes, uint32_t* num_bytes, 38 void* bytes, uint32_t* num_bytes,
42 std::vector<scoped_refptr<Dispatcher> >* dispatchers, 39 std::vector<scoped_refptr<Dispatcher> >* dispatchers,
43 uint32_t* num_dispatchers, 40 uint32_t* num_dispatchers,
44 MojoReadMessageFlags flags) OVERRIDE; 41 MojoReadMessageFlags flags) OVERRIDE;
45 virtual MojoResult AddWaiter(Waiter* waiter, 42 virtual MojoResult AddWaiter(Waiter* waiter,
46 MojoWaitFlags flags, 43 MojoWaitFlags flags,
47 MojoResult wake_result) OVERRIDE; 44 MojoResult wake_result) OVERRIDE;
48 virtual void RemoveWaiter(Waiter* waiter) OVERRIDE; 45 virtual void RemoveWaiter(Waiter* waiter) OVERRIDE;
49 46
50 private: 47 private:
51 struct MessageQueueEntry { 48 class MessageQueueEntry {
49 public:
52 MessageQueueEntry(); 50 MessageQueueEntry();
53 // Provide an explicit copy constructor, so that we can use this directly in 51 // Provide an explicit copy constructor, so that we can use this directly in
54 // a (C++03) STL container. However, we only allow the case where |other| is 52 // a (C++03) STL container. However, we only allow the case where |other| is
55 // empty. (We don't provide a nontrivial constructor, because it wouldn't be 53 // empty. (We don't provide a nontrivial constructor, because it wouldn't be
56 // useful with these constraints. This will change with C++11.) 54 // useful with these constraints. This will change with C++11.)
57 MessageQueueEntry(const MessageQueueEntry& other); 55 MessageQueueEntry(const MessageQueueEntry& other);
58 ~MessageQueueEntry(); 56 ~MessageQueueEntry();
59 57
60 MessageInTransit* message; 58 // Initialize, taking ownership of |message| and creating equivalent
61 std::vector<scoped_refptr<Dispatcher> > dispatchers; 59 // "duplicate" |dispatchers|. |dispatchers| should be non-null only if
60 // nonempty.
61 // TODO(vtl): This would simply be a constructor, but we don't have C++11's
62 // emplace operations yet, and I don't want to copy |dispatchers_|.
63 void Init(MessageInTransit* message,
64 const std::vector<Dispatcher*>* dispatchers);
65
66 MessageInTransit* message() {
67 return message_;
68 }
69 std::vector<scoped_refptr<Dispatcher> >* dispatchers() {
70 return &dispatchers_;
71 }
62 72
63 private: 73 private:
74 MessageInTransit* message_;
75 std::vector<scoped_refptr<Dispatcher> > dispatchers_;
76
64 // We don't need assignment, however. 77 // We don't need assignment, however.
65 DISALLOW_ASSIGN(MessageQueueEntry); 78 DISALLOW_ASSIGN(MessageQueueEntry);
66 }; 79 };
67 80
68 MojoWaitFlags SatisfiedFlags(); 81 MojoWaitFlags SatisfiedFlags();
69 MojoWaitFlags SatisfiableFlags(); 82 MojoWaitFlags SatisfiableFlags();
70 83
71 bool is_open_; 84 bool is_open_;
72 bool is_peer_open_; 85 bool is_peer_open_;
73 86
74 std::deque<MessageQueueEntry> message_queue_; 87 std::deque<MessageQueueEntry> message_queue_;
75 WaiterList waiter_list_; 88 WaiterList waiter_list_;
76 89
77 DISALLOW_COPY_AND_ASSIGN(LocalMessagePipeEndpoint); 90 DISALLOW_COPY_AND_ASSIGN(LocalMessagePipeEndpoint);
78 }; 91 };
79 92
80 } // namespace system 93 } // namespace system
81 } // namespace mojo 94 } // namespace mojo
82 95
83 #endif // MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_ 96 #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