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 { |
11 namespace embedder { | 11 namespace embedder { |
12 | 12 |
13 // static | 13 // static |
14 SimplePlatformSharedBuffer* SimplePlatformSharedBuffer::Create( | 14 SimplePlatformSharedBuffer* SimplePlatformSharedBuffer::Create( |
15 size_t num_bytes) { | 15 size_t num_bytes) { |
16 DCHECK_GT(num_bytes, 0u); | 16 DCHECK_GT(num_bytes, 0u); |
17 | 17 |
18 SimplePlatformSharedBuffer* rv = new SimplePlatformSharedBuffer(num_bytes); | 18 SimplePlatformSharedBuffer* rv = new SimplePlatformSharedBuffer(num_bytes); |
19 if (!rv->Init()) { | 19 if (!rv->Init()) { |
20 // We can't just delete it directly, due to the "in destructor" (debug) | 20 // We can't just delete it directly, due to the "in destructor" (debug) |
21 // check. | 21 // check. |
22 scoped_refptr<SimplePlatformSharedBuffer> deleter(rv); | 22 scoped_refptr<SimplePlatformSharedBuffer> deleter(rv); |
23 return NULL; | 23 return nullptr; |
24 } | 24 } |
25 | 25 |
26 return rv; | 26 return rv; |
27 } | 27 } |
28 | 28 |
29 // static | 29 // static |
30 SimplePlatformSharedBuffer* | 30 SimplePlatformSharedBuffer* |
31 SimplePlatformSharedBuffer::CreateFromPlatformHandle( | 31 SimplePlatformSharedBuffer::CreateFromPlatformHandle( |
32 size_t num_bytes, | 32 size_t num_bytes, |
33 ScopedPlatformHandle platform_handle) { | 33 ScopedPlatformHandle platform_handle) { |
34 DCHECK_GT(num_bytes, 0u); | 34 DCHECK_GT(num_bytes, 0u); |
35 | 35 |
36 SimplePlatformSharedBuffer* rv = new SimplePlatformSharedBuffer(num_bytes); | 36 SimplePlatformSharedBuffer* rv = new SimplePlatformSharedBuffer(num_bytes); |
37 if (!rv->InitFromPlatformHandle(platform_handle.Pass())) { | 37 if (!rv->InitFromPlatformHandle(platform_handle.Pass())) { |
38 // We can't just delete it directly, due to the "in destructor" (debug) | 38 // We can't just delete it directly, due to the "in destructor" (debug) |
39 // check. | 39 // check. |
40 scoped_refptr<SimplePlatformSharedBuffer> deleter(rv); | 40 scoped_refptr<SimplePlatformSharedBuffer> deleter(rv); |
41 return NULL; | 41 return nullptr; |
42 } | 42 } |
43 | 43 |
44 return rv; | 44 return rv; |
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( |
(...skipping 47 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 |