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

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

Issue 728043002: Revert of Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 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/edk/embedder/platform_support.h" 11 #include "mojo/edk/embedder/platform_support.h"
12 #include "mojo/edk/system/channel.h" 12 #include "mojo/edk/system/channel.h"
13 #include "mojo/edk/system/configuration.h" 13 #include "mojo/edk/system/constants.h"
14 #include "mojo/edk/system/memory.h" 14 #include "mojo/edk/system/memory.h"
15 #include "mojo/edk/system/options_validation.h" 15 #include "mojo/edk/system/options_validation.h"
16 #include "mojo/public/c/system/macros.h" 16 #include "mojo/public/c/system/macros.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 namespace system { 19 namespace system {
20 20
21 namespace { 21 namespace {
22 22
23 struct SerializedSharedBufferDispatcher { 23 struct SerializedSharedBufferDispatcher {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 // static 64 // static
65 MojoResult SharedBufferDispatcher::Create( 65 MojoResult SharedBufferDispatcher::Create(
66 embedder::PlatformSupport* platform_support, 66 embedder::PlatformSupport* platform_support,
67 const MojoCreateSharedBufferOptions& /*validated_options*/, 67 const MojoCreateSharedBufferOptions& /*validated_options*/,
68 uint64_t num_bytes, 68 uint64_t num_bytes,
69 scoped_refptr<SharedBufferDispatcher>* result) { 69 scoped_refptr<SharedBufferDispatcher>* result) {
70 if (!num_bytes) 70 if (!num_bytes)
71 return MOJO_RESULT_INVALID_ARGUMENT; 71 return MOJO_RESULT_INVALID_ARGUMENT;
72 if (num_bytes > GetConfiguration().max_shared_memory_num_bytes) 72 if (num_bytes > kMaxSharedMemoryNumBytes)
73 return MOJO_RESULT_RESOURCE_EXHAUSTED; 73 return MOJO_RESULT_RESOURCE_EXHAUSTED;
74 74
75 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer( 75 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer(
76 platform_support->CreateSharedBuffer(static_cast<size_t>(num_bytes))); 76 platform_support->CreateSharedBuffer(static_cast<size_t>(num_bytes)));
77 if (!shared_buffer.get()) 77 if (!shared_buffer.get())
78 return MOJO_RESULT_RESOURCE_EXHAUSTED; 78 return MOJO_RESULT_RESOURCE_EXHAUSTED;
79 79
80 *result = new SharedBufferDispatcher(shared_buffer); 80 *result = new SharedBufferDispatcher(shared_buffer);
81 return MOJO_RESULT_OK; 81 return MOJO_RESULT_OK;
82 } 82 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE}; 156 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE};
157 157
158 *out_options = kDefaultOptions; 158 *out_options = kDefaultOptions;
159 if (in_options.IsNull()) 159 if (in_options.IsNull())
160 return MOJO_RESULT_OK; 160 return MOJO_RESULT_OK;
161 161
162 UserOptionsReader<MojoDuplicateBufferHandleOptions> reader(in_options); 162 UserOptionsReader<MojoDuplicateBufferHandleOptions> reader(in_options);
163 if (!reader.is_valid()) 163 if (!reader.is_valid())
164 return MOJO_RESULT_INVALID_ARGUMENT; 164 return MOJO_RESULT_INVALID_ARGUMENT;
165 165
166 if (!OPTIONS_STRUCT_HAS_MEMBER(MojoDuplicateBufferHandleOptions, flags, 166 if (!OPTIONS_STRUCT_HAS_MEMBER(
167 reader)) 167 MojoDuplicateBufferHandleOptions, flags, reader))
168 return MOJO_RESULT_OK; 168 return MOJO_RESULT_OK;
169 if ((reader.options().flags & ~kKnownFlags)) 169 if ((reader.options().flags & ~kKnownFlags))
170 return MOJO_RESULT_UNIMPLEMENTED; 170 return MOJO_RESULT_UNIMPLEMENTED;
171 out_options->flags = reader.options().flags; 171 out_options->flags = reader.options().flags;
172 172
173 // Checks for fields beyond |flags|: 173 // Checks for fields beyond |flags|:
174 174
175 // (Nothing here yet.) 175 // (Nothing here yet.)
176 176
177 return MOJO_RESULT_OK; 177 return MOJO_RESULT_OK;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 platform_handles->push_back(platform_handle.release()); 267 platform_handles->push_back(platform_handle.release());
268 *actual_size = sizeof(SerializedSharedBufferDispatcher); 268 *actual_size = sizeof(SerializedSharedBufferDispatcher);
269 269
270 shared_buffer_ = nullptr; 270 shared_buffer_ = nullptr;
271 271
272 return true; 272 return true;
273 } 273 }
274 274
275 } // namespace system 275 } // namespace system
276 } // namespace mojo 276 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/run_all_unittests.cc ('k') | mojo/edk/system/shared_buffer_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698