| Index: third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
|
| diff --git a/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h b/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..46512182b3df1003b3ab03a5094603d0c4d16ee4
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
|
| @@ -0,0 +1,34 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CommonCustomTypesBlinkStructTraits_h
|
| +#define CommonCustomTypesBlinkStructTraits_h
|
| +
|
| +#include "public/platform/WebString.h"
|
| +#include "mojo/common/common_custom_types.mojom-blink.h"
|
| +#include "base/strings/string16.h"
|
| +#include <cstring>
|
| +
|
| +namespace mojo {
|
| +
|
| +template <>
|
| +struct StructTraits<mojo::common::mojom::String16DataView, blink::WebString> {
|
| + static WTF::Vector<uint16_t> data(const blink::WebString& str) {
|
| + base::string16 str16 = str;
|
| + WTF::Vector<uint16_t> raw_data(str16.size());
|
| + memcpy(raw_data.data(), str16.data(), str16.size() * sizeof(uint16_t));
|
| + return raw_data;
|
| + }
|
| + static bool Read(mojo::common::mojom::String16DataView data, blink::WebString* out) {
|
| + WTF::Vector<uint16_t> raw_data;
|
| + if (!data.ReadData(&raw_data))
|
| + return false;
|
| + out->assign(raw_data.begin(), raw_data.size());
|
| + return true;
|
| + }
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif // CommonCustomTypesBlinkStructTraits_h
|
|
|