Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: mojo/edk/embedder/simple_platform_shared_buffer.cc

Issue 1529303004: Convert Pass()→std::move() in mojo/edk/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/edk/embedder/simple_platform_shared_buffer.h" 5 #include "mojo/edk/embedder/simple_platform_shared_buffer.h"
6 6
7 #include <utility>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "mojo/edk/embedder/platform_handle_utils.h" 10 #include "mojo/edk/embedder/platform_handle_utils.h"
9 11
10 namespace mojo { 12 namespace mojo {
11 namespace edk { 13 namespace edk {
12 14
13 // static 15 // static
14 SimplePlatformSharedBuffer* SimplePlatformSharedBuffer::Create( 16 SimplePlatformSharedBuffer* SimplePlatformSharedBuffer::Create(
15 size_t num_bytes) { 17 size_t num_bytes) {
16 DCHECK_GT(num_bytes, 0u); 18 DCHECK_GT(num_bytes, 0u);
(...skipping 10 matching lines...) Expand all
27 } 29 }
28 30
29 // static 31 // static
30 SimplePlatformSharedBuffer* 32 SimplePlatformSharedBuffer*
31 SimplePlatformSharedBuffer::CreateFromPlatformHandle( 33 SimplePlatformSharedBuffer::CreateFromPlatformHandle(
32 size_t num_bytes, 34 size_t num_bytes,
33 ScopedPlatformHandle platform_handle) { 35 ScopedPlatformHandle platform_handle) {
34 DCHECK_GT(num_bytes, 0u); 36 DCHECK_GT(num_bytes, 0u);
35 37
36 SimplePlatformSharedBuffer* rv = new SimplePlatformSharedBuffer(num_bytes); 38 SimplePlatformSharedBuffer* rv = new SimplePlatformSharedBuffer(num_bytes);
37 if (!rv->InitFromPlatformHandle(platform_handle.Pass())) { 39 if (!rv->InitFromPlatformHandle(std::move(platform_handle))) {
38 // We can't just delete it directly, due to the "in destructor" (debug) 40 // We can't just delete it directly, due to the "in destructor" (debug)
39 // check. 41 // check.
40 scoped_refptr<SimplePlatformSharedBuffer> deleter(rv); 42 scoped_refptr<SimplePlatformSharedBuffer> deleter(rv);
41 return nullptr; 43 return nullptr;
42 } 44 }
43 45
44 return rv; 46 return rv;
45 } 47 }
46 48
47 size_t SimplePlatformSharedBuffer::GetNumBytes() const { 49 size_t SimplePlatformSharedBuffer::GetNumBytes() const {
(...skipping 27 matching lines...) Expand all
75 DCHECK(IsValidMap(offset, length)); 77 DCHECK(IsValidMap(offset, length));
76 return MapImpl(offset, length); 78 return MapImpl(offset, length);
77 } 79 }
78 80
79 ScopedPlatformHandle SimplePlatformSharedBuffer::DuplicatePlatformHandle() { 81 ScopedPlatformHandle SimplePlatformSharedBuffer::DuplicatePlatformHandle() {
80 return mojo::edk::DuplicatePlatformHandle(handle_.get()); 82 return mojo::edk::DuplicatePlatformHandle(handle_.get());
81 } 83 }
82 84
83 ScopedPlatformHandle SimplePlatformSharedBuffer::PassPlatformHandle() { 85 ScopedPlatformHandle SimplePlatformSharedBuffer::PassPlatformHandle() {
84 DCHECK(HasOneRef()); 86 DCHECK(HasOneRef());
85 return handle_.Pass(); 87 return std::move(handle_);
86 } 88 }
87 89
88 SimplePlatformSharedBuffer::SimplePlatformSharedBuffer(size_t num_bytes) 90 SimplePlatformSharedBuffer::SimplePlatformSharedBuffer(size_t num_bytes)
89 : num_bytes_(num_bytes) { 91 : num_bytes_(num_bytes) {
90 } 92 }
91 93
92 SimplePlatformSharedBuffer::~SimplePlatformSharedBuffer() { 94 SimplePlatformSharedBuffer::~SimplePlatformSharedBuffer() {
93 } 95 }
94 96
95 SimplePlatformSharedBufferMapping::~SimplePlatformSharedBufferMapping() { 97 SimplePlatformSharedBufferMapping::~SimplePlatformSharedBufferMapping() {
96 Unmap(); 98 Unmap();
97 } 99 }
98 100
99 void* SimplePlatformSharedBufferMapping::GetBase() const { 101 void* SimplePlatformSharedBufferMapping::GetBase() const {
100 return base_; 102 return base_;
101 } 103 }
102 104
103 size_t SimplePlatformSharedBufferMapping::GetLength() const { 105 size_t SimplePlatformSharedBufferMapping::GetLength() const {
104 return length_; 106 return length_;
105 } 107 }
106 108
107 } // namespace edk 109 } // namespace edk
108 } // namespace mojo 110 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/platform_channel_pair_posix_unittest.cc ('k') | mojo/edk/embedder/simple_platform_shared_buffer_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698