7 #include "flutter/fml/macros.h"
8 #include "flutter/fml/platform/darwin/scoped_nsobject.h"
12 class NSDataMapping :
public fml::Mapping {
14 explicit NSDataMapping(NSData* data) : data_([data retain]) {}
16 size_t GetSize()
const override {
return [data_.get() length]; }
18 const uint8_t* GetMapping()
const override {
19 return static_cast<const uint8_t*
>([data_.get() bytes]);
22 bool IsDontNeedSafe()
const override {
return false; }
25 fml::scoped_nsobject<NSData> data_;
26 FML_DISALLOW_COPY_AND_ASSIGN(NSDataMapping);
31 const uint8_t* bytes =
static_cast<const uint8_t*
>(data.bytes);
32 return fml::MallocMapping::Copy(bytes, data.length);
36 size_t size = buffer.GetSize();
37 return [NSData dataWithBytesNoCopy:buffer.Release() length:size];
41 return std::make_unique<NSDataMapping>(data);
45 return [NSData dataWithBytes:mapping->GetMapping() length:mapping->GetSize()];