OLD | NEW |
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/embedder/platform_shared_buffer.h" |
9 #include "mojo/system/memory.h" | 10 #include "mojo/system/memory.h" |
10 #include "mojo/system/raw_shared_buffer.h" | |
11 #include "mojo/system/simple_dispatcher.h" | 11 #include "mojo/system/simple_dispatcher.h" |
12 #include "mojo/system/system_impl_export.h" | 12 #include "mojo/system/system_impl_export.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace system { | 15 namespace system { |
16 | 16 |
17 // 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 |
18 // 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 |
19 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.). | 19 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.). |
20 class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher : public SimpleDispatcher { | 20 class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher : public SimpleDispatcher { |
(...skipping 25 matching lines...) Expand all Loading... |
46 // The "opposite" of |SerializeAndClose()|. (Typically this is called by | 46 // The "opposite" of |SerializeAndClose()|. (Typically this is called by |
47 // |Dispatcher::Deserialize()|.) | 47 // |Dispatcher::Deserialize()|.) |
48 static scoped_refptr<SharedBufferDispatcher> Deserialize( | 48 static scoped_refptr<SharedBufferDispatcher> Deserialize( |
49 Channel* channel, | 49 Channel* channel, |
50 const void* source, | 50 const void* source, |
51 size_t size, | 51 size_t size, |
52 embedder::PlatformHandleVector* platform_handles); | 52 embedder::PlatformHandleVector* platform_handles); |
53 | 53 |
54 private: | 54 private: |
55 explicit SharedBufferDispatcher( | 55 explicit SharedBufferDispatcher( |
56 scoped_refptr<RawSharedBuffer> shared_buffer_); | 56 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_); |
57 virtual ~SharedBufferDispatcher(); | 57 virtual ~SharedBufferDispatcher(); |
58 | 58 |
59 // Validates and/or sets default options for | 59 // Validates and/or sets default options for |
60 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to | 60 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to |
61 // a struct of at least |in_options->struct_size| bytes. |out_options| must | 61 // a struct of at least |in_options->struct_size| bytes. |out_options| must |
62 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be | 62 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be |
63 // entirely overwritten on success (it may be partly overwritten on failure). | 63 // entirely overwritten on success (it may be partly overwritten on failure). |
64 static MojoResult ValidateDuplicateOptions( | 64 static MojoResult ValidateDuplicateOptions( |
65 UserPointer<const MojoDuplicateBufferHandleOptions> in_options, | 65 UserPointer<const MojoDuplicateBufferHandleOptions> in_options, |
66 MojoDuplicateBufferHandleOptions* out_options); | 66 MojoDuplicateBufferHandleOptions* out_options); |
67 | 67 |
68 // |Dispatcher| protected methods: | 68 // |Dispatcher| protected methods: |
69 virtual void CloseImplNoLock() OVERRIDE; | 69 virtual void CloseImplNoLock() OVERRIDE; |
70 virtual scoped_refptr<Dispatcher> | 70 virtual scoped_refptr<Dispatcher> |
71 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE; | 71 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE; |
72 virtual MojoResult DuplicateBufferHandleImplNoLock( | 72 virtual MojoResult DuplicateBufferHandleImplNoLock( |
73 UserPointer<const MojoDuplicateBufferHandleOptions> options, | 73 UserPointer<const MojoDuplicateBufferHandleOptions> options, |
74 scoped_refptr<Dispatcher>* new_dispatcher) OVERRIDE; | 74 scoped_refptr<Dispatcher>* new_dispatcher) OVERRIDE; |
75 virtual MojoResult MapBufferImplNoLock( | 75 virtual MojoResult MapBufferImplNoLock( |
76 uint64_t offset, | 76 uint64_t offset, |
77 uint64_t num_bytes, | 77 uint64_t num_bytes, |
78 MojoMapBufferFlags flags, | 78 MojoMapBufferFlags flags, |
79 scoped_ptr<RawSharedBufferMapping>* mapping) OVERRIDE; | 79 scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping) OVERRIDE; |
80 virtual void StartSerializeImplNoLock(Channel* channel, | 80 virtual void StartSerializeImplNoLock(Channel* channel, |
81 size_t* max_size, | 81 size_t* max_size, |
82 size_t* max_platform_handles) OVERRIDE; | 82 size_t* max_platform_handles) OVERRIDE; |
83 virtual bool EndSerializeAndCloseImplNoLock( | 83 virtual bool EndSerializeAndCloseImplNoLock( |
84 Channel* channel, | 84 Channel* channel, |
85 void* destination, | 85 void* destination, |
86 size_t* actual_size, | 86 size_t* actual_size, |
87 embedder::PlatformHandleVector* platform_handles) OVERRIDE; | 87 embedder::PlatformHandleVector* platform_handles) OVERRIDE; |
88 | 88 |
89 scoped_refptr<RawSharedBuffer> shared_buffer_; | 89 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); | 91 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); |
92 }; | 92 }; |
93 | 93 |
94 } // namespace system | 94 } // namespace system |
95 } // namespace mojo | 95 } // namespace mojo |
96 | 96 |
97 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ | 97 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ |
OLD | NEW |