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

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

Issue 1412183009: EDK: Stop having MojoCreateDataPipeOptions as a member of DataPipe. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | 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>
11 11
12 #include "base/compiler_specific.h"
13 #include "mojo/edk/embedder/platform_handle_vector.h" 12 #include "mojo/edk/embedder/platform_handle_vector.h"
14 #include "mojo/edk/system/channel_endpoint_client.h" 13 #include "mojo/edk/system/channel_endpoint_client.h"
15 #include "mojo/edk/system/handle_signals_state.h" 14 #include "mojo/edk/system/handle_signals_state.h"
16 #include "mojo/edk/system/memory.h" 15 #include "mojo/edk/system/memory.h"
17 #include "mojo/edk/util/mutex.h" 16 #include "mojo/edk/util/mutex.h"
18 #include "mojo/edk/util/ref_ptr.h" 17 #include "mojo/edk/util/ref_ptr.h"
19 #include "mojo/edk/util/thread_annotations.h" 18 #include "mojo/edk/util/thread_annotations.h"
20 #include "mojo/public/c/system/data_pipe.h" 19 #include "mojo/public/c/system/data_pipe.h"
21 #include "mojo/public/c/system/types.h" 20 #include "mojo/public/c/system/types.h"
22 #include "mojo/public/cpp/system/macros.h" 21 #include "mojo/public/cpp/system/macros.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 std::unique_ptr<DataPipeImpl> ReplaceImplNoLock( 166 std::unique_ptr<DataPipeImpl> ReplaceImplNoLock(
168 std::unique_ptr<DataPipeImpl> new_impl) 167 std::unique_ptr<DataPipeImpl> new_impl)
169 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 168 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
170 void SetProducerClosedNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 169 void SetProducerClosedNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
171 void SetConsumerClosedNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 170 void SetConsumerClosedNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
172 171
173 void ProducerCloseNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 172 void ProducerCloseNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
174 void ConsumerCloseNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 173 void ConsumerCloseNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
175 174
176 // Thread-safe and fast (they don't take |mutex_|): 175 // Thread-safe and fast (they don't take |mutex_|):
177 const MojoCreateDataPipeOptions& validated_options() const { 176 MojoCreateDataPipeOptions validated_options() const {
178 return validated_options_; 177 MojoCreateDataPipeOptions rv = {sizeof(MojoCreateDataPipeOptions),
178 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE,
179 element_num_bytes_, capacity_num_bytes_};
180 return rv;
179 } 181 }
180 size_t element_num_bytes() const { 182 size_t element_num_bytes() const { return element_num_bytes_; }
181 return validated_options_.element_num_bytes; 183 size_t capacity_num_bytes() const { return capacity_num_bytes_; }
182 }
183 size_t capacity_num_bytes() const {
184 return validated_options_.capacity_num_bytes;
185 }
186 184
187 // Must be called under |mutex_|. 185 // Must be called under |mutex_|.
188 bool producer_open_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) { 186 bool producer_open_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) {
189 mutex_.AssertHeld(); 187 mutex_.AssertHeld();
190 return producer_open_; 188 return producer_open_;
191 } 189 }
192 bool consumer_open_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) { 190 bool consumer_open_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) {
193 mutex_.AssertHeld(); 191 mutex_.AssertHeld();
194 return consumer_open_; 192 return consumer_open_;
195 } 193 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 253
256 bool has_local_producer_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) { 254 bool has_local_producer_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) {
257 mutex_.AssertHeld(); 255 mutex_.AssertHeld();
258 return !!producer_awakable_list_; 256 return !!producer_awakable_list_;
259 } 257 }
260 bool has_local_consumer_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) { 258 bool has_local_consumer_no_lock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_) {
261 mutex_.AssertHeld(); 259 mutex_.AssertHeld();
262 return !!consumer_awakable_list_; 260 return !!consumer_awakable_list_;
263 } 261 }
264 262
265 MSVC_SUPPRESS_WARNING(4324) 263 const uint32_t element_num_bytes_;
266 const MojoCreateDataPipeOptions validated_options_; 264 const uint32_t capacity_num_bytes_;
267 265
268 mutable util::Mutex mutex_; 266 mutable util::Mutex mutex_;
269 // *Known* state of producer or consumer. 267 // *Known* state of producer or consumer.
270 bool producer_open_ MOJO_GUARDED_BY(mutex_); 268 bool producer_open_ MOJO_GUARDED_BY(mutex_);
271 bool consumer_open_ MOJO_GUARDED_BY(mutex_); 269 bool consumer_open_ MOJO_GUARDED_BY(mutex_);
272 // Non-null only if the producer or consumer, respectively, is local. 270 // Non-null only if the producer or consumer, respectively, is local.
273 std::unique_ptr<AwakableList> producer_awakable_list_ MOJO_GUARDED_BY(mutex_); 271 std::unique_ptr<AwakableList> producer_awakable_list_ MOJO_GUARDED_BY(mutex_);
274 std::unique_ptr<AwakableList> consumer_awakable_list_ MOJO_GUARDED_BY(mutex_); 272 std::unique_ptr<AwakableList> consumer_awakable_list_ MOJO_GUARDED_BY(mutex_);
275 // These are nonzero if and only if a two-phase write/read is in progress. 273 // These are nonzero if and only if a two-phase write/read is in progress.
276 uint32_t producer_two_phase_max_num_bytes_written_ MOJO_GUARDED_BY(mutex_); 274 uint32_t producer_two_phase_max_num_bytes_written_ MOJO_GUARDED_BY(mutex_);
277 uint32_t consumer_two_phase_max_num_bytes_read_ MOJO_GUARDED_BY(mutex_); 275 uint32_t consumer_two_phase_max_num_bytes_read_ MOJO_GUARDED_BY(mutex_);
278 std::unique_ptr<DataPipeImpl> impl_ MOJO_GUARDED_BY(mutex_); 276 std::unique_ptr<DataPipeImpl> impl_ MOJO_GUARDED_BY(mutex_);
279 277
280 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipe); 278 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipe);
281 }; 279 };
282 280
283 } // namespace system 281 } // namespace system
284 } // namespace mojo 282 } // namespace mojo
285 283
286 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_H_ 284 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/edk/system/data_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698