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

Side by Side Diff: mojo/edk/system/data_pipe.h

Issue 1396783004: Convert mojo::system::ChannelEndpointClient to use our new refcounting stuff (instead of base's). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « mojo/edk/system/core.cc ('k') | mojo/edk/system/data_pipe.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_EDK_SYSTEM_DATA_PIPE_H_ 5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_H_
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_H_ 6 #define MOJO_EDK_SYSTEM_DATA_PIPE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // may be partly overwritten on failure). 51 // may be partly overwritten on failure).
52 static MojoResult ValidateCreateOptions( 52 static MojoResult ValidateCreateOptions(
53 UserPointer<const MojoCreateDataPipeOptions> in_options, 53 UserPointer<const MojoCreateDataPipeOptions> in_options,
54 MojoCreateDataPipeOptions* out_options); 54 MojoCreateDataPipeOptions* out_options);
55 55
56 // Creates a local (both producer and consumer) data pipe (using 56 // Creates a local (both producer and consumer) data pipe (using
57 // |LocalDataPipeImpl|. |validated_options| should be the output of 57 // |LocalDataPipeImpl|. |validated_options| should be the output of
58 // |ValidateOptions()|. In particular: |struct_size| is ignored (so 58 // |ValidateOptions()|. In particular: |struct_size| is ignored (so
59 // |validated_options| must be the current version of the struct) and 59 // |validated_options| must be the current version of the struct) and
60 // |capacity_num_bytes| must be nonzero. 60 // |capacity_num_bytes| must be nonzero.
61 static DataPipe* CreateLocal( 61 static RefPtr<DataPipe> CreateLocal(
62 const MojoCreateDataPipeOptions& validated_options); 62 const MojoCreateDataPipeOptions& validated_options);
63 63
64 // Creates a data pipe with a remote producer and a local consumer, using an 64 // Creates a data pipe with a remote producer and a local consumer, using an
65 // existing |ChannelEndpoint| (whose |ReplaceClient()| it'll call) and taking 65 // existing |ChannelEndpoint| (whose |ReplaceClient()| it'll call) and taking
66 // |message_queue|'s contents as already-received incoming messages. If 66 // |message_queue|'s contents as already-received incoming messages. If
67 // |channel_endpoint| is null, this will create a "half-open" data pipe (with 67 // |channel_endpoint| is null, this will create a "half-open" data pipe (with
68 // only the consumer open). Note that this may fail, in which case it returns 68 // only the consumer open). Note that this may fail, in which case it returns
69 // null. 69 // null.
70 static DataPipe* CreateRemoteProducerFromExisting( 70 static RefPtr<DataPipe> CreateRemoteProducerFromExisting(
71 const MojoCreateDataPipeOptions& validated_options, 71 const MojoCreateDataPipeOptions& validated_options,
72 MessageInTransitQueue* message_queue, 72 MessageInTransitQueue* message_queue,
73 RefPtr<ChannelEndpoint>&& channel_endpoint); 73 RefPtr<ChannelEndpoint>&& channel_endpoint);
74 74
75 // Creates a data pipe with a local producer and a remote consumer, using an 75 // Creates a data pipe with a local producer and a remote consumer, using an
76 // existing |ChannelEndpoint| (whose |ReplaceClient()| it'll call) and taking 76 // existing |ChannelEndpoint| (whose |ReplaceClient()| it'll call) and taking
77 // |message_queue|'s contents as already-received incoming messages 77 // |message_queue|'s contents as already-received incoming messages
78 // (|message_queue| may be null). If |channel_endpoint| is null, this will 78 // (|message_queue| may be null). If |channel_endpoint| is null, this will
79 // create a "half-open" data pipe (with only the producer open). Note that 79 // create a "half-open" data pipe (with only the producer open). Note that
80 // this may fail, in which case it returns null. 80 // this may fail, in which case it returns null.
81 static DataPipe* CreateRemoteConsumerFromExisting( 81 static RefPtr<DataPipe> CreateRemoteConsumerFromExisting(
82 const MojoCreateDataPipeOptions& validated_options, 82 const MojoCreateDataPipeOptions& validated_options,
83 size_t consumer_num_bytes, 83 size_t consumer_num_bytes,
84 MessageInTransitQueue* message_queue, 84 MessageInTransitQueue* message_queue,
85 RefPtr<ChannelEndpoint>&& channel_endpoint); 85 RefPtr<ChannelEndpoint>&& channel_endpoint);
86 86
87 // Used by |DataPipeProducerDispatcher::Deserialize()|. Returns true on 87 // Used by |DataPipeProducerDispatcher::Deserialize()|. Returns true on
88 // success (in which case, |*data_pipe| is set appropriately) and false on 88 // success (in which case, |*data_pipe| is set appropriately) and false on
89 // failure (in which case |*data_pipe| may or may not be set to null). 89 // failure (in which case |*data_pipe| may or may not be set to null).
90 static bool ProducerDeserialize(Channel* channel, 90 static bool ProducerDeserialize(Channel* channel,
91 const void* source, 91 const void* source,
92 size_t size, 92 size_t size,
93 scoped_refptr<DataPipe>* data_pipe); 93 RefPtr<DataPipe>* data_pipe);
94 94
95 // Used by |DataPipeConsumerDispatcher::Deserialize()|. Returns true on 95 // Used by |DataPipeConsumerDispatcher::Deserialize()|. Returns true on
96 // success (in which case, |*data_pipe| is set appropriately) and false on 96 // success (in which case, |*data_pipe| is set appropriately) and false on
97 // failure (in which case |*data_pipe| may or may not be set to null). 97 // failure (in which case |*data_pipe| may or may not be set to null).
98 static bool ConsumerDeserialize(Channel* channel, 98 static bool ConsumerDeserialize(Channel* channel,
99 const void* source, 99 const void* source,
100 size_t size, 100 size_t size,
101 scoped_refptr<DataPipe>* data_pipe); 101 RefPtr<DataPipe>* data_pipe);
102 102
103 // These are called by the producer dispatcher to implement its methods of 103 // These are called by the producer dispatcher to implement its methods of
104 // corresponding names. 104 // corresponding names.
105 void ProducerCancelAllAwakables(); 105 void ProducerCancelAllAwakables();
106 void ProducerClose(); 106 void ProducerClose();
107 MojoResult ProducerWriteData(UserPointer<const void> elements, 107 MojoResult ProducerWriteData(UserPointer<const void> elements,
108 UserPointer<uint32_t> num_bytes, 108 UserPointer<uint32_t> num_bytes,
109 bool all_or_none); 109 bool all_or_none);
110 MojoResult ProducerBeginWriteData(UserPointer<void*> buffer, 110 MojoResult ProducerBeginWriteData(UserPointer<void*> buffer,
111 UserPointer<uint32_t> buffer_num_bytes); 111 UserPointer<uint32_t> buffer_num_bytes);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 uint32_t consumer_two_phase_max_num_bytes_read_ MOJO_GUARDED_BY(mutex_); 277 uint32_t consumer_two_phase_max_num_bytes_read_ MOJO_GUARDED_BY(mutex_);
278 std::unique_ptr<DataPipeImpl> impl_ MOJO_GUARDED_BY(mutex_); 278 std::unique_ptr<DataPipeImpl> impl_ MOJO_GUARDED_BY(mutex_);
279 279
280 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipe); 280 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipe);
281 }; 281 };
282 282
283 } // namespace system 283 } // namespace system
284 } // namespace mojo 284 } // namespace mojo
285 285
286 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_H_ 286 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/core.cc ('k') | mojo/edk/system/data_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698