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

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

Issue 324783002: Mojo: Add a MojoCreateMessagePipeOptions struct parameter to MojoCreateMessagePipe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 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/entrypoints.cc ('k') | mojo/system/message_pipe_dispatcher.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_MESSAGE_PIPE_DISPATCHER_H_ 5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
6 #define MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 6 #define MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "mojo/system/dispatcher.h" 13 #include "mojo/system/dispatcher.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 MessagePipe; 19 class MessagePipe;
20 class MessagePipeDispatcherTransport; 20 class MessagePipeDispatcherTransport;
21 21
22 // This is the |Dispatcher| implementation for message pipes (created by the 22 // This is the |Dispatcher| implementation for message pipes (created by the
23 // Mojo primitive |MojoCreateMessagePipe()|). This class is thread-safe. 23 // Mojo primitive |MojoCreateMessagePipe()|). This class is thread-safe.
24 class MOJO_SYSTEM_IMPL_EXPORT MessagePipeDispatcher : public Dispatcher { 24 class MOJO_SYSTEM_IMPL_EXPORT MessagePipeDispatcher : public Dispatcher {
25 public: 25 public:
26 MessagePipeDispatcher(); 26 // The default options to use for |MojoCreateMessagePipe()|. (Real uses
27 // should obtain this via |ValidateCreateOptions()| with a null |in_options|;
28 // this is exposed directly for testing convenience.)
29 static const MojoCreateMessagePipeOptions kDefaultCreateOptions;
30
31 MessagePipeDispatcher(
32 const MojoCreateMessagePipeOptions& /*validated_options*/);
33
34 // Validates and/or sets default options for |MojoCreateMessagePipeOptions|.
35 // If non-null, |in_options| must point to a struct of at least
36 // |in_options->struct_size| bytes. |out_options| must point to a (current)
37 // |MojoCreateMessagePipeOptions| and will be entirely overwritten on success
38 // (it may be partly overwritten on failure).
39 static MojoResult ValidateCreateOptions(
40 const MojoCreateMessagePipeOptions* in_options,
41 MojoCreateMessagePipeOptions* out_options);
27 42
28 // Must be called before any other methods. (This method is not thread-safe.) 43 // Must be called before any other methods. (This method is not thread-safe.)
29 void Init(scoped_refptr<MessagePipe> message_pipe, unsigned port); 44 void Init(scoped_refptr<MessagePipe> message_pipe, unsigned port);
30 45
31 // |Dispatcher| public methods: 46 // |Dispatcher| public methods:
32 virtual Type GetType() const OVERRIDE; 47 virtual Type GetType() const OVERRIDE;
33 48
34 // Creates a |MessagePipe| with a local endpoint (at port 0) and a proxy 49 // Creates a |MessagePipe| with a local endpoint (at port 0) and a proxy
35 // endpoint, and creates/initializes a |MessagePipeDispatcher| (attached to 50 // endpoint, and creates/initializes a |MessagePipeDispatcher| (attached to
36 // the message pipe, port 0). 51 // the message pipe, port 0).
52 // TODO(vtl): This currently uses |kDefaultCreateOptions|, which is okay since
53 // there aren't any options, but eventually options should be plumbed through.
37 static std::pair<scoped_refptr<MessagePipeDispatcher>, 54 static std::pair<scoped_refptr<MessagePipeDispatcher>,
38 scoped_refptr<MessagePipe> > CreateRemoteMessagePipe(); 55 scoped_refptr<MessagePipe> > CreateRemoteMessagePipe();
39 56
40 // The "opposite" of |SerializeAndClose()|. (Typically this is called by 57 // The "opposite" of |SerializeAndClose()|. (Typically this is called by
41 // |Dispatcher::Deserialize()|.) 58 // |Dispatcher::Deserialize()|.)
42 static scoped_refptr<MessagePipeDispatcher> Deserialize(Channel* channel, 59 static scoped_refptr<MessagePipeDispatcher> Deserialize(Channel* channel,
43 const void* source, 60 const void* source,
44 size_t size); 61 size_t size);
45 62
46 private: 63 private:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return static_cast<MessagePipeDispatcher*>(dispatcher()); 122 return static_cast<MessagePipeDispatcher*>(dispatcher());
106 } 123 }
107 124
108 // Copy and assign allowed. 125 // Copy and assign allowed.
109 }; 126 };
110 127
111 } // namespace system 128 } // namespace system
112 } // namespace mojo 129 } // namespace mojo
113 130
114 #endif // MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 131 #endif // MOJO_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/system/entrypoints.cc ('k') | mojo/system/message_pipe_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698