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

Side by Side Diff: sandbox/mac/mach_message_server.h

Issue 392273002: Create DispatchSourceMach to run a MACH_RECV dispatch source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: I despise the shared_library build with a deep, deep passion Created 6 years, 5 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 | « sandbox/mac/dispatch_source_mach_unittest.cc ('k') | sandbox/mac/mach_message_server.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ 5 #ifndef SANDBOX_MAC_MACH_MESSAGE_SERVER_H_
6 #define SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ 6 #define SANDBOX_MAC_MACH_MESSAGE_SERVER_H_
7 7
8 #include <dispatch/dispatch.h>
9 #include <mach/mach.h> 8 #include <mach/mach.h>
10 9
11 #include "base/mac/scoped_mach_port.h" 10 #include "base/mac/scoped_mach_port.h"
12 #include "base/mac/scoped_mach_vm.h" 11 #include "base/mac/scoped_mach_vm.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "sandbox/mac/message_server.h" 13 #include "sandbox/mac/message_server.h"
14 14
15 namespace sandbox { 15 namespace sandbox {
16 16
17 class DispatchSourceMach;
18
17 // A Mach message server that operates a receive port. Messages are received 19 // A Mach message server that operates a receive port. Messages are received
18 // and then passed to the MessageDemuxer for handling. The Demuxer 20 // and then passed to the MessageDemuxer for handling. The Demuxer
19 // can use the server class to send a reply, forward the message to a 21 // can use the server class to send a reply, forward the message to a
20 // different port, or reply to the message with a MIG error. 22 // different port, or reply to the message with a MIG error.
21 class MachMessageServer : public MessageServer { 23 class MachMessageServer : public MessageServer {
22 public: 24 public:
23 // Creates a new Mach message server that will send messages to |demuxer| 25 // Creates a new Mach message server that will send messages to |demuxer|
24 // for handling. If the |server_receive_right| is non-NULL, this class will 26 // for handling. If the |server_receive_right| is non-NULL, this class will
25 // take ownership of the port and it will be used to receive messages. 27 // take ownership of the port and it will be used to receive messages.
26 // Otherwise the server will create a new receive right. 28 // Otherwise the server will create a new receive right.
(...skipping 19 matching lines...) Expand all
46 // Event handler for the |server_source_| that reads a message from the queue 48 // Event handler for the |server_source_| that reads a message from the queue
47 // and processes it. 49 // and processes it.
48 void ReceiveMessage(); 50 void ReceiveMessage();
49 51
50 // The demuxer delegate. Weak. 52 // The demuxer delegate. Weak.
51 MessageDemuxer* demuxer_; 53 MessageDemuxer* demuxer_;
52 54
53 // The Mach port on which the server is receiving requests. 55 // The Mach port on which the server is receiving requests.
54 base::mac::ScopedMachReceiveRight server_port_; 56 base::mac::ScopedMachReceiveRight server_port_;
55 57
56 // The dispatch queue used to service the server_source_.
57 dispatch_queue_t server_queue_;
58
59 // A MACH_RECV dispatch source for the server_port_.
60 dispatch_source_t server_source_;
61
62 // Semaphore used to wait on the |server_source_|'s cancellation in the
63 // destructor.
64 dispatch_semaphore_t source_canceled_;
65
66 // The size of the two message buffers below. 58 // The size of the two message buffers below.
67 const mach_msg_size_t buffer_size_; 59 const mach_msg_size_t buffer_size_;
68 60
69 // Request and reply buffers used in ReceiveMessage. 61 // Request and reply buffers used in ReceiveMessage.
70 base::mac::ScopedMachVM request_buffer_; 62 base::mac::ScopedMachVM request_buffer_;
71 base::mac::ScopedMachVM reply_buffer_; 63 base::mac::ScopedMachVM reply_buffer_;
72 64
65 // MACH_RECV dispatch source that handles the |server_port_|.
66 scoped_ptr<DispatchSourceMach> dispatch_source_;
67
73 // Whether or not ForwardMessage() was called during ReceiveMessage(). 68 // Whether or not ForwardMessage() was called during ReceiveMessage().
74 bool did_forward_message_; 69 bool did_forward_message_;
75 }; 70 };
76 71
77 } // namespace sandbox 72 } // namespace sandbox
78 73
79 #endif // SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ 74 #endif // SANDBOX_MAC_MACH_MESSAGE_SERVER_H_
OLDNEW
« no previous file with comments | « sandbox/mac/dispatch_source_mach_unittest.cc ('k') | sandbox/mac/mach_message_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698