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 #ifndef MOJO_PUBLIC_CPP_BASE_REF_COUNTED_MEMORY_MOJOM_TRAITS_H_ 6 #define MOJO_PUBLIC_CPP_BASE_REF_COUNTED_MEMORY_MOJOM_TRAITS_H_ 7 8 #include <string> 9 10 #include "base/component_export.h" 11 #include "base/memory/ref_counted_memory.h" 12 #include "mojo/public/cpp/base/big_buffer.h" 13 #include "mojo/public/cpp/bindings/struct_traits.h" 14 #include "mojo/public/mojom/base/ref_counted_memory.mojom-shared.h" 15 16 namespace mojo { 17 18 template <> COMPONENT_EXPORT(MOJO_BASE_MOJOM)19struct COMPONENT_EXPORT(MOJO_BASE_MOJOM) 20 StructTraits<mojo_base::mojom::RefCountedMemoryDataView, 21 scoped_refptr<base::RefCountedMemory>> { 22 static mojo_base::BigBuffer data( 23 const scoped_refptr<base::RefCountedMemory>& in); 24 25 static bool IsNull(const scoped_refptr<base::RefCountedMemory>& input); 26 static void SetToNull(scoped_refptr<base::RefCountedMemory>* out); 27 28 static bool Read(mojo_base::mojom::RefCountedMemoryDataView data, 29 scoped_refptr<base::RefCountedMemory>* out); 30 }; 31 32 } // namespace mojo 33 34 #endif // MOJO_PUBLIC_CPP_BASE_REF_COUNTED_MEMORY_MOJOM_TRAITS_H_ 35