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/embedder/simple_platform_shared_buffer.h" | 5 #include "mojo/embedder/simple_platform_shared_buffer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/embedder/platform_handle_utils.h" | 8 #include "mojo/embedder/platform_handle_utils.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 size_t SimplePlatformSharedBuffer::GetNumBytes() const { | 47 size_t SimplePlatformSharedBuffer::GetNumBytes() const { |
48 return num_bytes_; | 48 return num_bytes_; |
49 } | 49 } |
50 | 50 |
51 scoped_ptr<PlatformSharedBufferMapping> SimplePlatformSharedBuffer::Map( | 51 scoped_ptr<PlatformSharedBufferMapping> SimplePlatformSharedBuffer::Map( |
52 size_t offset, | 52 size_t offset, |
53 size_t length) { | 53 size_t length) { |
54 if (!IsValidMap(offset, length)) | 54 if (!IsValidMap(offset, length)) |
55 return scoped_ptr<PlatformSharedBufferMapping>(); | 55 return nullptr; |
56 | 56 |
57 return MapNoCheck(offset, length); | 57 return MapNoCheck(offset, length); |
58 } | 58 } |
59 | 59 |
60 bool SimplePlatformSharedBuffer::IsValidMap(size_t offset, size_t length) { | 60 bool SimplePlatformSharedBuffer::IsValidMap(size_t offset, size_t length) { |
61 if (offset > num_bytes_ || length == 0) | 61 if (offset > num_bytes_ || length == 0) |
62 return false; | 62 return false; |
63 | 63 |
64 // Note: This is an overflow-safe check of |offset + length > num_bytes_| | 64 // Note: This is an overflow-safe check of |offset + length > num_bytes_| |
65 // (that |num_bytes >= offset| is verified above). | 65 // (that |num_bytes >= offset| is verified above). |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void* SimplePlatformSharedBufferMapping::GetBase() const { | 99 void* SimplePlatformSharedBufferMapping::GetBase() const { |
100 return base_; | 100 return base_; |
101 } | 101 } |
102 | 102 |
103 size_t SimplePlatformSharedBufferMapping::GetLength() const { | 103 size_t SimplePlatformSharedBufferMapping::GetLength() const { |
104 return length_; | 104 return length_; |
105 } | 105 } |
106 | 106 |
107 } // namespace embedder | 107 } // namespace embedder |
108 } // namespace mojo | 108 } // namespace mojo |
OLD | NEW |