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

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

Issue 414393002: Convert verification of options structs to use the new user pointer handling (see r285350). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: temporarily disable part of OptionsValidationTest.InvalidDeath Created 6 years, 4 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/options_validation_unittest.cc ('k') | mojo/system/shared_buffer_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 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 MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 5 #ifndef MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
6 #define MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 6 #define MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "mojo/system/memory.h"
9 #include "mojo/system/raw_shared_buffer.h" 10 #include "mojo/system/raw_shared_buffer.h"
10 #include "mojo/system/simple_dispatcher.h" 11 #include "mojo/system/simple_dispatcher.h"
11 #include "mojo/system/system_impl_export.h" 12 #include "mojo/system/system_impl_export.h"
12 13
13 namespace mojo { 14 namespace mojo {
14 namespace system { 15 namespace system {
15 16
16 // TODO(vtl): We derive from SimpleDispatcher, even though we don't currently 17 // TODO(vtl): We derive from SimpleDispatcher, even though we don't currently
17 // have anything that's waitable. I want to add a "transferrable" wait flag. 18 // have anything that's waitable. I want to add a "transferrable" wait flag.
18 class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher : public SimpleDispatcher { 19 class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher : public SimpleDispatcher {
19 public: 20 public:
20 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses 21 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses
21 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; 22 // should obtain this via |ValidateCreateOptions()| with a null |in_options|;
22 // this is exposed directly for testing convenience.) 23 // this is exposed directly for testing convenience.)
23 static const MojoCreateSharedBufferOptions kDefaultCreateOptions; 24 static const MojoCreateSharedBufferOptions kDefaultCreateOptions;
24 25
25 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|. 26 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|.
26 // If non-null, |in_options| must point to a struct of at least 27 // If non-null, |in_options| must point to a struct of at least
27 // |in_options->struct_size| bytes. |out_options| must point to a (current) 28 // |in_options->struct_size| bytes. |out_options| must point to a (current)
28 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success 29 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success
29 // (it may be partly overwritten on failure). 30 // (it may be partly overwritten on failure).
30 static MojoResult ValidateCreateOptions( 31 static MojoResult ValidateCreateOptions(
31 const MojoCreateSharedBufferOptions* in_options, 32 UserPointer<const MojoCreateSharedBufferOptions> in_options,
32 MojoCreateSharedBufferOptions* out_options); 33 MojoCreateSharedBufferOptions* out_options);
33 34
34 // Static factory method: |validated_options| must be validated (obviously). 35 // Static factory method: |validated_options| must be validated (obviously).
35 // On failure, |*result| will be left as-is. 36 // On failure, |*result| will be left as-is.
36 static MojoResult Create( 37 static MojoResult Create(
37 const MojoCreateSharedBufferOptions& validated_options, 38 const MojoCreateSharedBufferOptions& validated_options,
38 uint64_t num_bytes, 39 uint64_t num_bytes,
39 scoped_refptr<SharedBufferDispatcher>* result); 40 scoped_refptr<SharedBufferDispatcher>* result);
40 41
41 // |Dispatcher| public methods: 42 // |Dispatcher| public methods:
(...skipping 11 matching lines...) Expand all
53 explicit SharedBufferDispatcher( 54 explicit SharedBufferDispatcher(
54 scoped_refptr<RawSharedBuffer> shared_buffer_); 55 scoped_refptr<RawSharedBuffer> shared_buffer_);
55 virtual ~SharedBufferDispatcher(); 56 virtual ~SharedBufferDispatcher();
56 57
57 // Validates and/or sets default options for 58 // Validates and/or sets default options for
58 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to 59 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to
59 // a struct of at least |in_options->struct_size| bytes. |out_options| must 60 // a struct of at least |in_options->struct_size| bytes. |out_options| must
60 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be 61 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be
61 // entirely overwritten on success (it may be partly overwritten on failure). 62 // entirely overwritten on success (it may be partly overwritten on failure).
62 static MojoResult ValidateDuplicateOptions( 63 static MojoResult ValidateDuplicateOptions(
63 const MojoDuplicateBufferHandleOptions* in_options, 64 UserPointer<const MojoDuplicateBufferHandleOptions> in_options,
64 MojoDuplicateBufferHandleOptions* out_options); 65 MojoDuplicateBufferHandleOptions* out_options);
65 66
66 // |Dispatcher| protected methods: 67 // |Dispatcher| protected methods:
67 virtual void CloseImplNoLock() OVERRIDE; 68 virtual void CloseImplNoLock() OVERRIDE;
68 virtual scoped_refptr<Dispatcher> 69 virtual scoped_refptr<Dispatcher>
69 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE; 70 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE;
70 virtual MojoResult DuplicateBufferHandleImplNoLock( 71 virtual MojoResult DuplicateBufferHandleImplNoLock(
71 const MojoDuplicateBufferHandleOptions* options, 72 UserPointer<const MojoDuplicateBufferHandleOptions> options,
72 scoped_refptr<Dispatcher>* new_dispatcher) OVERRIDE; 73 scoped_refptr<Dispatcher>* new_dispatcher) OVERRIDE;
73 virtual MojoResult MapBufferImplNoLock( 74 virtual MojoResult MapBufferImplNoLock(
74 uint64_t offset, 75 uint64_t offset,
75 uint64_t num_bytes, 76 uint64_t num_bytes,
76 MojoMapBufferFlags flags, 77 MojoMapBufferFlags flags,
77 scoped_ptr<RawSharedBufferMapping>* mapping) OVERRIDE; 78 scoped_ptr<RawSharedBufferMapping>* mapping) OVERRIDE;
78 virtual void StartSerializeImplNoLock(Channel* channel, 79 virtual void StartSerializeImplNoLock(Channel* channel,
79 size_t* max_size, 80 size_t* max_size,
80 size_t* max_platform_handles) OVERRIDE; 81 size_t* max_platform_handles) OVERRIDE;
81 virtual bool EndSerializeAndCloseImplNoLock( 82 virtual bool EndSerializeAndCloseImplNoLock(
82 Channel* channel, 83 Channel* channel,
83 void* destination, 84 void* destination,
84 size_t* actual_size, 85 size_t* actual_size,
85 embedder::PlatformHandleVector* platform_handles) OVERRIDE; 86 embedder::PlatformHandleVector* platform_handles) OVERRIDE;
86 87
87 // |SimpleDispatcher| method: 88 // |SimpleDispatcher| method:
88 virtual HandleSignalsState GetHandleSignalsStateNoLock() const OVERRIDE; 89 virtual HandleSignalsState GetHandleSignalsStateNoLock() const OVERRIDE;
89 90
90 scoped_refptr<RawSharedBuffer> shared_buffer_; 91 scoped_refptr<RawSharedBuffer> shared_buffer_;
91 92
92 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); 93 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher);
93 }; 94 };
94 95
95 } // namespace system 96 } // namespace system
96 } // namespace mojo 97 } // namespace mojo
97 98
98 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ 99 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/system/options_validation_unittest.cc ('k') | mojo/system/shared_buffer_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698