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 #include "mojo/system/shared_buffer_dispatcher.h" | 5 #include "mojo/system/shared_buffer_dispatcher.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "mojo/system/constants.h" | 11 #include "mojo/system/constants.h" |
12 #include "mojo/system/memory.h" | 12 #include "mojo/system/memory.h" |
| 13 #include "mojo/system/raw_shared_buffer.h" |
13 | 14 |
14 namespace mojo { | 15 namespace mojo { |
15 namespace system { | 16 namespace system { |
16 | 17 |
17 // static | 18 // static |
18 MojoResult SharedBufferDispatcher::ValidateOptions( | 19 MojoResult SharedBufferDispatcher::ValidateOptions( |
19 const MojoCreateSharedBufferOptions* in_options, | 20 const MojoCreateSharedBufferOptions* in_options, |
20 MojoCreateSharedBufferOptions* out_options) { | 21 MojoCreateSharedBufferOptions* out_options) { |
21 static const MojoCreateSharedBufferOptions kDefaultOptions = { | 22 static const MojoCreateSharedBufferOptions kDefaultOptions = { |
22 static_cast<uint32_t>(sizeof(MojoCreateSharedBufferOptions)), | 23 static_cast<uint32_t>(sizeof(MojoCreateSharedBufferOptions)), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 100 } |
100 | 101 |
101 *new_dispatcher = new SharedBufferDispatcher(shared_buffer_); | 102 *new_dispatcher = new SharedBufferDispatcher(shared_buffer_); |
102 return MOJO_RESULT_OK; | 103 return MOJO_RESULT_OK; |
103 } | 104 } |
104 | 105 |
105 MojoResult SharedBufferDispatcher::MapBufferImplNoLock( | 106 MojoResult SharedBufferDispatcher::MapBufferImplNoLock( |
106 uint64_t offset, | 107 uint64_t offset, |
107 uint64_t num_bytes, | 108 uint64_t num_bytes, |
108 MojoMapBufferFlags flags, | 109 MojoMapBufferFlags flags, |
109 scoped_ptr<RawSharedBuffer::Mapping>* mapping) { | 110 scoped_ptr<RawSharedBufferMapping>* mapping) { |
110 DCHECK(shared_buffer_); | 111 DCHECK(shared_buffer_); |
111 | 112 |
112 if (offset > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) | 113 if (offset > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) |
113 return MOJO_RESULT_INVALID_ARGUMENT; | 114 return MOJO_RESULT_INVALID_ARGUMENT; |
114 if (num_bytes > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) | 115 if (num_bytes > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) |
115 return MOJO_RESULT_INVALID_ARGUMENT; | 116 return MOJO_RESULT_INVALID_ARGUMENT; |
116 | 117 |
117 if (!shared_buffer_->IsValidMap(static_cast<size_t>(offset), | 118 if (!shared_buffer_->IsValidMap(static_cast<size_t>(offset), |
118 static_cast<size_t>(num_bytes))) | 119 static_cast<size_t>(num_bytes))) |
119 return MOJO_RESULT_INVALID_ARGUMENT; | 120 return MOJO_RESULT_INVALID_ARGUMENT; |
(...skipping 12 matching lines...) Expand all Loading... |
132 return MOJO_WAIT_FLAG_NONE; | 133 return MOJO_WAIT_FLAG_NONE; |
133 } | 134 } |
134 | 135 |
135 MojoWaitFlags SharedBufferDispatcher::SatisfiableFlagsNoLock() const { | 136 MojoWaitFlags SharedBufferDispatcher::SatisfiableFlagsNoLock() const { |
136 // TODO(vtl): Add transferrable flag. | 137 // TODO(vtl): Add transferrable flag. |
137 return MOJO_WAIT_FLAG_NONE; | 138 return MOJO_WAIT_FLAG_NONE; |
138 } | 139 } |
139 | 140 |
140 } // namespace system | 141 } // namespace system |
141 } // namespace mojo | 142 } // namespace mojo |
OLD | NEW |