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

Side by Side Diff: mojo/edk/system/shared_buffer_dispatcher.cc

Issue 1477643002: Remove the TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03 macro. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@basepass
Patch Set: type-with-move: . 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/system/shared_buffer_dispatcher.h" 5 #include "mojo/edk/system/shared_buffer_dispatcher.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility>
8 9
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "mojo/edk/embedder/embedder_internal.h" 12 #include "mojo/edk/embedder/embedder_internal.h"
12 #include "mojo/edk/embedder/platform_support.h" 13 #include "mojo/edk/embedder/platform_support.h"
13 #include "mojo/edk/system/configuration.h" 14 #include "mojo/edk/system/configuration.h"
14 #include "mojo/edk/system/options_validation.h" 15 #include "mojo/edk/system/options_validation.h"
15 #include "mojo/public/c/system/macros.h" 16 #include "mojo/public/c/system/macros.h"
16 17
17 namespace mojo { 18 namespace mojo {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (!num_bytes) 70 if (!num_bytes)
70 return MOJO_RESULT_INVALID_ARGUMENT; 71 return MOJO_RESULT_INVALID_ARGUMENT;
71 if (num_bytes > GetConfiguration().max_shared_memory_num_bytes) 72 if (num_bytes > GetConfiguration().max_shared_memory_num_bytes)
72 return MOJO_RESULT_RESOURCE_EXHAUSTED; 73 return MOJO_RESULT_RESOURCE_EXHAUSTED;
73 74
74 scoped_refptr<PlatformSharedBuffer> shared_buffer( 75 scoped_refptr<PlatformSharedBuffer> shared_buffer(
75 platform_support->CreateSharedBuffer(static_cast<size_t>(num_bytes))); 76 platform_support->CreateSharedBuffer(static_cast<size_t>(num_bytes)));
76 if (!shared_buffer) 77 if (!shared_buffer)
77 return MOJO_RESULT_RESOURCE_EXHAUSTED; 78 return MOJO_RESULT_RESOURCE_EXHAUSTED;
78 79
79 *result = CreateInternal(shared_buffer.Pass()); 80 *result = CreateInternal(std::move(shared_buffer));
80 return MOJO_RESULT_OK; 81 return MOJO_RESULT_OK;
81 } 82 }
82 83
83 Dispatcher::Type SharedBufferDispatcher::GetType() const { 84 Dispatcher::Type SharedBufferDispatcher::GetType() const {
84 return Type::SHARED_BUFFER; 85 return Type::SHARED_BUFFER;
85 } 86 }
86 87
87 // static 88 // static
88 scoped_refptr<SharedBufferDispatcher> SharedBufferDispatcher::Deserialize( 89 scoped_refptr<SharedBufferDispatcher> SharedBufferDispatcher::Deserialize(
89 const void* source, 90 const void* source,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // closed even if creation fails. 123 // closed even if creation fails.
123 scoped_refptr<PlatformSharedBuffer> shared_buffer( 124 scoped_refptr<PlatformSharedBuffer> shared_buffer(
124 internal::g_platform_support->CreateSharedBufferFromHandle( 125 internal::g_platform_support->CreateSharedBufferFromHandle(
125 num_bytes, ScopedPlatformHandle(platform_handle))); 126 num_bytes, ScopedPlatformHandle(platform_handle)));
126 if (!shared_buffer) { 127 if (!shared_buffer) {
127 LOG(ERROR) 128 LOG(ERROR)
128 << "Invalid serialized shared buffer dispatcher (invalid num_bytes?)"; 129 << "Invalid serialized shared buffer dispatcher (invalid num_bytes?)";
129 return nullptr; 130 return nullptr;
130 } 131 }
131 132
132 return CreateInternal(shared_buffer.Pass()); 133 return CreateInternal(std::move(shared_buffer));
133 } 134 }
134 135
135 SharedBufferDispatcher::SharedBufferDispatcher( 136 SharedBufferDispatcher::SharedBufferDispatcher(
136 scoped_refptr<PlatformSharedBuffer> shared_buffer) 137 scoped_refptr<PlatformSharedBuffer> shared_buffer)
137 : shared_buffer_(shared_buffer) { 138 : shared_buffer_(shared_buffer) {
138 DCHECK(shared_buffer_); 139 DCHECK(shared_buffer_);
139 } 140 }
140 141
141 SharedBufferDispatcher::~SharedBufferDispatcher() { 142 SharedBufferDispatcher::~SharedBufferDispatcher() {
142 } 143 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 void SharedBufferDispatcher::CloseImplNoLock() { 177 void SharedBufferDispatcher::CloseImplNoLock() {
177 lock().AssertAcquired(); 178 lock().AssertAcquired();
178 DCHECK(shared_buffer_); 179 DCHECK(shared_buffer_);
179 shared_buffer_ = nullptr; 180 shared_buffer_ = nullptr;
180 } 181 }
181 182
182 scoped_refptr<Dispatcher> 183 scoped_refptr<Dispatcher>
183 SharedBufferDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { 184 SharedBufferDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() {
184 lock().AssertAcquired(); 185 lock().AssertAcquired();
185 DCHECK(shared_buffer_); 186 DCHECK(shared_buffer_);
186 return CreateInternal(shared_buffer_.Pass()); 187 return CreateInternal(std::move(shared_buffer_));
187 } 188 }
188 189
189 MojoResult SharedBufferDispatcher::DuplicateBufferHandleImplNoLock( 190 MojoResult SharedBufferDispatcher::DuplicateBufferHandleImplNoLock(
190 const MojoDuplicateBufferHandleOptions* options, 191 const MojoDuplicateBufferHandleOptions* options,
191 scoped_refptr<Dispatcher>* new_dispatcher) { 192 scoped_refptr<Dispatcher>* new_dispatcher) {
192 lock().AssertAcquired(); 193 lock().AssertAcquired();
193 194
194 MojoDuplicateBufferHandleOptions validated_options; 195 MojoDuplicateBufferHandleOptions validated_options;
195 MojoResult result = ValidateDuplicateOptions(options, &validated_options); 196 MojoResult result = ValidateDuplicateOptions(options, &validated_options);
196 if (result != MOJO_RESULT_OK) 197 if (result != MOJO_RESULT_OK)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 *actual_size = sizeof(SerializedSharedBufferDispatcher); 260 *actual_size = sizeof(SerializedSharedBufferDispatcher);
260 261
261 shared_buffer_ = nullptr; 262 shared_buffer_ = nullptr;
262 263
263 return true; 264 return true;
264 } 265 }
265 266
266 267
267 } // namespace edk 268 } // namespace edk
268 } // namespace mojo 269 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698