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

Side by Side Diff: mojo/system/data_pipe.cc

Issue 320343002: Mojo: Make default Options directly accessible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/data_pipe.h ('k') | mojo/system/shared_buffer_dispatcher.h » ('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 #include "mojo/system/data_pipe.h" 5 #include "mojo/system/data_pipe.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "mojo/system/constants.h" 14 #include "mojo/system/constants.h"
15 #include "mojo/system/memory.h" 15 #include "mojo/system/memory.h"
16 #include "mojo/system/options_validation.h" 16 #include "mojo/system/options_validation.h"
17 #include "mojo/system/waiter_list.h" 17 #include "mojo/system/waiter_list.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace system { 20 namespace system {
21 21
22 // static 22 // static
23 const MojoCreateDataPipeOptions DataPipe::kDefaultCreateOptions = {
24 static_cast<uint32_t>(sizeof(MojoCreateDataPipeOptions)),
25 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE,
26 1u,
27 static_cast<uint32_t>(kDefaultDataPipeCapacityBytes)
28 };
29
30 // static
23 MojoResult DataPipe::ValidateCreateOptions( 31 MojoResult DataPipe::ValidateCreateOptions(
24 const MojoCreateDataPipeOptions* in_options, 32 const MojoCreateDataPipeOptions* in_options,
25 MojoCreateDataPipeOptions* out_options) { 33 MojoCreateDataPipeOptions* out_options) {
26 const MojoCreateDataPipeOptionsFlags kKnownFlags = 34 const MojoCreateDataPipeOptionsFlags kKnownFlags =
27 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD; 35 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD;
28 static const MojoCreateDataPipeOptions kDefaultOptions = {
29 static_cast<uint32_t>(sizeof(MojoCreateDataPipeOptions)),
30 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE,
31 1u,
32 static_cast<uint32_t>(kDefaultDataPipeCapacityBytes)
33 };
34 36
35 *out_options = kDefaultOptions; 37 *out_options = kDefaultCreateOptions;
36 if (!in_options) 38 if (!in_options)
37 return MOJO_RESULT_OK; 39 return MOJO_RESULT_OK;
38 40
39 MojoResult result = 41 MojoResult result =
40 ValidateOptionsStructPointerSizeAndFlags<MojoCreateDataPipeOptions>( 42 ValidateOptionsStructPointerSizeAndFlags<MojoCreateDataPipeOptions>(
41 in_options, kKnownFlags, out_options); 43 in_options, kKnownFlags, out_options);
42 if (result != MOJO_RESULT_OK) 44 if (result != MOJO_RESULT_OK)
43 return result; 45 return result;
44 46
45 // Checks for fields beyond |flags|: 47 // Checks for fields beyond |flags|:
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock() { 383 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock() {
382 lock_.AssertAcquired(); 384 lock_.AssertAcquired();
383 if (!has_local_consumer_no_lock()) 385 if (!has_local_consumer_no_lock())
384 return; 386 return;
385 consumer_waiter_list_->AwakeWaitersForStateChange( 387 consumer_waiter_list_->AwakeWaitersForStateChange(
386 ConsumerSatisfiedFlagsNoLock(), ConsumerSatisfiableFlagsNoLock()); 388 ConsumerSatisfiedFlagsNoLock(), ConsumerSatisfiableFlagsNoLock());
387 } 389 }
388 390
389 } // namespace system 391 } // namespace system
390 } // namespace mojo 392 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/data_pipe.h ('k') | mojo/system/shared_buffer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698