1 // Copyright 2015 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 "content/browser/indexed_db/indexed_db_return_value.h" 6 7 #include <stdint.h> 8 #include <vector> 9 10 #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h" 11 12 namespace content { 13 14 // static ConvertReturnValue(IndexedDBReturnValue * value)15blink::mojom::IDBReturnValuePtr IndexedDBReturnValue::ConvertReturnValue( 16 IndexedDBReturnValue* value) { 17 auto mojo_value = blink::mojom::IDBReturnValue::New(); 18 mojo_value->value = blink::mojom::IDBValue::New(); 19 if (value->primary_key.IsValid()) { 20 mojo_value->primary_key = value->primary_key; 21 mojo_value->key_path = value->key_path; 22 } 23 if (!value->empty()) { 24 // TODO(crbug.com/902498): Use mojom traits to map directly from 25 // std::string. 26 const char* value_data = value->bits.data(); 27 mojo_value->value->bits = 28 std::vector<uint8_t>(value_data, value_data + value->bits.length()); 29 // Release value->bits std::string. 30 value->bits.clear(); 31 } 32 IndexedDBExternalObject::ConvertToMojo(value->external_objects, 33 &mojo_value->value->external_objects); 34 return mojo_value; 35 } 36 37 } // namespace content 38