• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "mojo/public/cpp/base/read_only_buffer_mojom_traits.h"
6 
7 namespace mojo {
8 
9 bool StructTraits<mojo_base::mojom::ReadOnlyBufferDataView,
10                   base::span<const uint8_t>>::
Read(mojo_base::mojom::ReadOnlyBufferDataView input,base::span<const uint8_t> * out)11     Read(mojo_base::mojom::ReadOnlyBufferDataView input,
12          base::span<const uint8_t>* out) {
13   ArrayDataView<uint8_t> data_view;
14   input.GetBufferDataView(&data_view);
15 
16   // NOTE: This output directly refers to memory owned by the message.
17   // Therefore, the message must stay valid while the output is passed to the
18   // user code.
19   *out = base::span<const uint8_t>(data_view.data(), data_view.size());
20   return true;
21 }
22 
23 }  // namespace mojo