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 "ipc/message_mojom_traits.h" 6 7 #include "mojo/public/cpp/base/big_buffer_mojom_traits.h" 8 9 namespace mojo { 10 11 // static 12 mojo_base::BigBufferView buffer(IPC::MessageView & view)13StructTraits<IPC::mojom::MessageDataView, IPC::MessageView>::buffer( 14 IPC::MessageView& view) { 15 return view.TakeBufferView(); 16 } 17 18 // static 19 base::Optional<std::vector<mojo::native::SerializedHandlePtr>> handles(IPC::MessageView & view)20StructTraits<IPC::mojom::MessageDataView, IPC::MessageView>::handles( 21 IPC::MessageView& view) { 22 return view.TakeHandles(); 23 } 24 25 // static Read(IPC::mojom::MessageDataView data,IPC::MessageView * out)26bool StructTraits<IPC::mojom::MessageDataView, IPC::MessageView>::Read( 27 IPC::mojom::MessageDataView data, 28 IPC::MessageView* out) { 29 mojo_base::BigBufferView buffer_view; 30 if (!data.ReadBuffer(&buffer_view)) 31 return false; 32 base::Optional<std::vector<mojo::native::SerializedHandlePtr>> handles; 33 if (!data.ReadHandles(&handles)) 34 return false; 35 36 *out = IPC::MessageView(std::move(buffer_view), std::move(handles)); 37 return true; 38 } 39 40 } // namespace mojo 41