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/embedder/platform_shared_buffer.h" |
10 #include "mojo/system/memory.h" | 10 #include "mojo/system/memory.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // Static factory method: |validated_options| must be validated (obviously). | 41 // Static factory method: |validated_options| must be validated (obviously). |
42 // On failure, |*result| will be left as-is. | 42 // On failure, |*result| will be left as-is. |
43 static MojoResult Create( | 43 static MojoResult Create( |
44 embedder::PlatformSupport* platform_support, | 44 embedder::PlatformSupport* platform_support, |
45 const MojoCreateSharedBufferOptions& validated_options, | 45 const MojoCreateSharedBufferOptions& validated_options, |
46 uint64_t num_bytes, | 46 uint64_t num_bytes, |
47 scoped_refptr<SharedBufferDispatcher>* result); | 47 scoped_refptr<SharedBufferDispatcher>* result); |
48 | 48 |
49 // |Dispatcher| public methods: | 49 // |Dispatcher| public methods: |
50 virtual Type GetType() const OVERRIDE; | 50 virtual Type GetType() const override; |
51 | 51 |
52 // The "opposite" of |SerializeAndClose()|. (Typically this is called by | 52 // The "opposite" of |SerializeAndClose()|. (Typically this is called by |
53 // |Dispatcher::Deserialize()|.) | 53 // |Dispatcher::Deserialize()|.) |
54 static scoped_refptr<SharedBufferDispatcher> Deserialize( | 54 static scoped_refptr<SharedBufferDispatcher> Deserialize( |
55 Channel* channel, | 55 Channel* channel, |
56 const void* source, | 56 const void* source, |
57 size_t size, | 57 size_t size, |
58 embedder::PlatformHandleVector* platform_handles); | 58 embedder::PlatformHandleVector* platform_handles); |
59 | 59 |
60 private: | 60 private: |
61 explicit SharedBufferDispatcher( | 61 explicit SharedBufferDispatcher( |
62 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_); | 62 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_); |
63 virtual ~SharedBufferDispatcher(); | 63 virtual ~SharedBufferDispatcher(); |
64 | 64 |
65 // Validates and/or sets default options for | 65 // Validates and/or sets default options for |
66 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to | 66 // |MojoDuplicateBufferHandleOptions|. If non-null, |in_options| must point to |
67 // a struct of at least |in_options->struct_size| bytes. |out_options| must | 67 // a struct of at least |in_options->struct_size| bytes. |out_options| must |
68 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be | 68 // point to a (current) |MojoDuplicateBufferHandleOptions| and will be |
69 // entirely overwritten on success (it may be partly overwritten on failure). | 69 // entirely overwritten on success (it may be partly overwritten on failure). |
70 static MojoResult ValidateDuplicateOptions( | 70 static MojoResult ValidateDuplicateOptions( |
71 UserPointer<const MojoDuplicateBufferHandleOptions> in_options, | 71 UserPointer<const MojoDuplicateBufferHandleOptions> in_options, |
72 MojoDuplicateBufferHandleOptions* out_options); | 72 MojoDuplicateBufferHandleOptions* out_options); |
73 | 73 |
74 // |Dispatcher| protected methods: | 74 // |Dispatcher| protected methods: |
75 virtual void CloseImplNoLock() OVERRIDE; | 75 virtual void CloseImplNoLock() override; |
76 virtual scoped_refptr<Dispatcher> | 76 virtual scoped_refptr<Dispatcher> |
77 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE; | 77 CreateEquivalentDispatcherAndCloseImplNoLock() override; |
78 virtual MojoResult DuplicateBufferHandleImplNoLock( | 78 virtual MojoResult DuplicateBufferHandleImplNoLock( |
79 UserPointer<const MojoDuplicateBufferHandleOptions> options, | 79 UserPointer<const MojoDuplicateBufferHandleOptions> options, |
80 scoped_refptr<Dispatcher>* new_dispatcher) OVERRIDE; | 80 scoped_refptr<Dispatcher>* new_dispatcher) override; |
81 virtual MojoResult MapBufferImplNoLock( | 81 virtual MojoResult MapBufferImplNoLock( |
82 uint64_t offset, | 82 uint64_t offset, |
83 uint64_t num_bytes, | 83 uint64_t num_bytes, |
84 MojoMapBufferFlags flags, | 84 MojoMapBufferFlags flags, |
85 scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping) OVERRIDE; | 85 scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping) override; |
86 virtual void StartSerializeImplNoLock(Channel* channel, | 86 virtual void StartSerializeImplNoLock(Channel* channel, |
87 size_t* max_size, | 87 size_t* max_size, |
88 size_t* max_platform_handles) OVERRIDE; | 88 size_t* max_platform_handles) override; |
89 virtual bool EndSerializeAndCloseImplNoLock( | 89 virtual bool EndSerializeAndCloseImplNoLock( |
90 Channel* channel, | 90 Channel* channel, |
91 void* destination, | 91 void* destination, |
92 size_t* actual_size, | 92 size_t* actual_size, |
93 embedder::PlatformHandleVector* platform_handles) OVERRIDE; | 93 embedder::PlatformHandleVector* platform_handles) override; |
94 | 94 |
95 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_; | 95 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); | 97 DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); |
98 }; | 98 }; |
99 | 99 |
100 } // namespace system | 100 } // namespace system |
101 } // namespace mojo | 101 } // namespace mojo |
102 | 102 |
103 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ | 103 #endif // MOJO_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ |
OLD | NEW |